@leyyo/common 1.0.1 → 1.0.2
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/assertion/common-assertion-impl.d.ts +3 -4
- package/dist/assertion/common-assertion-impl.js +9 -8
- package/dist/assertion/index-types.d.ts +6 -22
- package/dist/assertion/index.d.ts +0 -1
- package/dist/assertion/index.js +0 -1
- package/dist/error/common-error-impl.d.ts +6 -4
- package/dist/error/common-error-impl.js +8 -4
- package/dist/error/index-types.d.ts +5 -52
- package/dist/error/index.d.ts +0 -5
- package/dist/error/index.js +0 -5
- package/dist/{error → exception}/assertion-exception.d.ts +1 -1
- package/dist/{error → exception}/caused-exception.d.ts +1 -1
- package/dist/{error → exception}/developer-exception.d.ts +1 -1
- package/dist/{error → exception}/exception.d.ts +4 -3
- package/dist/{error → exception}/exception.js +4 -4
- package/dist/exception/index-types.d.ts +30 -0
- package/dist/exception/index.d.ts +6 -0
- package/dist/exception/index.js +22 -0
- package/dist/fqn/common-fqn-impl.d.ts +11 -0
- package/dist/fqn/common-fqn-impl.js +47 -0
- package/dist/fqn/index-types.d.ts +6 -0
- package/dist/fqn/index-types.js +2 -0
- package/dist/fqn/index.d.ts +2 -0
- package/dist/{callback → fqn}/index.js +1 -1
- package/dist/hook/common-hook-impl.d.ts +30 -0
- package/dist/hook/common-hook-impl.js +111 -0
- package/dist/hook/index-types.d.ts +56 -0
- package/dist/hook/index-types.js +2 -0
- package/dist/hook/index.d.ts +2 -0
- package/dist/hook/index.js +18 -0
- package/dist/index.d.ts +11 -5
- package/dist/index.js +19 -6
- package/dist/is/common-is-impl.js +6 -6
- package/dist/is/index-types.d.ts +2 -3
- package/dist/leyyo/index-types.d.ts +4 -2
- package/dist/leyyo/leyyo-impl.d.ts +4 -2
- package/dist/leyyo/leyyo-impl.js +37 -29
- package/dist/literal/country-code.d.ts +8 -0
- package/dist/literal/country-code.js +17 -0
- package/dist/literal/environment.d.ts +8 -0
- package/dist/literal/environment.js +7 -0
- package/dist/literal/http-method.d.ts +8 -0
- package/dist/literal/http-method.js +7 -0
- package/dist/literal/http-place.d.ts +8 -0
- package/dist/literal/http-place.js +7 -0
- package/dist/literal/index-types.d.ts +6 -0
- package/dist/literal/index-types.js +2 -0
- package/dist/literal/index.d.ts +14 -0
- package/dist/literal/index.js +30 -0
- package/dist/literal/key-value.d.ts +4 -0
- package/dist/literal/key-value.js +7 -0
- package/dist/literal/language-code.d.ts +8 -0
- package/dist/literal/language-code.js +12 -0
- package/dist/literal/locale-code.d.ts +10 -0
- package/dist/literal/locale-code.js +17 -0
- package/dist/literal/primitive.d.ts +8 -0
- package/dist/literal/primitive.js +7 -0
- package/dist/literal/real-value.d.ts +8 -0
- package/dist/literal/real-value.js +7 -0
- package/dist/literal/severity.d.ts +8 -0
- package/dist/literal/severity.js +7 -0
- package/dist/literal/storage-type.d.ts +8 -0
- package/dist/literal/storage-type.js +7 -0
- package/dist/literal/weak-false.d.ts +8 -0
- package/dist/literal/weak-false.js +7 -0
- package/dist/literal/weak-true.d.ts +8 -0
- package/dist/literal/weak-true.js +7 -0
- package/dist/log/common-log-impl.d.ts +3 -2
- package/dist/log/common-log-impl.js +6 -6
- package/dist/log/index-types.d.ts +2 -52
- package/dist/log/index-types.js +0 -1
- package/dist/log/index.d.ts +1 -1
- package/dist/log/index.js +1 -1
- package/dist/log/logger-impl.d.ts +3 -3
- package/dist/log/logger-impl.js +5 -5
- package/dist/{assertion → shared}/assert.js +1 -0
- package/dist/{aliases.d.ts → shared/index-aliases.d.ts} +1 -1
- package/dist/shared/index-types.d.ts +141 -0
- package/dist/shared/index-types.js +3 -0
- package/dist/shared/index.d.ts +5 -0
- package/dist/shared/index.js +21 -0
- package/dist/storage/common-storage-impl.d.ts +3 -3
- package/dist/storage/common-storage-impl.js +3 -3
- package/dist/storage/index-types.d.ts +3 -13
- package/dist/storage/index.d.ts +0 -1
- package/dist/storage/index.js +0 -1
- package/dist/to/common-to-impl.d.ts +3 -3
- package/dist/to/common-to-impl.js +11 -11
- package/dist/to/index-types.d.ts +1 -30
- package/package.json +1 -1
- package/dist/callback/common-callback-impl.d.ts +0 -31
- package/dist/callback/common-callback-impl.js +0 -134
- package/dist/callback/index-types.d.ts +0 -73
- package/dist/callback/index.d.ts +0 -2
- package/dist/literals.d.ts +0 -106
- package/dist/literals.js +0 -81
- package/dist/{error → exception}/assertion-exception.js +0 -0
- package/dist/{error → exception}/caused-exception.js +0 -0
- package/dist/{error → exception}/developer-exception.js +0 -0
- package/dist/{callback → exception}/index-types.js +0 -0
- package/dist/{error → exception}/multiple-exception.d.ts +1 -1
- package/dist/{error → exception}/multiple-exception.js +0 -0
- package/dist/{assertion → shared}/assert.d.ts +1 -1
- /package/dist/{aliases.js → shared/index-aliases.js} +0 -0
- /package/dist/{constants.d.ts → shared/index-constants.d.ts} +0 -0
- /package/dist/{constants.js → shared/index-constants.js} +0 -0
- /package/dist/{storage → shared}/list.d.ts +0 -0
- /package/dist/{storage → shared}/list.js +0 -0
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Leyyo } from "../leyyo";
|
|
2
|
-
import { CommonLog, CommonLogSecure
|
|
2
|
+
import { CommonLog, CommonLogSecure } from "./index-types";
|
|
3
|
+
import { Logger, LogLine } from "../shared";
|
|
3
4
|
export declare class CommonLogImpl implements CommonLog, CommonLogSecure {
|
|
4
|
-
private
|
|
5
|
+
private hook;
|
|
5
6
|
constructor();
|
|
6
7
|
get $secure(): CommonLogSecure;
|
|
7
8
|
$init(leyyo: Leyyo): void;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CommonLogImpl = void 0;
|
|
4
4
|
const logger_impl_1 = require("./logger-impl");
|
|
5
|
-
const
|
|
6
|
-
// noinspection JSUnusedLocalSymbols
|
|
5
|
+
const shared_1 = require("../shared");
|
|
6
|
+
// noinspection JSUnusedLocalSymbols,JSUnusedGlobalSymbols
|
|
7
7
|
class CommonLogImpl {
|
|
8
8
|
constructor() {
|
|
9
9
|
this.create.bind(this);
|
|
@@ -15,16 +15,16 @@ class CommonLogImpl {
|
|
|
15
15
|
throw this;
|
|
16
16
|
}
|
|
17
17
|
$init(leyyo) {
|
|
18
|
-
this.
|
|
18
|
+
this.hook = leyyo.hook;
|
|
19
19
|
const fields = ['create', 'apply', 'check', 'print'];
|
|
20
20
|
const rec = { proper: false };
|
|
21
21
|
fields.forEach(field => {
|
|
22
22
|
rec[field] = this[field];
|
|
23
23
|
});
|
|
24
24
|
// define itself temporarily for log operations
|
|
25
|
-
this.
|
|
25
|
+
this.hook.defineProvider(shared_1.LY_ATTACHED_LOG, CommonLogImpl, rec);
|
|
26
26
|
// when new log provider is defined, replace all common methods
|
|
27
|
-
this.
|
|
27
|
+
this.hook.whenProviderDefined(shared_1.LY_ATTACHED_LOG, CommonLogImpl, (ins) => {
|
|
28
28
|
fields.forEach(field => {
|
|
29
29
|
if (typeof ins[field] === 'function') {
|
|
30
30
|
this[field] = ins[field];
|
|
@@ -34,7 +34,7 @@ class CommonLogImpl {
|
|
|
34
34
|
}
|
|
35
35
|
create(clazz) {
|
|
36
36
|
const ins = new logger_impl_1.LoggerImpl(clazz);
|
|
37
|
-
this.
|
|
37
|
+
this.hook.queueForCallback(shared_1.LY_PENDING_LOG_REGISTER, ins, clazz);
|
|
38
38
|
return ins;
|
|
39
39
|
}
|
|
40
40
|
apply(line) {
|
|
@@ -1,55 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Dict, InitLike, ShiftMain, ShiftSecure } from "../aliases";
|
|
3
|
-
import { CommonCallbackDefined } from "../callback";
|
|
1
|
+
import { InitLike, LogConsumer, Logger, ShiftMain, ShiftSecure } from "../shared";
|
|
4
2
|
export interface CommonLog extends ShiftSecure<CommonLogSecure>, LogConsumer {
|
|
5
3
|
create(clazz: Object | Function | string): Logger;
|
|
6
4
|
}
|
|
7
|
-
export
|
|
8
|
-
create?(clazz: Object | Function | string): Logger;
|
|
9
|
-
apply?(line: LogLine): void;
|
|
10
|
-
check?<T>(line: LogLineEnhanced<T>): void;
|
|
11
|
-
print<T>(line: LogLineEnhanced<T>): void;
|
|
12
|
-
}
|
|
13
|
-
export interface CommonLogSecure extends ShiftMain<CommonLog>, InitLike {
|
|
14
|
-
}
|
|
15
|
-
export interface LogConsumer {
|
|
16
|
-
apply(line: LogLine): void;
|
|
17
|
-
}
|
|
18
|
-
export interface LogLine {
|
|
19
|
-
severity: Severity;
|
|
20
|
-
message: string | Error;
|
|
21
|
-
holder?: string;
|
|
22
|
-
params?: Dict;
|
|
23
|
-
}
|
|
24
|
-
export interface LogLineEnhanced<L = Dict> extends LogLine {
|
|
25
|
-
time?: Date;
|
|
26
|
-
locals?: L;
|
|
27
|
-
}
|
|
28
|
-
export interface Logger extends ShiftSecure<LoggerSecure> {
|
|
29
|
-
error(message: string, params?: any): void;
|
|
30
|
-
error(error: Error, params?: any): void;
|
|
31
|
-
error(whatever: any, params?: any): void;
|
|
32
|
-
warn(message: string, params?: any): void;
|
|
33
|
-
warn(error: Error, params?: any): void;
|
|
34
|
-
warn(whatever: any, params?: any): void;
|
|
35
|
-
info(message: string, params?: any): void;
|
|
36
|
-
info(error: Error, params?: any): void;
|
|
37
|
-
info(whatever: any, params?: any): void;
|
|
38
|
-
log(message: string, params?: any): void;
|
|
39
|
-
log(error: Error, params?: any): void;
|
|
40
|
-
log(whatever: any, params?: any): void;
|
|
41
|
-
trace(message: string, params?: any): void;
|
|
42
|
-
trace(error: Error, params?: any): void;
|
|
43
|
-
trace(whatever: any, params?: any): void;
|
|
44
|
-
debug(message: string, params?: any): void;
|
|
45
|
-
debug(error: Error, params?: any): void;
|
|
46
|
-
debug(whatever: any, params?: any): void;
|
|
47
|
-
}
|
|
48
|
-
export interface LoggerSecure extends ShiftMain<Logger> {
|
|
49
|
-
get $clazz(): Function;
|
|
50
|
-
get $name(): string;
|
|
51
|
-
$assert(error: Error, indicator: string, params?: unknown): void;
|
|
52
|
-
$setName(name: string): void;
|
|
53
|
-
$setMethod(method: Severity, lambda?: LoggerLambda): void;
|
|
54
|
-
}
|
|
55
|
-
export type LoggerLambda = (whatever: any, params?: any) => void;
|
|
5
|
+
export type CommonLogSecure = ShiftMain<CommonLog> & InitLike;
|
package/dist/log/index-types.js
CHANGED
package/dist/log/index.d.ts
CHANGED
package/dist/log/index.js
CHANGED
|
@@ -15,5 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./index-types"), exports);
|
|
18
|
-
__exportStar(require("./logger-impl"), exports);
|
|
19
18
|
__exportStar(require("./common-log-impl"), exports);
|
|
19
|
+
__exportStar(require("./logger-impl"), exports);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Logger, LoggerLambda, LoggerSecure } from "./index-types";
|
|
2
1
|
import { Leyyo } from "../leyyo";
|
|
3
|
-
import { Severity } from "../
|
|
2
|
+
import { Severity } from "../literal";
|
|
3
|
+
import { Logger, LoggerLambda, LoggerSecure } from "../shared";
|
|
4
4
|
export declare class LoggerImpl implements Logger, LoggerSecure {
|
|
5
5
|
private readonly _clazz;
|
|
6
6
|
private _name;
|
|
7
|
-
private static
|
|
7
|
+
private static _fqn;
|
|
8
8
|
private static _log;
|
|
9
9
|
constructor(value: Object | Function | string);
|
|
10
10
|
debug(message: any, params?: any): void;
|
package/dist/log/logger-impl.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LoggerImpl = void 0;
|
|
4
|
-
const
|
|
4
|
+
const exception_1 = require("../exception");
|
|
5
5
|
// noinspection JSUnusedLocalSymbols
|
|
6
6
|
class LoggerImpl {
|
|
7
7
|
constructor(value) {
|
|
8
8
|
switch (typeof value) {
|
|
9
9
|
case "function":
|
|
10
10
|
this._clazz = value;
|
|
11
|
-
this._name = LoggerImpl.
|
|
11
|
+
this._name = LoggerImpl._fqn.name(value);
|
|
12
12
|
break;
|
|
13
13
|
case "object":
|
|
14
14
|
this._clazz = value.constructor;
|
|
15
|
-
this._name = LoggerImpl.
|
|
15
|
+
this._name = LoggerImpl._fqn.name(value);
|
|
16
16
|
break;
|
|
17
17
|
case "string":
|
|
18
18
|
this._name = value;
|
|
19
19
|
break;
|
|
20
20
|
default:
|
|
21
|
-
throw new
|
|
21
|
+
throw new exception_1.DeveloperException('invalid.logger.name', { type: typeof value });
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
debug(message, params) {
|
|
@@ -53,7 +53,7 @@ class LoggerImpl {
|
|
|
53
53
|
return this._name;
|
|
54
54
|
}
|
|
55
55
|
static $setLeyyo(leyyo) {
|
|
56
|
-
this.
|
|
56
|
+
this._fqn = leyyo.fqn;
|
|
57
57
|
this._log = leyyo.log;
|
|
58
58
|
}
|
|
59
59
|
$setName(name) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LanguageCode, LocaleCode } from "
|
|
1
|
+
import { LanguageCode, LocaleCode } from "../literal";
|
|
2
2
|
export type BasicType = 'undefined' | 'string' | 'object' | 'number' | 'boolean' | 'function' | 'symbol' | 'bigint';
|
|
3
3
|
export type Dict<T = any> = Record<KeyValue, T>;
|
|
4
4
|
export type Arr<T = any> = Array<T>;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { Dict, KeyValue, OneOrMore, ShiftMain, ShiftSecure } from "./index-aliases";
|
|
2
|
+
import { Exception, ExceptionLike } from "../exception";
|
|
3
|
+
import { Severity, StorageType } from "../literal";
|
|
4
|
+
export interface AssertionOpt {
|
|
5
|
+
indicator?: AssertionReason | string;
|
|
6
|
+
param?: string;
|
|
7
|
+
where?: string;
|
|
8
|
+
value?: any;
|
|
9
|
+
expected?: OneOrMore<string>;
|
|
10
|
+
current?: string;
|
|
11
|
+
type?: string;
|
|
12
|
+
[k: string]: any;
|
|
13
|
+
}
|
|
14
|
+
type AssertionReason = 'invalid.type' | 'not.found' | 'duplicated' | 'empty';
|
|
15
|
+
export type AssertionCallback = () => string | AssertionOpt;
|
|
16
|
+
export interface AssertionBuiltResult {
|
|
17
|
+
message?: string;
|
|
18
|
+
params: AssertionOpt;
|
|
19
|
+
}
|
|
20
|
+
export interface HookAttachedCallback {
|
|
21
|
+
initialization?: true;
|
|
22
|
+
fn: Function;
|
|
23
|
+
}
|
|
24
|
+
export interface $HookDefinedProvider extends HookDefinedProvider {
|
|
25
|
+
producer: Function;
|
|
26
|
+
}
|
|
27
|
+
export interface HookDefinedProvider {
|
|
28
|
+
proper: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface HookWaitingProviderItem {
|
|
31
|
+
consumer: Function;
|
|
32
|
+
callback: HookDefinedProviderLambda;
|
|
33
|
+
}
|
|
34
|
+
export type HookDefinedProviderLambda<T extends HookDefinedProvider = HookDefinedProvider> = (instance: T) => void;
|
|
35
|
+
export interface FqnDefinedProvider extends HookDefinedProvider {
|
|
36
|
+
name(value: any): string;
|
|
37
|
+
register(value: any, type: FqnStereoType, pckName: string): void;
|
|
38
|
+
}
|
|
39
|
+
export type FqnStereoType = 'class' | 'function' | 'enum' | 'literal';
|
|
40
|
+
export interface ErrorDefinedProvider extends HookDefinedProvider {
|
|
41
|
+
register(exception: ExceptionLike): void;
|
|
42
|
+
build?(e: Error | string): ExceptionLike;
|
|
43
|
+
afterCreate?(e: ExceptionLike): void;
|
|
44
|
+
causedBy?(e: Error | string): ExceptionLike;
|
|
45
|
+
initSign?(err: Error): boolean;
|
|
46
|
+
addSign?(err: Error, ...keys: Array<string>): boolean;
|
|
47
|
+
getSign?(err: Error): Array<string>;
|
|
48
|
+
removeSign?(err: Error, ...keys: Array<string>): boolean;
|
|
49
|
+
hasSign?(err: Error, key: string): boolean;
|
|
50
|
+
toObject?(e: Error, ...omittedFields: Array<string>): Dict;
|
|
51
|
+
buildStack?(e: Error): void;
|
|
52
|
+
copyStack?(exception: Exception, error: Error): void;
|
|
53
|
+
initOmit?(clz: Function): boolean;
|
|
54
|
+
addOmit?(clz: Function, ...properties: Array<string>): boolean;
|
|
55
|
+
getOmit?(clz: Function): Array<string>;
|
|
56
|
+
inheritOmit?(clz: Function): Array<string>;
|
|
57
|
+
}
|
|
58
|
+
export interface LogDefinedProvider extends HookDefinedProvider {
|
|
59
|
+
create?(clazz: Object | Function | string): Logger;
|
|
60
|
+
apply?(line: LogLine): void;
|
|
61
|
+
check?<T>(line: LogLineEnhanced<T>): void;
|
|
62
|
+
print<T>(line: LogLineEnhanced<T>): void;
|
|
63
|
+
}
|
|
64
|
+
export interface LogConsumer {
|
|
65
|
+
apply(line: LogLine): void;
|
|
66
|
+
}
|
|
67
|
+
export interface LogLine {
|
|
68
|
+
severity: Severity;
|
|
69
|
+
message: string | Error;
|
|
70
|
+
holder?: string;
|
|
71
|
+
params?: Dict;
|
|
72
|
+
}
|
|
73
|
+
export interface LogLineEnhanced<L = Dict> extends LogLine {
|
|
74
|
+
time?: Date;
|
|
75
|
+
locals?: L;
|
|
76
|
+
}
|
|
77
|
+
export interface Logger extends ShiftSecure<LoggerSecure> {
|
|
78
|
+
error(message: string, params?: any): void;
|
|
79
|
+
error(error: Error, params?: any): void;
|
|
80
|
+
error(whatever: any, params?: any): void;
|
|
81
|
+
warn(message: string, params?: any): void;
|
|
82
|
+
warn(error: Error, params?: any): void;
|
|
83
|
+
warn(whatever: any, params?: any): void;
|
|
84
|
+
info(message: string, params?: any): void;
|
|
85
|
+
info(error: Error, params?: any): void;
|
|
86
|
+
info(whatever: any, params?: any): void;
|
|
87
|
+
log(message: string, params?: any): void;
|
|
88
|
+
log(error: Error, params?: any): void;
|
|
89
|
+
log(whatever: any, params?: any): void;
|
|
90
|
+
trace(message: string, params?: any): void;
|
|
91
|
+
trace(error: Error, params?: any): void;
|
|
92
|
+
trace(whatever: any, params?: any): void;
|
|
93
|
+
debug(message: string, params?: any): void;
|
|
94
|
+
debug(error: Error, params?: any): void;
|
|
95
|
+
debug(whatever: any, params?: any): void;
|
|
96
|
+
}
|
|
97
|
+
export interface LoggerSecure extends ShiftMain<Logger> {
|
|
98
|
+
get $clazz(): Function;
|
|
99
|
+
get $name(): string;
|
|
100
|
+
$assert(error: Error, indicator: string, params?: unknown): void;
|
|
101
|
+
$setName(name: string): void;
|
|
102
|
+
$setMethod(method: Severity, lambda?: LoggerLambda): void;
|
|
103
|
+
}
|
|
104
|
+
export type LoggerLambda = (whatever: any, params?: any) => void;
|
|
105
|
+
/**
|
|
106
|
+
* Storage size dictionary which in corresponding type
|
|
107
|
+
* */
|
|
108
|
+
export type StorageItem = Dict<number>;
|
|
109
|
+
/**
|
|
110
|
+
* Storage export dictionary which includes items
|
|
111
|
+
* */
|
|
112
|
+
export type StorageDetail = Record<StorageType, StorageItem>;
|
|
113
|
+
export interface ToTypeOpt extends AssertionOpt {
|
|
114
|
+
silent?: true;
|
|
115
|
+
children?: unknown;
|
|
116
|
+
}
|
|
117
|
+
export type ToTypeFnLambda<T = unknown, O extends ToTypeOpt = ToTypeOpt> = (value: unknown, opt?: O) => T;
|
|
118
|
+
export interface ToTypeChildOpt<T = unknown> extends ToTypeOpt {
|
|
119
|
+
fn?: ToTypeFnLambda<T>;
|
|
120
|
+
}
|
|
121
|
+
export interface ToTypeArrayChildOpt<V extends ToTypeChildOpt = ToTypeChildOpt> extends Dict<ToTypeChildOpt> {
|
|
122
|
+
value?: V;
|
|
123
|
+
}
|
|
124
|
+
export interface ToTypeArrayOpt<V extends ToTypeChildOpt = ToTypeChildOpt> extends ToTypeOpt {
|
|
125
|
+
children?: ToTypeArrayChildOpt<V>;
|
|
126
|
+
}
|
|
127
|
+
export interface ToTypeDictChildOpt<K extends ToTypeChildOpt = ToTypeChildOpt, V extends ToTypeChildOpt = ToTypeChildOpt> extends Record<string, ToTypeChildOpt> {
|
|
128
|
+
key?: K;
|
|
129
|
+
value?: V;
|
|
130
|
+
}
|
|
131
|
+
export interface ToTypeObjectOpt<K extends ToTypeChildOpt = ToTypeChildOpt, V extends ToTypeChildOpt = ToTypeChildOpt> extends ToTypeOpt {
|
|
132
|
+
children?: ToTypeDictChildOpt<K, V>;
|
|
133
|
+
}
|
|
134
|
+
export interface ToTypeEnumOpt<E extends KeyValue = KeyValue> extends ToTypeOpt {
|
|
135
|
+
map: EnumerationMap<E> | EnumerationArray<E>;
|
|
136
|
+
alt?: EnumerationAlt<E>;
|
|
137
|
+
}
|
|
138
|
+
export type EnumerationMap<E extends KeyValue = KeyValue> = Dict<E>;
|
|
139
|
+
export type EnumerationAlt<E extends KeyValue = KeyValue> = Dict<E>;
|
|
140
|
+
export type EnumerationArray<E extends KeyValue = KeyValue> = Array<E>;
|
|
141
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./index-aliases"), exports);
|
|
18
|
+
__exportStar(require("./index-constants"), exports);
|
|
19
|
+
__exportStar(require("./index-types"), exports);
|
|
20
|
+
__exportStar(require("./assert"), exports);
|
|
21
|
+
__exportStar(require("./list"), exports);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { List } from "
|
|
2
|
-
import { CommonStorage, CommonStorageSecure
|
|
1
|
+
import { List, StorageDetail, StorageItem } from "../shared";
|
|
2
|
+
import { CommonStorage, CommonStorageSecure } from "./index-types";
|
|
3
3
|
import { Leyyo } from "../leyyo";
|
|
4
|
-
import { StorageType } from "../
|
|
4
|
+
import { StorageType } from "../literal";
|
|
5
5
|
/** @inheritDoc */
|
|
6
6
|
export declare class CommonStorageImpl implements CommonStorage, CommonStorageSecure {
|
|
7
7
|
private readonly _lists;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CommonStorageImpl = void 0;
|
|
4
|
-
const
|
|
5
|
-
// noinspection JSUnusedLocalSymbols
|
|
4
|
+
const shared_1 = require("../shared");
|
|
5
|
+
// noinspection JSUnusedLocalSymbols,JSUnusedGlobalSymbols
|
|
6
6
|
/** @inheritDoc */
|
|
7
7
|
class CommonStorageImpl {
|
|
8
8
|
/**
|
|
@@ -80,7 +80,7 @@ class CommonStorageImpl {
|
|
|
80
80
|
// region list
|
|
81
81
|
/** @inheritDoc */
|
|
82
82
|
newList(name) {
|
|
83
|
-
const list = new
|
|
83
|
+
const list = new shared_1.List();
|
|
84
84
|
this._lists.set(name, list);
|
|
85
85
|
return list;
|
|
86
86
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { List } from "
|
|
2
|
-
import {
|
|
3
|
-
import { StorageType } from "../literals";
|
|
1
|
+
import { InitLike, List, ShiftMain, ShiftSecure, StorageDetail } from "../shared";
|
|
2
|
+
import { StorageType } from "../literal";
|
|
4
3
|
/**
|
|
5
4
|
* Storage factory
|
|
6
5
|
*
|
|
@@ -85,13 +84,4 @@ export interface CommonStorage extends ShiftSecure<CommonStorageSecure> {
|
|
|
85
84
|
* */
|
|
86
85
|
details(type?: StorageType, name?: string): StorageDetail;
|
|
87
86
|
}
|
|
88
|
-
export
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* Storage size dictionary which in corresponding type
|
|
92
|
-
* */
|
|
93
|
-
export type StorageItem = Dict<number>;
|
|
94
|
-
/**
|
|
95
|
-
* Storage export dictionary which includes items
|
|
96
|
-
* */
|
|
97
|
-
export type StorageDetail = Record<StorageType, StorageItem>;
|
|
87
|
+
export type CommonStorageSecure = ShiftMain<CommonStorage> & InitLike;
|
package/dist/storage/index.d.ts
CHANGED
package/dist/storage/index.js
CHANGED
|
@@ -15,5 +15,4 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./index-types"), exports);
|
|
18
|
-
__exportStar(require("./list"), exports);
|
|
19
18
|
__exportStar(require("./common-storage-impl"), exports);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { CommonTo, CommonToSecure
|
|
2
|
-
import { Dict, KeyValue, OneOrMore } from "../
|
|
1
|
+
import { CommonTo, CommonToSecure } from "./index-types";
|
|
2
|
+
import { Dict, KeyValue, OneOrMore, ToTypeArrayOpt, ToTypeEnumOpt, ToTypeObjectOpt, ToTypeOpt } from "../shared";
|
|
3
3
|
import { Leyyo } from "../leyyo";
|
|
4
4
|
export declare class CommonToImpl implements CommonTo, CommonToSecure {
|
|
5
5
|
private readonly _EXPECTED_ANY;
|
|
@@ -11,7 +11,7 @@ export declare class CommonToImpl implements CommonTo, CommonToSecure {
|
|
|
11
11
|
private readonly _EXPECTED_NUMBER;
|
|
12
12
|
private readonly _EXPECTED_STRING;
|
|
13
13
|
private is;
|
|
14
|
-
private
|
|
14
|
+
private fqn;
|
|
15
15
|
private assertion;
|
|
16
16
|
private _enumInMap;
|
|
17
17
|
private _enumInArray;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CommonToImpl = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const literal_1 = require("../literal");
|
|
5
|
+
const exception_1 = require("../exception");
|
|
6
6
|
// noinspection JSUnusedGlobalSymbols
|
|
7
7
|
class CommonToImpl {
|
|
8
8
|
constructor() {
|
|
@@ -137,7 +137,7 @@ class CommonToImpl {
|
|
|
137
137
|
return fn(value);
|
|
138
138
|
}
|
|
139
139
|
catch (e) {
|
|
140
|
-
|
|
140
|
+
exception_1.Exception.cast(e).raise(!(opt === null || opt === void 0 ? void 0 : opt.silent));
|
|
141
141
|
}
|
|
142
142
|
return null;
|
|
143
143
|
}
|
|
@@ -150,7 +150,7 @@ class CommonToImpl {
|
|
|
150
150
|
indicator = 'type.invalid-value';
|
|
151
151
|
}
|
|
152
152
|
opt = Object.assign(Object.assign(Object.assign({}, opt), params), { expected, value });
|
|
153
|
-
new
|
|
153
|
+
new exception_1.DeveloperException(indicator, opt)
|
|
154
154
|
.with(this)
|
|
155
155
|
.raise(!(opt === null || opt === void 0 ? void 0 : opt.silent));
|
|
156
156
|
return null;
|
|
@@ -201,7 +201,7 @@ class CommonToImpl {
|
|
|
201
201
|
result.push(valueFn(v, clonedOpt));
|
|
202
202
|
}
|
|
203
203
|
catch (e) {
|
|
204
|
-
|
|
204
|
+
exception_1.Exception.cast(e).raise(!opt.silent);
|
|
205
205
|
result.push(null);
|
|
206
206
|
}
|
|
207
207
|
});
|
|
@@ -226,10 +226,10 @@ class CommonToImpl {
|
|
|
226
226
|
if (value === '') {
|
|
227
227
|
return null;
|
|
228
228
|
}
|
|
229
|
-
if (
|
|
229
|
+
if (literal_1.WeakTrueItems.includes(value)) {
|
|
230
230
|
return true;
|
|
231
231
|
}
|
|
232
|
-
if (
|
|
232
|
+
if (literal_1.WeakFalseItems.includes(value)) {
|
|
233
233
|
return false;
|
|
234
234
|
}
|
|
235
235
|
return this.raiseInvalidValue(value, this._EXPECTED_BOOL, opt);
|
|
@@ -258,7 +258,7 @@ class CommonToImpl {
|
|
|
258
258
|
return value;
|
|
259
259
|
case 'object':
|
|
260
260
|
case 'function':
|
|
261
|
-
return this.
|
|
261
|
+
return this.fqn.name(value);
|
|
262
262
|
}
|
|
263
263
|
return this.raiseInvalidValue(value, this._EXPECTED_CLASS, opt);
|
|
264
264
|
}
|
|
@@ -314,7 +314,7 @@ class CommonToImpl {
|
|
|
314
314
|
mapType = 'array';
|
|
315
315
|
}
|
|
316
316
|
if (!mapType) {
|
|
317
|
-
throw new
|
|
317
|
+
throw new exception_1.DeveloperException('type.invalid-enum-items', { map: opt.map });
|
|
318
318
|
}
|
|
319
319
|
let v;
|
|
320
320
|
switch (typeof value) {
|
|
@@ -475,7 +475,7 @@ class CommonToImpl {
|
|
|
475
475
|
result[keyOpt.fn(k, keyOpt)] = valueOpt.fn(v, valueOpt);
|
|
476
476
|
}
|
|
477
477
|
catch (e) {
|
|
478
|
-
|
|
478
|
+
exception_1.Exception.cast(e).raise(!opt.silent);
|
|
479
479
|
result[k] = null;
|
|
480
480
|
}
|
|
481
481
|
}
|
|
@@ -540,7 +540,7 @@ class CommonToImpl {
|
|
|
540
540
|
// region secure
|
|
541
541
|
$init(leyyo) {
|
|
542
542
|
this.is = leyyo.is;
|
|
543
|
-
this.
|
|
543
|
+
this.fqn = leyyo.fqn;
|
|
544
544
|
this.assertion = leyyo.assertion;
|
|
545
545
|
}
|
|
546
546
|
get $back() {
|