@nu-art/ts-common 0.102.30 → 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.
- package/core/dispatcher.d.ts +2 -2
- package/core/dispatcher.js +1 -1
- package/core/logger/LogClient.d.ts +1 -1
- package/core/logger/LogClient_BaseRotate.d.ts +1 -1
- package/core/logger/types.d.ts +2 -2
- package/core/module.d.ts +1 -1
- package/modules/CSVModule.d.ts +3 -3
- package/modules/CSVModule.js +1 -1
- package/modules/CliParamsModule.d.ts +3 -3
- package/modules/csv-serializer.d.ts +1 -1
- package/package.json +1 -1
- package/testing/test-case.d.ts +3 -3
- package/testing/test-case.js +1 -1
- package/tools/get-log-style.d.ts +1 -1
- package/utils/array-tools.js +1 -1
- package/utils/date-time-tools.d.ts +1 -1
- package/utils/date-time-tools.js +1 -1
- package/utils/query-params.d.ts +1 -1
- package/utils/queue.js +1 -1
- package/utils/types.d.ts +34 -34
- package/utils/version-tools.d.ts +1 -1
- package/validator/validator.d.ts +7 -7
package/core/dispatcher.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FunctionKeys, ReturnPromiseType } from '../utils/types';
|
|
2
2
|
import { Logger } from './logger/Logger';
|
|
3
|
-
export
|
|
4
|
-
export
|
|
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;
|
package/core/dispatcher.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]) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { LogLevel, LogParam, LogPrefixComposer } from "./types";
|
|
2
|
-
export
|
|
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
|
-
|
|
3
|
+
type LogRotateListener = () => void;
|
|
4
4
|
export declare abstract class LogClient_BaseRotate extends LogClient {
|
|
5
5
|
readonly name: string;
|
|
6
6
|
readonly maxEntries: number;
|
package/core/logger/types.d.ts
CHANGED
|
@@ -6,5 +6,5 @@ export declare enum LogLevel {
|
|
|
6
6
|
Error = "Error"
|
|
7
7
|
}
|
|
8
8
|
export declare const LogLevelOrdinal: LogLevel[];
|
|
9
|
-
export
|
|
10
|
-
export
|
|
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
|
-
|
|
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 {
|
package/modules/CSVModule.d.ts
CHANGED
|
@@ -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
|
-
|
|
10
|
+
type Config = {
|
|
11
11
|
options: Options;
|
|
12
12
|
};
|
|
13
|
-
export
|
|
13
|
+
export type ReadPropsMap<K extends TS_Object = TS_Object> = {
|
|
14
14
|
[s: string]: keyof K;
|
|
15
15
|
};
|
|
16
|
-
export
|
|
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> {
|
package/modules/CSVModule.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]) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Module } from '../core/module';
|
|
2
2
|
import { TypedMap } from '../utils/types';
|
|
3
|
-
export
|
|
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
|
-
|
|
14
|
-
|
|
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> {
|
package/package.json
CHANGED
package/testing/test-case.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export
|
|
1
|
+
export type TestCase<Input, Result> = {
|
|
2
2
|
expected?: Result;
|
|
3
3
|
input: Input;
|
|
4
4
|
};
|
|
5
|
-
export
|
|
6
|
-
export
|
|
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[];
|
package/testing/test-case.js
CHANGED
|
@@ -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]) {
|
package/tools/get-log-style.d.ts
CHANGED
package/utils/array-tools.js
CHANGED
|
@@ -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
|
|
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;
|
package/utils/date-time-tools.js
CHANGED
|
@@ -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]) {
|
package/utils/query-params.d.ts
CHANGED
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
|
|
1
|
+
export type CustomOptional<T, K> = {
|
|
2
2
|
[P in keyof T]?: K;
|
|
3
3
|
};
|
|
4
|
-
export
|
|
4
|
+
export type Subset<T> = {
|
|
5
5
|
[P in keyof T]: T[P];
|
|
6
6
|
};
|
|
7
|
-
export
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
26
|
-
export
|
|
27
|
-
export
|
|
28
|
-
export
|
|
29
|
-
export
|
|
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
|
|
33
|
+
export type Identity = {
|
|
34
34
|
id: string;
|
|
35
35
|
};
|
|
36
|
-
export
|
|
36
|
+
export type StringMap = {
|
|
37
37
|
[s: string]: string;
|
|
38
38
|
};
|
|
39
|
-
export
|
|
39
|
+
export type TS_Object = {
|
|
40
40
|
[s: string]: any;
|
|
41
41
|
};
|
|
42
|
-
export
|
|
42
|
+
export type TypedMap<ValueType> = {
|
|
43
43
|
[s: string]: ValueType;
|
|
44
44
|
};
|
|
45
|
-
export
|
|
45
|
+
export type TypedMapValue<T extends TS_Object, ValueType> = {
|
|
46
46
|
[P in keyof T]: ValueType;
|
|
47
47
|
};
|
|
48
|
-
export
|
|
49
|
-
export
|
|
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
|
|
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
|
|
59
|
-
export
|
|
60
|
-
export
|
|
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
|
|
63
|
+
export type Auditable = {
|
|
64
64
|
_audit?: AuditBy;
|
|
65
65
|
};
|
|
66
|
-
export
|
|
66
|
+
export type AuditBy = {
|
|
67
67
|
comment?: string;
|
|
68
68
|
auditBy: string;
|
|
69
69
|
auditAt: Timestamp;
|
|
70
70
|
};
|
|
71
|
-
export
|
|
71
|
+
export type Timestamp = {
|
|
72
72
|
timestamp: number;
|
|
73
73
|
pretty: string;
|
|
74
74
|
timezone?: string;
|
|
75
75
|
};
|
|
76
|
-
export
|
|
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
|
|
80
|
+
export type PackageJson = {
|
|
81
81
|
version: string;
|
|
82
82
|
name: string;
|
|
83
83
|
};
|
|
84
|
-
export
|
|
85
|
-
export
|
|
86
|
-
export
|
|
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
|
|
91
|
-
export
|
|
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;
|
package/utils/version-tools.d.ts
CHANGED
package/validator/validator.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { CustomException } from '../core/exceptions';
|
|
2
2
|
import { ArrayType, AuditBy, RangeTimestamp, TS_Object } from '../utils/types';
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
export
|
|
6
|
-
export
|
|
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
|
|
9
|
+
export type InvalidResultObject<T extends any> = {
|
|
10
10
|
[K in keyof T]?: InvalidResult<T[K]>;
|
|
11
11
|
};
|
|
12
|
-
export
|
|
13
|
-
export
|
|
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>;
|