@leyyo/common 1.0.12 → 1.2.1
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/dist/deploy/deploy.common.d.ts +12 -7
- package/dist/deploy/deploy.common.js +29 -10
- package/dist/deploy/deploy.common.js.map +1 -1
- package/dist/deploy/index.types.d.ts +12 -8
- package/dist/error/error.common.d.ts +11 -20
- package/dist/error/error.common.js +145 -86
- package/dist/error/error.common.js.map +1 -1
- package/dist/error/http-error.map.d.ts +6 -0
- package/dist/error/http-error.map.js +25 -0
- package/dist/error/http-error.map.js.map +1 -0
- package/dist/error/index.d.ts +2 -0
- package/dist/error/index.js +2 -0
- package/dist/error/index.js.map +1 -1
- package/dist/error/index.types.d.ts +34 -36
- package/dist/error/items/bad-request.error.d.ts +10 -0
- package/dist/error/items/bad-request.error.js +16 -0
- package/dist/error/items/bad-request.error.js.map +1 -0
- package/dist/error/items/caused.error.d.ts +8 -0
- package/dist/error/items/caused.error.js +16 -0
- package/dist/error/items/caused.error.js.map +1 -0
- package/dist/error/items/conflict.error.d.ts +10 -0
- package/dist/error/items/conflict.error.js +16 -0
- package/dist/error/items/conflict.error.js.map +1 -0
- package/dist/error/items/content-too-large.error.d.ts +10 -0
- package/dist/error/items/content-too-large.error.js +16 -0
- package/dist/error/items/content-too-large.error.js.map +1 -0
- package/dist/error/items/developer.error.d.ts +4 -0
- package/dist/error/items/developer.error.js +9 -0
- package/dist/error/items/developer.error.js.map +1 -0
- package/dist/error/items/forbidden.error.d.ts +10 -0
- package/dist/error/items/forbidden.error.js +16 -0
- package/dist/error/items/forbidden.error.js.map +1 -0
- package/dist/error/items/gone.error.d.ts +10 -0
- package/dist/error/items/gone.error.js +16 -0
- package/dist/error/items/gone.error.js.map +1 -0
- package/dist/error/items/http.error.d.ts +15 -0
- package/dist/error/items/http.error.js +21 -0
- package/dist/error/items/http.error.js.map +1 -0
- package/dist/error/items/index.d.ts +21 -0
- package/dist/error/items/index.js +38 -0
- package/dist/error/items/index.js.map +1 -0
- package/dist/error/items/invalid-value.error.d.ts +6 -0
- package/dist/error/items/invalid-value.error.js +11 -0
- package/dist/error/items/invalid-value.error.js.map +1 -0
- package/dist/error/items/length-required.error.d.ts +10 -0
- package/dist/error/items/length-required.error.js +16 -0
- package/dist/error/items/length-required.error.js.map +1 -0
- package/dist/error/items/leyyo.error.d.ts +50 -0
- package/dist/error/items/leyyo.error.js +98 -0
- package/dist/error/items/leyyo.error.js.map +1 -0
- package/dist/error/items/method-not-allowed.error.d.ts +10 -0
- package/dist/error/items/method-not-allowed.error.js +16 -0
- package/dist/error/items/method-not-allowed.error.js.map +1 -0
- package/dist/error/items/multiple.error.d.ts +11 -0
- package/dist/error/items/multiple.error.js +34 -0
- package/dist/error/items/multiple.error.js.map +1 -0
- package/dist/error/items/not-acceptable.error.d.ts +10 -0
- package/dist/error/items/not-acceptable.error.js +16 -0
- package/dist/error/items/not-acceptable.error.js.map +1 -0
- package/dist/error/items/not-found.error.d.ts +10 -0
- package/dist/error/items/not-found.error.js +16 -0
- package/dist/error/items/not-found.error.js.map +1 -0
- package/dist/error/items/payment-required.error.d.ts +10 -0
- package/dist/error/items/payment-required.error.js +16 -0
- package/dist/error/items/payment-required.error.js.map +1 -0
- package/dist/error/items/precondition-failed.error.d.ts +10 -0
- package/dist/error/items/precondition-failed.error.js +16 -0
- package/dist/error/items/precondition-failed.error.js.map +1 -0
- package/dist/error/items/proxy-authentication-required.error.d.ts +10 -0
- package/dist/error/items/proxy-authentication-required.error.js +16 -0
- package/dist/error/items/proxy-authentication-required.error.js.map +1 -0
- package/dist/error/items/request-timeout.error.d.ts +10 -0
- package/dist/error/items/request-timeout.error.js +16 -0
- package/dist/error/items/request-timeout.error.js.map +1 -0
- package/dist/error/items/silent.error.d.ts +11 -0
- package/dist/error/items/silent.error.js +19 -0
- package/dist/error/items/silent.error.js.map +1 -0
- package/dist/error/items/unauthorized.error.d.ts +10 -0
- package/dist/error/items/unauthorized.error.js +16 -0
- package/dist/error/items/unauthorized.error.js.map +1 -0
- package/dist/event/event.common.d.ts +77 -0
- package/dist/event/event.common.js +308 -0
- package/dist/event/event.common.js.map +1 -0
- package/dist/event/event.error.d.ts +3 -0
- package/dist/event/event.error.js +8 -0
- package/dist/event/event.error.js.map +1 -0
- package/dist/event/index.js.map +1 -0
- package/dist/event/index.types.d.ts +261 -0
- package/dist/{hook → event}/index.types.js.map +1 -1
- package/dist/hub/hub.channel.d.ts +27 -0
- package/dist/hub/hub.channel.js +83 -0
- package/dist/hub/hub.channel.js.map +1 -0
- package/dist/hub/hub.common.d.ts +27 -0
- package/dist/hub/hub.common.js +92 -0
- package/dist/hub/hub.common.js.map +1 -0
- package/dist/hub/index.js.map +1 -0
- package/dist/hub/index.types.d.ts +105 -0
- package/dist/{to → hub}/index.types.js.map +1 -1
- package/dist/index.d.ts +5 -23
- package/dist/index.js +7 -25
- package/dist/index.js.map +1 -1
- package/dist/leyyo/index.d.ts +0 -1
- package/dist/leyyo/index.js +0 -1
- package/dist/leyyo/index.js.map +1 -1
- package/dist/leyyo/index.types.d.ts +4 -22
- package/dist/leyyo/leyyo.d.ts +4 -22
- package/dist/leyyo/leyyo.js +12 -39
- package/dist/leyyo/leyyo.js.map +1 -1
- package/dist/log/index.d.ts +1 -1
- package/dist/log/index.js +1 -1
- package/dist/log/index.js.map +1 -1
- package/dist/log/index.types.d.ts +22 -29
- package/dist/log/log-level.d.ts +7 -0
- package/dist/log/log-level.js +9 -0
- package/dist/log/log-level.js.map +1 -0
- package/dist/log/log.common.d.ts +1 -1
- package/dist/log/log.common.js +28 -53
- package/dist/log/log.common.js.map +1 -1
- package/dist/log/logger.error.d.ts +3 -0
- package/dist/log/logger.error.js +8 -0
- package/dist/log/logger.error.js.map +1 -0
- package/dist/log/logger.instance.d.ts +9 -11
- package/dist/log/logger.instance.js +42 -52
- package/dist/log/logger.instance.js.map +1 -1
- package/dist/name/index.types.d.ts +1 -1
- package/dist/name/name.common.js +64 -37
- package/dist/name/name.common.js.map +1 -1
- package/dist/name/name.error.d.ts +3 -0
- package/dist/name/name.error.js +8 -0
- package/dist/name/name.error.js.map +1 -0
- package/dist/opt/index.js.map +1 -0
- package/dist/opt/index.types.d.ts +33 -0
- package/dist/{fqn → opt}/index.types.js.map +1 -1
- package/dist/opt/opt.common.d.ts +15 -0
- package/dist/opt/opt.common.js +93 -0
- package/dist/opt/opt.common.js.map +1 -0
- package/dist/repo/index.types.d.ts +1 -19
- package/dist/repo/repo.common.d.ts +0 -6
- package/dist/repo/repo.common.js +0 -20
- package/dist/repo/repo.common.js.map +1 -1
- package/dist/server.js +1 -1
- package/dist/server.js.map +1 -1
- package/dist/shared/index.d.ts +3 -0
- package/dist/shared/index.enum.d.ts +7 -0
- package/dist/{exception/index.types.js → shared/index.enum.js} +1 -1
- package/dist/shared/index.enum.js.map +1 -0
- package/dist/shared/index.fqn.d.ts +3 -0
- package/dist/shared/index.fqn.js +3 -0
- package/dist/shared/index.fqn.js.map +1 -0
- package/dist/shared/index.js +3 -0
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/index.json.d.ts +33 -0
- package/dist/shared/index.json.js +3 -0
- package/dist/shared/index.json.js.map +1 -0
- package/dist/shared/index.types.d.ts +78 -100
- package/dist/shared/index.types.js +31 -0
- package/dist/shared/index.types.js.map +1 -1
- package/dist/util/delay.d.ts +9 -0
- package/dist/util/delay.js +21 -0
- package/dist/util/delay.js.map +1 -0
- package/dist/util/empty.fn.d.ts +8 -0
- package/dist/util/empty.fn.js +11 -0
- package/dist/util/empty.fn.js.map +1 -0
- package/dist/util/index.d.ts +5 -0
- package/dist/{developer → util}/index.js +5 -2
- package/dist/util/index.js.map +1 -0
- package/dist/util/one-or-more.d.ts +8 -0
- package/dist/util/one-or-more.js +19 -0
- package/dist/util/one-or-more.js.map +1 -0
- package/dist/util/secure-clone.d.ts +3 -0
- package/dist/util/secure-clone.js +38 -0
- package/dist/util/secure-clone.js.map +1 -0
- package/dist/util/secure-json.d.ts +37 -0
- package/dist/util/secure-json.js +126 -0
- package/dist/util/secure-json.js.map +1 -0
- package/package.json +2 -2
- package/dist/assertion/assertion.common.d.ts +0 -183
- package/dist/assertion/assertion.common.js +0 -663
- package/dist/assertion/assertion.common.js.map +0 -1
- package/dist/assertion/index.js.map +0 -1
- package/dist/assertion/index.types.d.ts +0 -661
- package/dist/assertion/index.types.js.map +0 -1
- package/dist/descriptor/descriptor.common.d.ts +0 -22
- package/dist/descriptor/descriptor.common.js +0 -117
- package/dist/descriptor/descriptor.common.js.map +0 -1
- package/dist/descriptor/index.js.map +0 -1
- package/dist/descriptor/index.types.d.ts +0 -23
- package/dist/descriptor/index.types.js.map +0 -1
- package/dist/developer/developer.common.d.ts +0 -32
- package/dist/developer/developer.common.js +0 -245
- package/dist/developer/developer.common.js.map +0 -1
- package/dist/developer/index.d.ts +0 -2
- package/dist/developer/index.errors.d.ts +0 -13
- package/dist/developer/index.errors.js +0 -24
- package/dist/developer/index.errors.js.map +0 -1
- package/dist/developer/index.js.map +0 -1
- package/dist/developer/index.types.d.ts +0 -85
- package/dist/developer/index.types.js.map +0 -1
- package/dist/exception/assertion.exception.d.ts +0 -5
- package/dist/exception/assertion.exception.js +0 -12
- package/dist/exception/assertion.exception.js.map +0 -1
- package/dist/exception/caused.exception.d.ts +0 -5
- package/dist/exception/caused.exception.js +0 -13
- package/dist/exception/caused.exception.js.map +0 -1
- package/dist/exception/developer.exception.d.ts +0 -5
- package/dist/exception/developer.exception.js +0 -12
- package/dist/exception/developer.exception.js.map +0 -1
- package/dist/exception/exception.d.ts +0 -32
- package/dist/exception/exception.js +0 -117
- package/dist/exception/exception.js.map +0 -1
- package/dist/exception/index.d.ts +0 -7
- package/dist/exception/index.js +0 -24
- package/dist/exception/index.js.map +0 -1
- package/dist/exception/index.types.d.ts +0 -30
- package/dist/exception/index.types.js.map +0 -1
- package/dist/exception/invalid-value.exception.d.ts +0 -5
- package/dist/exception/invalid-value.exception.js +0 -12
- package/dist/exception/invalid-value.exception.js.map +0 -1
- package/dist/exception/multiple.exception.d.ts +0 -8
- package/dist/exception/multiple.exception.js +0 -34
- package/dist/exception/multiple.exception.js.map +0 -1
- package/dist/fqn/fqn.common.d.ts +0 -20
- package/dist/fqn/fqn.common.js +0 -123
- package/dist/fqn/fqn.common.js.map +0 -1
- package/dist/fqn/index.js.map +0 -1
- package/dist/fqn/index.types.d.ts +0 -20
- package/dist/fqn/index.types.js +0 -3
- package/dist/hook/hook.common.d.ts +0 -25
- package/dist/hook/hook.common.js +0 -95
- package/dist/hook/hook.common.js.map +0 -1
- package/dist/hook/index.d.ts +0 -1
- package/dist/hook/index.js +0 -18
- package/dist/hook/index.js.map +0 -1
- package/dist/hook/index.types.d.ts +0 -72
- package/dist/hook/index.types.js +0 -3
- package/dist/is/index.d.ts +0 -1
- package/dist/is/index.js +0 -18
- package/dist/is/index.js.map +0 -1
- package/dist/is/index.types.d.ts +0 -240
- package/dist/is/index.types.js +0 -3
- package/dist/is/index.types.js.map +0 -1
- package/dist/is/is.common.d.ts +0 -71
- package/dist/is/is.common.js +0 -177
- package/dist/is/is.common.js.map +0 -1
- package/dist/leyyo/leyyo-hook.common.d.ts +0 -10
- package/dist/leyyo/leyyo-hook.common.js +0 -18
- package/dist/leyyo/leyyo-hook.common.js.map +0 -1
- package/dist/log/severity.d.ts +0 -8
- package/dist/log/severity.js +0 -8
- package/dist/log/severity.js.map +0 -1
- package/dist/mixin/index.d.ts +0 -1
- package/dist/mixin/index.js +0 -18
- package/dist/mixin/index.js.map +0 -1
- package/dist/mixin/index.types.d.ts +0 -19
- package/dist/mixin/index.types.js +0 -3
- package/dist/mixin/index.types.js.map +0 -1
- package/dist/mixin/mixin.common.d.ts +0 -22
- package/dist/mixin/mixin.common.js +0 -165
- package/dist/mixin/mixin.common.js.map +0 -1
- package/dist/system/country-code.d.ts +0 -8
- package/dist/system/country-code.js +0 -18
- package/dist/system/country-code.js.map +0 -1
- package/dist/system/environment.d.ts +0 -8
- package/dist/system/environment.js +0 -8
- package/dist/system/environment.js.map +0 -1
- package/dist/system/index.d.ts +0 -7
- package/dist/system/index.js +0 -24
- package/dist/system/index.js.map +0 -1
- package/dist/system/index.types.d.ts +0 -6
- package/dist/system/index.types.js +0 -3
- package/dist/system/index.types.js.map +0 -1
- package/dist/system/language-code.d.ts +0 -8
- package/dist/system/language-code.js +0 -13
- package/dist/system/language-code.js.map +0 -1
- package/dist/system/locale-code.d.ts +0 -10
- package/dist/system/locale-code.js +0 -18
- package/dist/system/locale-code.js.map +0 -1
- package/dist/system/sys-class.d.ts +0 -2
- package/dist/system/sys-class.js +0 -20
- package/dist/system/sys-class.js.map +0 -1
- package/dist/system/sys-function.d.ts +0 -2
- package/dist/system/sys-function.js +0 -7
- package/dist/system/sys-function.js.map +0 -1
- package/dist/system/system.common.d.ts +0 -11
- package/dist/system/system.common.js +0 -64
- package/dist/system/system.common.js.map +0 -1
- package/dist/test/index.d.ts +0 -2
- package/dist/test/index.js +0 -19
- package/dist/test/index.js.map +0 -1
- package/dist/test/index.types.d.ts +0 -9
- package/dist/test/index.types.js +0 -3
- package/dist/test/index.types.js.map +0 -1
- package/dist/test/test.common.d.ts +0 -14
- package/dist/test/test.common.js +0 -48
- package/dist/test/test.common.js.map +0 -1
- package/dist/test/tested.d.ts +0 -1
- package/dist/test/tested.js +0 -9
- package/dist/test/tested.js.map +0 -1
- package/dist/to/index.d.ts +0 -7
- package/dist/to/index.js +0 -24
- package/dist/to/index.js.map +0 -1
- package/dist/to/index.types.d.ts +0 -76
- package/dist/to/index.types.js +0 -3
- package/dist/to/key-value.d.ts +0 -4
- package/dist/to/key-value.js +0 -8
- package/dist/to/key-value.js.map +0 -1
- package/dist/to/list.d.ts +0 -20
- package/dist/to/list.js +0 -38
- package/dist/to/list.js.map +0 -1
- package/dist/to/primitive.d.ts +0 -8
- package/dist/to/primitive.js +0 -8
- package/dist/to/primitive.js.map +0 -1
- package/dist/to/real-value.d.ts +0 -8
- package/dist/to/real-value.js +0 -8
- package/dist/to/real-value.js.map +0 -1
- package/dist/to/to.common.d.ts +0 -77
- package/dist/to/to.common.js +0 -1079
- package/dist/to/to.common.js.map +0 -1
- package/dist/to/weak-false.d.ts +0 -8
- package/dist/to/weak-false.js +0 -8
- package/dist/to/weak-false.js.map +0 -1
- package/dist/to/weak-true.d.ts +0 -8
- package/dist/to/weak-true.js +0 -8
- package/dist/to/weak-true.js.map +0 -1
- package/dist/wrapper/index.d.ts +0 -2
- package/dist/wrapper/index.js +0 -19
- package/dist/wrapper/index.js.map +0 -1
- package/dist/wrapper/index.types.d.ts +0 -29
- package/dist/wrapper/index.types.js +0 -3
- package/dist/wrapper/index.types.js.map +0 -1
- package/dist/wrapper/wrap.d.ts +0 -7
- package/dist/wrapper/wrap.js +0 -11
- package/dist/wrapper/wrap.js.map +0 -1
- package/dist/wrapper/wrapper.common.d.ts +0 -26
- package/dist/wrapper/wrapper.common.js +0 -82
- package/dist/wrapper/wrapper.common.js.map +0 -1
- /package/dist/{assertion → event}/index.d.ts +0 -0
- /package/dist/{assertion → event}/index.js +0 -0
- /package/dist/{assertion → event}/index.types.js +0 -0
- /package/dist/{descriptor → hub}/index.d.ts +0 -0
- /package/dist/{descriptor → hub}/index.js +0 -0
- /package/dist/{descriptor → hub}/index.types.js +0 -0
- /package/dist/{fqn → opt}/index.d.ts +0 -0
- /package/dist/{fqn → opt}/index.js +0 -0
- /package/dist/{developer → opt}/index.types.js +0 -0
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
export type HttpStatus = number;
|
|
2
2
|
export type BasicType = 'undefined' | 'string' | 'object' | 'number' | 'boolean' | 'function' | 'symbol' | 'bigint';
|
|
3
|
+
export type ExtendedType = BasicType | 'array' | 'class' | 'null' | 'empty' | 'nan' | 'integer' | 'date' | 'enum';
|
|
4
|
+
export type KeyValue = string | number;
|
|
5
|
+
export type AnyKey = string | number | symbol;
|
|
6
|
+
export type Obj = Object & {};
|
|
3
7
|
export type Dict<T = unknown> = Record<KeyValue, T>;
|
|
4
8
|
export type Arr<T = unknown> = Array<T>;
|
|
5
|
-
export type KeyValue = string | number;
|
|
6
9
|
export type Id = string | number;
|
|
7
|
-
export type Unknown = unknown;
|
|
8
10
|
export type Integer = number;
|
|
9
11
|
export type Float = number;
|
|
10
|
-
export type Boolean = boolean;
|
|
11
|
-
export type Enum = string;
|
|
12
12
|
export type Alpha = string;
|
|
13
|
-
export type
|
|
13
|
+
export type Text = string;
|
|
14
14
|
export type Digit = string;
|
|
15
15
|
export type Title = string;
|
|
16
16
|
export type Description = string;
|
|
@@ -24,75 +24,66 @@ export type Timestamp = number;
|
|
|
24
24
|
export type IsoDatetime = string;
|
|
25
25
|
export type IsoDate = string;
|
|
26
26
|
export type IsoTime = string;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
(...args:
|
|
27
|
+
export type Fnc<R = unknown> = ((...args: Arr) => R) & Function;
|
|
28
|
+
export type Async<R = unknown> = ((...args: Arr) => Promise<R>) & AsyncGeneratorFunction;
|
|
29
|
+
export interface Abstract<T = {}> extends Function {
|
|
30
|
+
prototype: T;
|
|
31
|
+
readonly name: string;
|
|
32
|
+
readonly length: number;
|
|
33
|
+
bind(thisArg: unknown, ...args: Arr): unknown;
|
|
34
|
+
apply(thisArg: unknown, args: Arr): unknown;
|
|
35
|
+
call(thisArg: unknown, ...args: Arr): unknown;
|
|
36
36
|
}
|
|
37
|
-
interface
|
|
38
|
-
(...args:
|
|
37
|
+
export interface ClassLike<T = {}> extends Abstract<T> {
|
|
38
|
+
new (...args: Arr): T;
|
|
39
39
|
}
|
|
40
|
-
export type Fnc<R = unknown> = _SyncFnc<R> & Function;
|
|
41
|
-
export type Async<R = unknown> = _AsyncFnc<R> & AsyncGeneratorFunction;
|
|
42
|
-
export type AnyFnc<R = unknown> = Fnc<R> | Async<R>;
|
|
43
|
-
export type _Type<T> = {
|
|
44
|
-
new (...args: Array<unknown>): T;
|
|
45
|
-
prototype?: unknown;
|
|
46
|
-
};
|
|
47
|
-
export type ClassLike<T = {}> = (_BaseFunc & _Type<T>) | _SyncFnc<T>;
|
|
48
40
|
export type TypeOf<C = ClassLike> = C extends ClassLike<infer T> ? T : C;
|
|
41
|
+
export declare namespace Express {
|
|
42
|
+
interface Request {
|
|
43
|
+
custom?: Dict;
|
|
44
|
+
}
|
|
45
|
+
interface Response {
|
|
46
|
+
custom?: Dict;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
49
|
export interface Describable {
|
|
50
50
|
description: string;
|
|
51
51
|
}
|
|
52
52
|
export interface Nameable {
|
|
53
53
|
name: string;
|
|
54
54
|
}
|
|
55
|
-
export
|
|
56
|
-
|
|
57
|
-
export type ClassOrFuncOrName = ClassLike | Function | string;
|
|
58
|
-
/**
|
|
59
|
-
* Referenced from Object
|
|
60
|
-
* */
|
|
61
|
-
export type Obj = Object & {};
|
|
62
|
-
export interface Abstract<T> extends Function {
|
|
63
|
-
prototype: T;
|
|
64
|
-
}
|
|
65
|
-
export interface Entity<I extends Id = Uuid> {
|
|
66
|
-
id?: I;
|
|
67
|
-
}
|
|
68
|
-
export interface Pair<I extends Id = Uuid> extends Entity<I> {
|
|
69
|
-
name?: string;
|
|
55
|
+
export interface HasId {
|
|
56
|
+
id?: string | number;
|
|
70
57
|
}
|
|
71
58
|
export type TypeOfMethod<T, M extends keyof T> = T[M] extends Function ? T[M] : never;
|
|
59
|
+
export type TypeOfFnc<F extends Fnc> = F extends (...args: Arr) => infer R ? R : never;
|
|
60
|
+
export type TypeOfAsync<F extends Async> = TypeOfPromise<TypeOfFnc<F>>;
|
|
61
|
+
export type TypeOfPromise<P> = P extends Promise<infer R> ? R : P;
|
|
62
|
+
/**
|
|
63
|
+
* String keys of a interface
|
|
64
|
+
* - Note: keyof keywords returns string|number|symbol, but it's ignore nuöber and symbol keys
|
|
65
|
+
* */
|
|
66
|
+
export type StrKey<T> = Extract<keyof T, string>;
|
|
67
|
+
/**
|
|
68
|
+
* Serialized version of another type
|
|
69
|
+
*/
|
|
70
|
+
export type Serialized<T> = {
|
|
71
|
+
[P in keyof T]: T[P];
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* Makes mutable an interface
|
|
75
|
+
*
|
|
76
|
+
* @see Readonly
|
|
77
|
+
* */
|
|
78
|
+
export type Mutable<A> = {
|
|
79
|
+
-readonly [K in keyof A]: A[K];
|
|
80
|
+
};
|
|
72
81
|
export type KeyOf<T> = keyof T;
|
|
73
82
|
export type Keys<T> = Array<keyof T>;
|
|
74
83
|
export type ValueOf<T> = T[KeyOf<T>];
|
|
75
84
|
export type Values<T> = Array<T[KeyOf<T>]>;
|
|
76
|
-
export type MaximumOneOf<T, K extends keyof T = keyof T> = K extends keyof T ? {
|
|
77
|
-
[P in K]: T[K];
|
|
78
|
-
} & Partial<Record<Exclude<keyof T, K>, never>> : never;
|
|
79
|
-
export type OneOf<Obj> = ValueOf<OneOfByKey<Obj>>;
|
|
80
|
-
export type Xor<A, B> = XorIn<A & {
|
|
81
|
-
[K in keyof B]?: undefined;
|
|
82
|
-
}> | XorIn<B & {
|
|
83
|
-
[K in keyof A]?: undefined;
|
|
84
|
-
}>;
|
|
85
85
|
export type OneOrMore<T> = T | Array<T>;
|
|
86
|
-
export type
|
|
87
|
-
export type ValueCallback<T> = () => T;
|
|
88
|
-
export type ValueCallbackAsync<T> = () => Promise<T>;
|
|
89
|
-
type OneOnly<T, K extends keyof T> = Omit<T, Exclude<keyof T, K>> | Pick<T, K>;
|
|
90
|
-
type OneOfByKey<T> = {
|
|
91
|
-
[key in keyof T]: OneOnly<T, key>;
|
|
92
|
-
};
|
|
93
|
-
type XorIn<T> = {
|
|
94
|
-
[K in keyof T]: T[K];
|
|
95
|
-
} & unknown;
|
|
86
|
+
export type SetOrMore<T> = T | Set<T>;
|
|
96
87
|
/**
|
|
97
88
|
* An interface which contains secure mode members and provides to shift to main mode
|
|
98
89
|
* */
|
|
@@ -133,42 +124,11 @@ export interface InitLike {
|
|
|
133
124
|
* */
|
|
134
125
|
$init(...args: Arr): void;
|
|
135
126
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
*/
|
|
139
|
-
export type JsonObject = {
|
|
140
|
-
[K in string]?: JsonValue;
|
|
127
|
+
export type EnumMap<E extends KeyValue = KeyValue> = {
|
|
128
|
+
[K in E]: KeyValue;
|
|
141
129
|
};
|
|
142
|
-
/**
|
|
143
|
-
* JSON Array
|
|
144
|
-
*/
|
|
145
|
-
export type JsonArray = Array<JsonValue>;
|
|
146
|
-
/**
|
|
147
|
-
* JSON Primitives
|
|
148
|
-
*/
|
|
149
|
-
export type JsonPrimitive = string | number | boolean | null;
|
|
150
|
-
/**
|
|
151
|
-
* JSON Values
|
|
152
|
-
*/
|
|
153
|
-
export type JsonValue = JsonPrimitive | JsonObject | JsonArray;
|
|
154
|
-
/**
|
|
155
|
-
* Primitive language key
|
|
156
|
-
*
|
|
157
|
-
* It can be language (xx), local (xx-xx) or string (not preferred)
|
|
158
|
-
* */
|
|
159
|
-
export type I18nKey = LanguageCode | LocaleCode | string;
|
|
160
|
-
/**
|
|
161
|
-
* Language map
|
|
162
|
-
*
|
|
163
|
-
* @example
|
|
164
|
-
* const name = {en: "Apple", tr: "Elma"};
|
|
165
|
-
*
|
|
166
|
-
* */
|
|
167
|
-
export type I18nRaw<V = unknown> = Dict<V>;
|
|
168
|
-
export type I18nAny<V = unknown> = I18nRaw<V> | V;
|
|
169
|
-
export type EnumMap<E extends KeyValue = KeyValue> = Dict<E>;
|
|
170
130
|
export type EnumAlt<E extends KeyValue = KeyValue> = Dict<E>;
|
|
171
|
-
export type EnumLiteral<E extends KeyValue = KeyValue> = Array<E> |
|
|
131
|
+
export type EnumLiteral<E extends KeyValue = KeyValue> = Array<E> | ReadonlyArray<E>;
|
|
172
132
|
export type IgnoreFieldsByType<T, I> = {
|
|
173
133
|
[K in keyof T]: T[K] extends I ? K : never;
|
|
174
134
|
}[keyof T];
|
|
@@ -178,13 +138,31 @@ export type ReplaceType<T, O, N> = {
|
|
|
178
138
|
export type SameType<A, T> = {
|
|
179
139
|
[K in keyof A]: T;
|
|
180
140
|
};
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
*/
|
|
184
|
-
export type Serialized<T> = {
|
|
185
|
-
[P in keyof T]: T[P];
|
|
141
|
+
export type PickByType<T, I> = {
|
|
142
|
+
[K in keyof T]: T[K] extends I ? K : never;
|
|
186
143
|
};
|
|
187
|
-
export type
|
|
188
|
-
|
|
144
|
+
export type PickKeyByType<T, I> = PickByType<T, I>[keyof T];
|
|
145
|
+
export type OmitByType<T, I> = {
|
|
146
|
+
[K in keyof T]: T[K] extends I ? never : K;
|
|
147
|
+
};
|
|
148
|
+
export type OmitKeysByType<T, I> = OmitByType<T, I>[keyof T];
|
|
149
|
+
export type ValueOrCallback<T> = T | ValueCallback<T> | ValueCallbackAsync<T>;
|
|
150
|
+
export type ValueCallback<T> = () => T;
|
|
151
|
+
export type ValueCallbackAsync<T> = () => Promise<T>;
|
|
152
|
+
export type MaximumOneOf<T, K extends keyof T = keyof T> = K extends keyof T ? {
|
|
153
|
+
[P in K]: T[K];
|
|
154
|
+
} & Partial<Record<Exclude<keyof T, K>, never>> : never;
|
|
155
|
+
export type OneOf<Obj> = ValueOf<OneOfByKey<Obj>>;
|
|
156
|
+
export type Xor<A, B> = XorIn<A & {
|
|
157
|
+
[K in keyof B]?: undefined;
|
|
158
|
+
}> | XorIn<B & {
|
|
159
|
+
[K in keyof A]?: undefined;
|
|
160
|
+
}>;
|
|
161
|
+
type OneOnly<T, K extends keyof T> = Omit<T, Exclude<keyof T, K>> | Pick<T, K>;
|
|
162
|
+
type OneOfByKey<T> = {
|
|
163
|
+
[key in keyof T]: OneOnly<T, key>;
|
|
189
164
|
};
|
|
165
|
+
type XorIn<T> = {
|
|
166
|
+
[K in keyof T]: T[K];
|
|
167
|
+
} & unknown;
|
|
190
168
|
export {};
|
|
@@ -2,4 +2,35 @@
|
|
|
2
2
|
// noinspection JSUnusedGlobalSymbols
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
// endregion
|
|
5
|
+
/*
|
|
6
|
+
|
|
7
|
+
// export type StrObject<T> = {
|
|
8
|
+
// [K in keyof T ]: K extends string ? K : never;
|
|
9
|
+
// };
|
|
10
|
+
// export type StrKey<T> = keyof StrObject<T>;
|
|
11
|
+
|
|
12
|
+
interface _BaseFunc {
|
|
13
|
+
readonly name?: string;
|
|
14
|
+
readonly length?: number;
|
|
15
|
+
bind(thisArg: unknown, ...args: Array<unknown>): unknown;
|
|
16
|
+
|
|
17
|
+
apply(thisArg: unknown, args: Array<unknown>): unknown;
|
|
18
|
+
|
|
19
|
+
call(thisArg: unknown, ...args: Array<unknown>): unknown;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface _SyncFnc<R> extends _BaseFunc {
|
|
23
|
+
(...args: Array<unknown>): R;
|
|
24
|
+
}
|
|
25
|
+
interface _AsyncFnc<R> extends _BaseFunc {
|
|
26
|
+
(...args: Array<unknown>): Promise<R>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
// export type ClassOrName = ClassLike | string;
|
|
30
|
+
// export type FuncOrName = Function | string;
|
|
31
|
+
// export type ClassOrFuncOrName = ClassLike | Function | string;
|
|
32
|
+
// export type ClassLike<T = {}> = (_BaseFunc & _Type<T>) | _SyncFnc<T>;
|
|
33
|
+
// export type AnyFnc<R = unknown> = Fnc<R> | Async<R>;
|
|
34
|
+
|
|
35
|
+
*/
|
|
5
36
|
//# sourceMappingURL=index.types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.types.js","sourceRoot":"","sources":["../../src/shared/index.types.ts"],"names":[],"mappings":";AAAA,qCAAqC;;
|
|
1
|
+
{"version":3,"file":"index.types.js","sourceRoot":"","sources":["../../src/shared/index.types.ts"],"names":[],"mappings":";AAAA,qCAAqC;;AAsNrC,YAAY;AAGZ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8BE"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.delay = delay;
|
|
4
|
+
/**
|
|
5
|
+
* Delay or sleep n msec
|
|
6
|
+
*
|
|
7
|
+
* @param {number} waiting - waiting as milliseconds
|
|
8
|
+
* @param {any} response - response value
|
|
9
|
+
* @return {any}
|
|
10
|
+
* @async
|
|
11
|
+
* */
|
|
12
|
+
function delay(waiting, response) {
|
|
13
|
+
if (typeof waiting !== "number" || waiting < 10) {
|
|
14
|
+
waiting = Math.round(Math.random() * 1000);
|
|
15
|
+
}
|
|
16
|
+
else if (!Number.isSafeInteger(waiting)) {
|
|
17
|
+
waiting = Math.round(waiting);
|
|
18
|
+
}
|
|
19
|
+
return new Promise(() => setTimeout(() => response, waiting));
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=delay.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"delay.js","sourceRoot":"","sources":["../../src/util/delay.ts"],"names":[],"mappings":";;AAQA,sBAQC;AAhBD;;;;;;;KAOK;AACL,SAAgB,KAAK,CAAgB,OAAgB,EAAE,QAAY;IAC/D,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,GAAG,EAAE,EAAE,CAAC;QAC9C,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAK,CAAC,CAAC;IAChD,CAAC;SACI,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC;QACtC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAClC,CAAC;IACD,OAAO,IAAI,OAAO,CAAI,GAAG,EAAE,CAAC,UAAU,CAAC,GAAM,EAAE,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,CAAC;AACxE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.emptyFn = emptyFn;
|
|
4
|
+
/**
|
|
5
|
+
* Empty function, it can be more useful sometimes
|
|
6
|
+
*
|
|
7
|
+
* @param {Arr} args - insignificant parameters
|
|
8
|
+
* @return {any}
|
|
9
|
+
* */
|
|
10
|
+
function emptyFn(...args) { }
|
|
11
|
+
//# sourceMappingURL=empty.fn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"empty.fn.js","sourceRoot":"","sources":["../../src/util/empty.fn.ts"],"names":[],"mappings":";;AAQA,0BAA6D;AAN7D;;;;;KAKK;AACL,SAAgB,OAAO,CAAc,GAAG,IAAS,IAAW,CAAC"}
|
|
@@ -14,6 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./
|
|
18
|
-
__exportStar(require("./
|
|
17
|
+
__exportStar(require("./delay"), exports);
|
|
18
|
+
__exportStar(require("./empty.fn"), exports);
|
|
19
|
+
__exportStar(require("./one-or-more"), exports);
|
|
20
|
+
__exportStar(require("./secure-json"), exports);
|
|
21
|
+
__exportStar(require("./secure-clone"), exports);
|
|
19
22
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/util/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,6CAA2B;AAC3B,gDAA8B;AAC9B,gDAA8B;AAC9B,iDAA+B"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { OneOrMore } from "../shared";
|
|
2
|
+
/**
|
|
3
|
+
* Return array value from one or more type
|
|
4
|
+
*
|
|
5
|
+
* @param {OneOrMore} value - it can be one value or array value
|
|
6
|
+
* @return {Array}
|
|
7
|
+
* */
|
|
8
|
+
export declare function oneOrMore<T = unknown>(value: OneOrMore<T>): Array<T> | undefined;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.oneOrMore = oneOrMore;
|
|
4
|
+
/**
|
|
5
|
+
* Return array value from one or more type
|
|
6
|
+
*
|
|
7
|
+
* @param {OneOrMore} value - it can be one value or array value
|
|
8
|
+
* @return {Array}
|
|
9
|
+
* */
|
|
10
|
+
function oneOrMore(value) {
|
|
11
|
+
if (Array.isArray(value)) {
|
|
12
|
+
return value;
|
|
13
|
+
}
|
|
14
|
+
if (value === undefined || value === null) {
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
return [value];
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=one-or-more.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"one-or-more.js","sourceRoot":"","sources":["../../src/util/one-or-more.ts"],"names":[],"mappings":";;AAQA,8BAQC;AAdD;;;;;KAKK;AACL,SAAgB,SAAS,CAAc,KAAmB;IACtD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,KAAiB,CAAC;IAC7B,CAAC;IACD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACxC,OAAO,SAAS,CAAC;IACrB,CAAC;IACD,OAAO,CAAC,KAAK,CAAa,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports._secureClone = _secureClone;
|
|
4
|
+
exports.secureClone = secureClone;
|
|
5
|
+
function _secureClone(value, weakSet) {
|
|
6
|
+
if (value === undefined || value === null) {
|
|
7
|
+
return value;
|
|
8
|
+
}
|
|
9
|
+
if (typeof value !== 'object') {
|
|
10
|
+
return value;
|
|
11
|
+
}
|
|
12
|
+
if (weakSet.has(weakSet)) {
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
weakSet.add(value);
|
|
16
|
+
if (Array.isArray(value)) {
|
|
17
|
+
return value.map(item => secureClone(item));
|
|
18
|
+
}
|
|
19
|
+
if (value instanceof Set) {
|
|
20
|
+
return new Set(Array.from(value.values()).map(item => secureClone(item)));
|
|
21
|
+
}
|
|
22
|
+
if (value instanceof Map) {
|
|
23
|
+
const newMap = new Map();
|
|
24
|
+
for (const [k, v] of value.entries()) {
|
|
25
|
+
newMap.set(k, secureClone(v));
|
|
26
|
+
}
|
|
27
|
+
return newMap;
|
|
28
|
+
}
|
|
29
|
+
const newObj = {};
|
|
30
|
+
for (const [k, v] of Object.entries(value)) {
|
|
31
|
+
newObj[k] = secureClone(v);
|
|
32
|
+
}
|
|
33
|
+
return newObj;
|
|
34
|
+
}
|
|
35
|
+
function secureClone(value) {
|
|
36
|
+
return _secureClone(value, new WeakSet());
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=secure-clone.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secure-clone.js","sourceRoot":"","sources":["../../src/util/secure-clone.ts"],"names":[],"mappings":";;AAEA,oCA6BC;AAED,kCAEC;AAjCD,SAAgB,YAAY,CAAI,KAAQ,EAAE,OAAqB;IAC3D,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QACxC,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC5B,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;QACvB,OAAO,KAAK,CAAC;IACj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- removes `circular` relations
|
|
6
|
+
* - cuts after max depths, default: `10`
|
|
7
|
+
* - converts `Set` to `array`
|
|
8
|
+
* - converts `Map` to `object`
|
|
9
|
+
* - cuts `methods` of an object
|
|
10
|
+
* - cuts `symbol` properties of an object
|
|
11
|
+
* - cuts `non-string keys` of an object
|
|
12
|
+
* - cuts `undefined` properties of an object
|
|
13
|
+
*
|
|
14
|
+
* @param {any} value
|
|
15
|
+
* @return {any}
|
|
16
|
+
* */
|
|
17
|
+
export declare function secureObject<E>(value: E): E;
|
|
18
|
+
/**
|
|
19
|
+
* Converts an object to secure string
|
|
20
|
+
*
|
|
21
|
+
* - `secure` means:
|
|
22
|
+
* - removes `circular` relations
|
|
23
|
+
* - cuts after max depths, default: `10`
|
|
24
|
+
* - converts `Set` to `array`
|
|
25
|
+
* - converts `Map` to `object`
|
|
26
|
+
* - cuts `methods` of an object
|
|
27
|
+
* - cuts `symbol` properties of an object
|
|
28
|
+
* - cuts `non-string keys` of an object
|
|
29
|
+
* - cuts `undefined` properties of an object
|
|
30
|
+
*
|
|
31
|
+
* Note:
|
|
32
|
+
* `JSON.stringify` can fail if there is a `dependency
|
|
33
|
+
*
|
|
34
|
+
* @param {any} value
|
|
35
|
+
* @return {string}
|
|
36
|
+
* */
|
|
37
|
+
export declare function secureJson(value: unknown): string;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.secureObject = secureObject;
|
|
4
|
+
exports.secureJson = secureJson;
|
|
5
|
+
/**
|
|
6
|
+
* Inner secure json function, it will be used after creating weak set
|
|
7
|
+
*
|
|
8
|
+
* @param {any} value
|
|
9
|
+
* @param {number} depth
|
|
10
|
+
* @param {WeakSet} set
|
|
11
|
+
* */
|
|
12
|
+
function _secureObject(value, depth, set) {
|
|
13
|
+
var _a, _b, _c;
|
|
14
|
+
if ([null, undefined].includes(value)) {
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
switch (typeof value) {
|
|
18
|
+
case 'object':
|
|
19
|
+
if (set.has(value)) {
|
|
20
|
+
return `#circular <${(_a = value === null || value === void 0 ? void 0 : value.constructor) === null || _a === void 0 ? void 0 : _a.name}>`;
|
|
21
|
+
}
|
|
22
|
+
if (depth >= 10) {
|
|
23
|
+
return `#depth <${(_b = value === null || value === void 0 ? void 0 : value.constructor) === null || _b === void 0 ? void 0 : _b.name}>`;
|
|
24
|
+
}
|
|
25
|
+
set.add(value);
|
|
26
|
+
if (Array.isArray(value)) {
|
|
27
|
+
return value.map(item => _secureObject(item, depth + 1, set));
|
|
28
|
+
}
|
|
29
|
+
if (value instanceof Set) {
|
|
30
|
+
return Array.from(value).map(item => _secureObject(item, depth + 1, set));
|
|
31
|
+
}
|
|
32
|
+
const obj = {};
|
|
33
|
+
if (value instanceof Map) {
|
|
34
|
+
for (const [k, v] of value.entries()) {
|
|
35
|
+
if (typeof k === 'string') {
|
|
36
|
+
obj[k] = _secureObject(v, depth + 1, set);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
else if ((value === null || value === void 0 ? void 0 : value.constructor) === Object) {
|
|
41
|
+
for (const [k, v] of Object.entries(value)) {
|
|
42
|
+
if (typeof k === 'string') {
|
|
43
|
+
obj[k] = _secureObject(v, depth + 1, set);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
let exists;
|
|
49
|
+
for (const [k, v] of Object.entries(value)) {
|
|
50
|
+
if (typeof k === 'string' && !['function', 'symbol', 'undefined'].includes(typeof value)) {
|
|
51
|
+
exists = true;
|
|
52
|
+
obj[k] = _secureObject(v, depth + 1, set);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (!exists) {
|
|
56
|
+
try {
|
|
57
|
+
return JSON.parse(JSON.stringify(value));
|
|
58
|
+
}
|
|
59
|
+
catch (e) {
|
|
60
|
+
return `#parse <${(_c = value === null || value === void 0 ? void 0 : value.constructor) === null || _c === void 0 ? void 0 : _c.name}>`;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return obj;
|
|
65
|
+
case 'function':
|
|
66
|
+
return `#function <${value.name}> (length: ${value.length})`;
|
|
67
|
+
case 'symbol':
|
|
68
|
+
return `#symbol <${value.description}>`;
|
|
69
|
+
}
|
|
70
|
+
return value;
|
|
71
|
+
}
|
|
72
|
+
// noinspection JSUnusedGlobalSymbols
|
|
73
|
+
/**
|
|
74
|
+
* Converts an object to secure object
|
|
75
|
+
*
|
|
76
|
+
* - `secure` means:
|
|
77
|
+
* - removes `circular` relations
|
|
78
|
+
* - cuts after max depths, default: `10`
|
|
79
|
+
* - converts `Set` to `array`
|
|
80
|
+
* - converts `Map` to `object`
|
|
81
|
+
* - cuts `methods` of an object
|
|
82
|
+
* - cuts `symbol` properties of an object
|
|
83
|
+
* - cuts `non-string keys` of an object
|
|
84
|
+
* - cuts `undefined` properties of an object
|
|
85
|
+
*
|
|
86
|
+
* @param {any} value
|
|
87
|
+
* @return {any}
|
|
88
|
+
* */
|
|
89
|
+
function secureObject(value) {
|
|
90
|
+
try {
|
|
91
|
+
return _secureObject(value, 0, new WeakSet());
|
|
92
|
+
}
|
|
93
|
+
catch (e) {
|
|
94
|
+
return `#error <${e.name}> (message: ${e.message})`;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// noinspection JSUnusedGlobalSymbols
|
|
98
|
+
/**
|
|
99
|
+
* Converts an object to secure string
|
|
100
|
+
*
|
|
101
|
+
* - `secure` means:
|
|
102
|
+
* - removes `circular` relations
|
|
103
|
+
* - cuts after max depths, default: `10`
|
|
104
|
+
* - converts `Set` to `array`
|
|
105
|
+
* - converts `Map` to `object`
|
|
106
|
+
* - cuts `methods` of an object
|
|
107
|
+
* - cuts `symbol` properties of an object
|
|
108
|
+
* - cuts `non-string keys` of an object
|
|
109
|
+
* - cuts `undefined` properties of an object
|
|
110
|
+
*
|
|
111
|
+
* Note:
|
|
112
|
+
* `JSON.stringify` can fail if there is a `dependency
|
|
113
|
+
*
|
|
114
|
+
* @param {any} value
|
|
115
|
+
* @return {string}
|
|
116
|
+
* */
|
|
117
|
+
function secureJson(value) {
|
|
118
|
+
try {
|
|
119
|
+
const json = _secureObject(value, 0, new WeakSet());
|
|
120
|
+
return (typeof json === 'string') ? json : JSON.stringify(json);
|
|
121
|
+
}
|
|
122
|
+
catch (e) {
|
|
123
|
+
return `#error <${e.name}> (message: ${e.message})`;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
//# sourceMappingURL=secure-json.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secure-json.js","sourceRoot":"","sources":["../../src/util/secure-json.ts"],"names":[],"mappings":";;AAoFA,oCAMC;AAsBD,gCAOC;AArHD;;;;;;KAMK;AACL,SAAS,aAAa,CAAC,KAAc,EAAE,KAAa,EAAE,GAAiB;;IACnE,IAAI,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;QACpC,OAAO,KAAK,CAAC;IACjB,CAAC;IACD,QAAQ,OAAO,KAAK,EAAE,CAAC;QACnB,KAAK,QAAQ;YACT,IAAI,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;gBACjB,OAAO,cAAc,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,WAAW,0CAAE,IAAI,GAAG,CAAC;YACrD,CAAC;YACD,IAAI,KAAK,IAAI,EAAE,EAAE,CAAC;gBACd,OAAO,WAAW,MAAA,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,WAAW,0CAAE,IAAI,GAAG,CAAC;YAClD,CAAC;YACD,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACf,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;gBACvB,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,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G,aAAa,CAAC,KAAK,EAAE,CAAC,EAAE,IAAI,OAAO,EAAO,CAAC,CAAC;QACzD,OAAO,CAAC,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACpE,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACT,OAAO,WAAW,CAAC,CAAC,IAAI,eAAe,CAAC,CAAC,OAAO,GAAG,CAAC;IACxD,CAAC;AACL,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leyyo/common",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "Common library",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"common"
|
|
@@ -49,6 +49,6 @@
|
|
|
49
49
|
"typescript": "^5.7.3"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"
|
|
52
|
+
"stacktrace-parser": "^0.1.11"
|
|
53
53
|
}
|
|
54
54
|
}
|