@leyyo/common 1.0.1 → 1.0.3

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.
Files changed (112) hide show
  1. package/dist/assertion/common-assertion-impl.d.ts +3 -4
  2. package/dist/assertion/common-assertion-impl.js +9 -8
  3. package/dist/assertion/index-types.d.ts +6 -22
  4. package/dist/assertion/index.d.ts +0 -1
  5. package/dist/assertion/index.js +0 -1
  6. package/dist/error/common-error-impl.d.ts +6 -4
  7. package/dist/error/common-error-impl.js +8 -4
  8. package/dist/error/index-types.d.ts +5 -52
  9. package/dist/error/index.d.ts +0 -5
  10. package/dist/error/index.js +0 -5
  11. package/dist/{error → exception}/assertion-exception.d.ts +1 -1
  12. package/dist/{error → exception}/caused-exception.d.ts +1 -1
  13. package/dist/{error → exception}/developer-exception.d.ts +1 -1
  14. package/dist/{error → exception}/exception.d.ts +4 -3
  15. package/dist/{error → exception}/exception.js +4 -4
  16. package/dist/exception/index-types.d.ts +30 -0
  17. package/dist/exception/index.d.ts +6 -0
  18. package/dist/exception/index.js +22 -0
  19. package/dist/fqn/common-fqn-impl.d.ts +18 -0
  20. package/dist/fqn/common-fqn-impl.js +121 -0
  21. package/dist/fqn/index-types.d.ts +9 -0
  22. package/dist/fqn/index-types.js +2 -0
  23. package/dist/fqn/index.d.ts +2 -0
  24. package/dist/{callback → fqn}/index.js +1 -1
  25. package/dist/hook/common-hook-impl.d.ts +30 -0
  26. package/dist/hook/common-hook-impl.js +111 -0
  27. package/dist/hook/index-types.d.ts +56 -0
  28. package/dist/hook/index-types.js +2 -0
  29. package/dist/hook/index.d.ts +2 -0
  30. package/dist/hook/index.js +18 -0
  31. package/dist/index.d.ts +11 -5
  32. package/dist/index.js +19 -6
  33. package/dist/is/common-is-impl.js +6 -6
  34. package/dist/is/index-types.d.ts +2 -3
  35. package/dist/leyyo/index-types.d.ts +4 -2
  36. package/dist/leyyo/leyyo-impl.d.ts +4 -2
  37. package/dist/leyyo/leyyo-impl.js +53 -30
  38. package/dist/literal/country-code.d.ts +8 -0
  39. package/dist/literal/country-code.js +17 -0
  40. package/dist/literal/environment.d.ts +8 -0
  41. package/dist/literal/environment.js +7 -0
  42. package/dist/literal/http-method.d.ts +8 -0
  43. package/dist/literal/http-method.js +7 -0
  44. package/dist/literal/http-place.d.ts +8 -0
  45. package/dist/literal/http-place.js +7 -0
  46. package/dist/literal/index-types.d.ts +6 -0
  47. package/dist/literal/index-types.js +2 -0
  48. package/dist/literal/index.d.ts +16 -0
  49. package/dist/literal/index.js +32 -0
  50. package/dist/literal/key-value.d.ts +4 -0
  51. package/dist/literal/key-value.js +7 -0
  52. package/dist/literal/language-code.d.ts +8 -0
  53. package/dist/literal/language-code.js +12 -0
  54. package/dist/literal/locale-code.d.ts +10 -0
  55. package/dist/literal/locale-code.js +17 -0
  56. package/dist/literal/primitive.d.ts +8 -0
  57. package/dist/literal/primitive.js +7 -0
  58. package/dist/literal/real-value.d.ts +8 -0
  59. package/dist/literal/real-value.js +7 -0
  60. package/dist/literal/severity.d.ts +8 -0
  61. package/dist/literal/severity.js +7 -0
  62. package/dist/literal/storage-type.d.ts +8 -0
  63. package/dist/literal/storage-type.js +7 -0
  64. package/dist/literal/sys-class.d.ts +2 -0
  65. package/dist/literal/sys-class.js +19 -0
  66. package/dist/literal/sys-function.d.ts +2 -0
  67. package/dist/literal/sys-function.js +6 -0
  68. package/dist/literal/weak-false.d.ts +8 -0
  69. package/dist/literal/weak-false.js +7 -0
  70. package/dist/literal/weak-true.d.ts +8 -0
  71. package/dist/literal/weak-true.js +7 -0
  72. package/dist/log/common-log-impl.d.ts +3 -2
  73. package/dist/log/common-log-impl.js +6 -6
  74. package/dist/log/index-types.d.ts +2 -52
  75. package/dist/log/index-types.js +0 -1
  76. package/dist/log/index.d.ts +1 -1
  77. package/dist/log/index.js +1 -1
  78. package/dist/log/logger-impl.d.ts +3 -4
  79. package/dist/log/logger-impl.js +11 -8
  80. package/dist/{assertion → shared}/assert.js +1 -0
  81. package/dist/{aliases.d.ts → shared/index-aliases.d.ts} +1 -1
  82. package/dist/{constants.d.ts → shared/index-constants.d.ts} +1 -0
  83. package/dist/{constants.js → shared/index-constants.js} +2 -1
  84. package/dist/shared/index-types.d.ts +142 -0
  85. package/dist/shared/index-types.js +3 -0
  86. package/dist/shared/index.d.ts +5 -0
  87. package/dist/shared/index.js +21 -0
  88. package/dist/storage/common-storage-impl.d.ts +3 -3
  89. package/dist/storage/common-storage-impl.js +3 -3
  90. package/dist/storage/index-types.d.ts +3 -13
  91. package/dist/storage/index.d.ts +0 -1
  92. package/dist/storage/index.js +0 -1
  93. package/dist/to/common-to-impl.d.ts +3 -3
  94. package/dist/to/common-to-impl.js +11 -11
  95. package/dist/to/index-types.d.ts +1 -30
  96. package/package.json +1 -1
  97. package/dist/callback/common-callback-impl.d.ts +0 -31
  98. package/dist/callback/common-callback-impl.js +0 -134
  99. package/dist/callback/index-types.d.ts +0 -73
  100. package/dist/callback/index.d.ts +0 -2
  101. package/dist/literals.d.ts +0 -106
  102. package/dist/literals.js +0 -81
  103. package/dist/{error → exception}/assertion-exception.js +0 -0
  104. package/dist/{error → exception}/caused-exception.js +0 -0
  105. package/dist/{error → exception}/developer-exception.js +0 -0
  106. package/dist/{callback → exception}/index-types.js +0 -0
  107. package/dist/{error → exception}/multiple-exception.d.ts +1 -1
  108. package/dist/{error → exception}/multiple-exception.js +0 -0
  109. package/dist/{assertion → shared}/assert.d.ts +1 -1
  110. /package/dist/{aliases.js → shared/index-aliases.js} +0 -0
  111. /package/dist/{storage → shared}/list.d.ts +0 -0
  112. /package/dist/{storage → shared}/list.js +0 -0
@@ -1,11 +1,10 @@
1
- import { AssertionCallback, AssertionOpt, CommonAssertion, CommonAssertionSecure } from "./index-types";
1
+ import { CommonAssertion, CommonAssertionSecure } from "./index-types";
2
2
  import { Leyyo } from "../leyyo";
3
- import { ToTypeOpt } from "../to";
4
- import { Arr, Obj } from "../aliases";
3
+ import { Arr, AssertionCallback, AssertionOpt, Obj, ToTypeOpt } from "../shared";
5
4
  /** @inheritDoc */
6
5
  export declare class CommonAssertionImpl implements CommonAssertion, CommonAssertionSecure {
7
6
  private is;
8
- private callback;
7
+ private fqn;
9
8
  constructor();
10
9
  /**
11
10
  * Build error parameters as message and params
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CommonAssertionImpl = void 0;
4
- const error_1 = require("../error");
4
+ const exception_1 = require("../exception");
5
+ // noinspection JSUnusedGlobalSymbols
5
6
  /** @inheritDoc */
6
7
  class CommonAssertionImpl {
7
8
  // endregion properties
@@ -50,10 +51,10 @@ class CommonAssertionImpl {
50
51
  switch (typeof value) {
51
52
  case 'object':
52
53
  if (set.has(value)) {
53
- return `<circular>${this.callback.fqnName(value === null || value === void 0 ? void 0 : value.constructor)}`;
54
+ return `<circular>${this.fqn.name(value === null || value === void 0 ? void 0 : value.constructor)}`;
54
55
  }
55
56
  if (level >= 10) {
56
- return `<max-depth>${this.callback.fqnName(value === null || value === void 0 ? void 0 : value.constructor)}`;
57
+ return `<max-depth>${this.fqn.name(value === null || value === void 0 ? void 0 : value.constructor)}`;
57
58
  }
58
59
  set.add(value);
59
60
  if (Array.isArray(value)) {
@@ -75,7 +76,7 @@ class CommonAssertionImpl {
75
76
  }
76
77
  return obj;
77
78
  case 'function':
78
- return `<function>${this.callback.fqnName(value)}`;
79
+ return `<function>${this.fqn.name(value)}`;
79
80
  case 'symbol':
80
81
  return `<symbol>${value.toString()}`;
81
82
  }
@@ -89,17 +90,17 @@ class CommonAssertionImpl {
89
90
  const type = typeof value;
90
91
  switch (type) {
91
92
  case "object":
92
- params.type = `object(${this.callback.fqnName(value.constructor)})`;
93
+ params.type = `object(${this.fqn.name(value.constructor)})`;
93
94
  break;
94
95
  case "function":
95
- params.type = `function(${this.callback.fqnName(value)})`;
96
+ params.type = `function(${this.fqn.name(value)})`;
96
97
  break;
97
98
  default:
98
99
  params.type = type;
99
100
  break;
100
101
  }
101
102
  def = def !== null && def !== void 0 ? def : 'Assertion error';
102
- throw new error_1.AssertionException(message !== null && message !== void 0 ? message : def, params);
103
+ throw new exception_1.AssertionException(message !== null && message !== void 0 ? message : def, params);
103
104
  }
104
105
  /** @inheritDoc */
105
106
  // noinspection JSUnusedLocalSymbols
@@ -237,7 +238,7 @@ class CommonAssertionImpl {
237
238
  /** @inheritDoc */
238
239
  $init(leyyo) {
239
240
  this.is = leyyo.is;
240
- this.callback = leyyo.callback;
241
+ this.fqn = leyyo.fqn;
241
242
  }
242
243
  /** @inheritDoc */
243
244
  get $secure() {
@@ -1,7 +1,6 @@
1
- import { Arr, InitLike, OneOrMore, ShiftMain, ShiftSecure } from "../aliases";
2
- import { ToTypeOpt } from "../to";
1
+ import { Arr, AssertionCallback, AssertionOpt, InitLike, ShiftMain, ShiftSecure, ToTypeOpt } from "../shared";
3
2
  /**
4
- * Basic is assertions to easy use
3
+ * Basic assertions to easy use
5
4
  * */
6
5
  export interface CommonAssertion extends ShiftSecure<CommonAssertionSecure> {
7
6
  /**
@@ -465,22 +464,7 @@ export interface CommonAssertion extends ShiftSecure<CommonAssertionSecure> {
465
464
  * */
466
465
  boolean(value: any, opt?: AssertionOpt): void;
467
466
  }
468
- export interface CommonAssertionSecure extends ShiftMain<CommonAssertion>, InitLike {
469
- }
470
- export interface AssertionOpt {
471
- indicator?: AssertionReason | string;
472
- param?: string;
473
- where?: string;
474
- value?: any;
475
- expected?: OneOrMore<string>;
476
- current?: string;
477
- type?: string;
478
- [k: string]: any;
479
- }
480
- type AssertionReason = 'invalid.type' | 'not.found' | 'duplicated' | 'empty';
481
- export type AssertionCallback = () => string | AssertionOpt;
482
- export interface AssertionBuiltResult {
483
- message?: string;
484
- params: AssertionOpt;
485
- }
486
- export {};
467
+ /**
468
+ * Secure assertion methods
469
+ * */
470
+ export type CommonAssertionSecure = ShiftMain<CommonAssertion> & InitLike;
@@ -1,3 +1,2 @@
1
1
  export * from './index-types';
2
2
  export * from './common-assertion-impl';
3
- export * from './assert';
@@ -16,4 +16,3 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./index-types"), exports);
18
18
  __exportStar(require("./common-assertion-impl"), exports);
19
- __exportStar(require("./assert"), exports);
@@ -1,17 +1,19 @@
1
- import { CommonError, CommonErrorSecure, ExceptionLike } from "./index-types";
1
+ import { CommonError, CommonErrorSecure } from "./index-types";
2
2
  import { Leyyo } from "../leyyo";
3
- import { Dict } from "../aliases";
4
- import { Exception } from "./exception";
3
+ import { Dict } from "../shared";
4
+ import { ExceptionLike } from "../exception";
5
5
  export declare class CommonErrorImpl implements CommonError, CommonErrorSecure {
6
+ private hook;
6
7
  get $back(): CommonError;
7
8
  $init(leyyo: Leyyo): void;
8
9
  get $secure(): CommonErrorSecure;
9
10
  addOmit(clz: Function, ...properties: Array<string>): boolean;
10
11
  addSign(err: Error, ...keys: Array<string>): boolean;
11
12
  afterCreate(e: ExceptionLike): void;
13
+ register(cls: Function): void;
12
14
  build(e: Error | string): ExceptionLike;
13
15
  buildStack(e: Error): void;
14
- copyStack(exception: Exception, error: Error): void;
16
+ copyStack(exception: ExceptionLike, error: Error): void;
15
17
  causedBy(e: Error | string): ExceptionLike;
16
18
  getOmit(clz: Function): Array<string>;
17
19
  getSign(err: Error): Array<string>;
@@ -1,14 +1,15 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CommonErrorImpl = void 0;
4
- const exception_1 = require("./exception");
5
- const constants_1 = require("../constants");
4
+ const shared_1 = require("../shared");
5
+ const exception_1 = require("../exception");
6
6
  // noinspection JSUnusedLocalSymbols
7
7
  class CommonErrorImpl {
8
8
  get $back() {
9
9
  return this;
10
10
  }
11
11
  $init(leyyo) {
12
+ this.hook = leyyo.hook;
12
13
  const fields = ['build', 'afterCreate', 'causedBy', 'toObject', 'buildStack', 'copyStack',
13
14
  'initSign', 'addSign', 'getSign', 'removeSign', 'hasSign',
14
15
  'initOmit', 'addOmit', 'getOmit', 'inheritOmit'];
@@ -17,9 +18,9 @@ class CommonErrorImpl {
17
18
  rec[field] = this[field];
18
19
  });
19
20
  // define itself temporarily for error operations
20
- leyyo.callback.defineProvider(constants_1.LY_ATTACHED_ERROR, CommonErrorImpl, rec);
21
+ this.hook.defineProvider(shared_1.LY_ATTACHED_ERROR, CommonErrorImpl, rec);
21
22
  // when new error provider is defined, replace all common methods
22
- leyyo.callback.whenProviderDefined(constants_1.LY_ATTACHED_ERROR, CommonErrorImpl, (ins) => {
23
+ this.hook.whenProviderDefined(shared_1.LY_ATTACHED_ERROR, CommonErrorImpl, (ins) => {
23
24
  fields.forEach(field => {
24
25
  if (typeof ins[field] === 'function') {
25
26
  this[field] = ins[field];
@@ -39,6 +40,9 @@ class CommonErrorImpl {
39
40
  afterCreate(e) {
40
41
  e.$secure.$setName(e.constructor.name);
41
42
  }
43
+ register(cls) {
44
+ this.hook.queueForCallback(shared_1.LY_PENDING_ERROR_REGISTER, cls);
45
+ }
42
46
  build(e) {
43
47
  if (e instanceof exception_1.Exception) {
44
48
  return e;
@@ -1,7 +1,7 @@
1
- import { Abstract, ClassLike, Dict, InitLike, ShiftMain, ShiftSecure } from "../aliases";
2
- import { Exception } from "./exception";
3
- import { CommonCallbackDefined } from "../callback";
1
+ import { Dict, InitLike, ShiftMain, ShiftSecure } from "../shared";
2
+ import { ExceptionLike } from "../exception";
4
3
  export interface CommonError extends ShiftSecure<CommonErrorSecure> {
4
+ register(cls: Function): void;
5
5
  build(e: Error | string): ExceptionLike;
6
6
  afterCreate(e: ExceptionLike): void;
7
7
  causedBy(e: Error | string): ExceptionLike;
@@ -12,57 +12,10 @@ export interface CommonError extends ShiftSecure<CommonErrorSecure> {
12
12
  hasSign(err: Error, key: string): boolean;
13
13
  toObject(e: Error, ...omittedFields: Array<string>): Dict;
14
14
  buildStack(e: Error): void;
15
- copyStack(exception: Exception, error: Error): void;
15
+ copyStack(exception: ExceptionLike, error: Error): void;
16
16
  initOmit(clz: Function): boolean;
17
17
  addOmit(clz: Function, ...properties: Array<string>): boolean;
18
18
  getOmit(clz: Function): Array<string>;
19
19
  inheritOmit(clz: Function): Array<string>;
20
20
  }
21
- export interface CommonErrorCb extends CommonCallbackDefined {
22
- build?(e: Error | string): ExceptionLike;
23
- afterCreate?(e: ExceptionLike): void;
24
- causedBy?(e: Error | string): ExceptionLike;
25
- initSign?(err: Error): boolean;
26
- addSign?(err: Error, ...keys: Array<string>): boolean;
27
- getSign?(err: Error): Array<string>;
28
- removeSign?(err: Error, ...keys: Array<string>): boolean;
29
- hasSign?(err: Error, key: string): boolean;
30
- toObject?(e: Error, ...omittedFields: Array<string>): Dict;
31
- buildStack?(e: Error): void;
32
- copyStack?(exception: Exception, error: Error): void;
33
- initOmit?(clz: Function): boolean;
34
- addOmit?(clz: Function, ...properties: Array<string>): boolean;
35
- getOmit?(clz: Function): Array<string>;
36
- inheritOmit?(clz: Function): Array<string>;
37
- }
38
- export interface CommonErrorSecure extends ShiftMain<CommonError>, InitLike {
39
- }
40
- export interface ExceptionStackLine {
41
- file?: string;
42
- method?: string;
43
- line?: number;
44
- column?: number;
45
- }
46
- export interface ExceptionParamsAppend extends Dict {
47
- indicator?: string;
48
- }
49
- export interface ExceptionLike extends Error, ShiftSecure<ExceptionSecure> {
50
- get params(): Dict;
51
- causedBy(e: Error | string): this;
52
- with(clazz: ClassLike): this;
53
- with(instance: Abstract<any>): this;
54
- with(name: string): this;
55
- with(value: any): this;
56
- appendParams(params: ExceptionParamsAppend, ignoreExisting?: boolean): this;
57
- log(req?: unknown): this;
58
- raise(throwable?: boolean, req?: unknown): this;
59
- toObject(...omittedFields: Array<string>): Dict;
60
- toJSON(): Dict;
61
- }
62
- export interface ExceptionSecure extends ShiftMain<ExceptionLike> {
63
- $setName(name: string): this;
64
- $hasSign(key: string): boolean;
65
- $listSigns(): Array<string>;
66
- $addSign(...keys: Array<string>): boolean;
67
- $removeSign(...keys: Array<string>): boolean;
68
- }
21
+ export type CommonErrorSecure = ShiftMain<CommonError> & InitLike;
@@ -1,7 +1,2 @@
1
1
  export * from './index-types';
2
2
  export * from './common-error-impl';
3
- export * from './exception';
4
- export * from './caused-exception';
5
- export * from './developer-exception';
6
- export * from './assertion-exception';
7
- export * from './multiple-exception';
@@ -16,8 +16,3 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./index-types"), exports);
18
18
  __exportStar(require("./common-error-impl"), exports);
19
- __exportStar(require("./exception"), exports);
20
- __exportStar(require("./caused-exception"), exports);
21
- __exportStar(require("./developer-exception"), exports);
22
- __exportStar(require("./assertion-exception"), exports);
23
- __exportStar(require("./multiple-exception"), exports);
@@ -1,5 +1,5 @@
1
1
  import { Exception } from "./exception";
2
- import { AssertionOpt } from "../assertion";
2
+ import { AssertionOpt } from "../shared";
3
3
  export declare class AssertionException extends Exception {
4
4
  constructor(indicator?: string, params?: AssertionOpt);
5
5
  }
@@ -1,5 +1,5 @@
1
1
  import { Exception } from "./exception";
2
- import { Dict } from "../aliases";
2
+ import { Dict } from "../shared";
3
3
  export declare class CausedException extends Exception {
4
4
  constructor(e: Error, indicator?: string, params?: Dict);
5
5
  }
@@ -1,5 +1,5 @@
1
1
  import { Exception } from "./exception";
2
- import { AssertionOpt } from "../assertion";
2
+ import { AssertionOpt } from "../shared";
3
3
  export declare class DeveloperException extends Exception {
4
4
  constructor(indicator?: string, params?: AssertionOpt);
5
5
  }
@@ -1,8 +1,9 @@
1
- import { CommonError, ExceptionLike, ExceptionParamsAppend, ExceptionSecure, ExceptionStackLine } from "./index-types";
2
- import { Abstract, ClassLike, ClassOrName, Dict } from "../aliases";
1
+ import { CommonError } from "../error";
2
+ import { Abstract, ClassLike, ClassOrName, Dict } from "../shared";
3
3
  import { Leyyo } from "../leyyo";
4
+ import { ExceptionLike, ExceptionParamsAppend, ExceptionSecure, ExceptionStackLine } from "./index-types";
4
5
  export declare class Exception extends Error implements ExceptionLike, ExceptionSecure {
5
- private static _callback;
6
+ private static _fqn;
6
7
  private static _error;
7
8
  private static _log;
8
9
  private static _assertion;
@@ -7,7 +7,7 @@ class Exception extends Error {
7
7
  message += ` => ${JSON.stringify(Exception._assertion.secureJson(params))}`;
8
8
  }
9
9
  super(message);
10
- this.name = Exception._callback.fqnName(this);
10
+ this.name = Exception._fqn.name(this);
11
11
  this._params = params !== null && params !== void 0 ? params : {};
12
12
  this._parsed = [];
13
13
  Exception._error.afterCreate(this);
@@ -27,7 +27,7 @@ class Exception extends Error {
27
27
  return this;
28
28
  }
29
29
  with(value) {
30
- this._holder = Exception._callback.fqnName(value);
30
+ this._holder = Exception._fqn.name(value);
31
31
  return this;
32
32
  }
33
33
  appendParams(params, ignoreExisting) {
@@ -98,8 +98,8 @@ class Exception extends Error {
98
98
  return Exception._error.removeSign(this, ...keys);
99
99
  }
100
100
  static $setLeyyo(leyyo) {
101
- if (!this._callback) {
102
- this._callback = leyyo.callback;
101
+ if (!this._fqn) {
102
+ this._fqn = leyyo.fqn;
103
103
  }
104
104
  if (!this._error) {
105
105
  this._error = leyyo.error;
@@ -0,0 +1,30 @@
1
+ import { Abstract, ClassLike, Dict, ShiftMain, ShiftSecure } from "../shared";
2
+ export interface ExceptionStackLine {
3
+ file?: string;
4
+ method?: string;
5
+ line?: number;
6
+ column?: number;
7
+ }
8
+ export interface ExceptionParamsAppend extends Dict {
9
+ indicator?: string;
10
+ }
11
+ export interface ExceptionLike extends Error, ShiftSecure<ExceptionSecure> {
12
+ get params(): Dict;
13
+ causedBy(e: Error | string): this;
14
+ with(clazz: ClassLike): this;
15
+ with(instance: Abstract<any>): this;
16
+ with(name: string): this;
17
+ with(value: any): this;
18
+ appendParams(params: ExceptionParamsAppend, ignoreExisting?: boolean): this;
19
+ log(req?: unknown): this;
20
+ raise(throwable?: boolean, req?: unknown): this;
21
+ toObject(...omittedFields: Array<string>): Dict;
22
+ toJSON(): Dict;
23
+ }
24
+ export interface ExceptionSecure extends ShiftMain<ExceptionLike> {
25
+ $setName(name: string): this;
26
+ $hasSign(key: string): boolean;
27
+ $listSigns(): Array<string>;
28
+ $addSign(...keys: Array<string>): boolean;
29
+ $removeSign(...keys: Array<string>): boolean;
30
+ }
@@ -0,0 +1,6 @@
1
+ export * from './index-types';
2
+ export * from './exception';
3
+ export * from './caused-exception';
4
+ export * from './developer-exception';
5
+ export * from './assertion-exception';
6
+ export * from './multiple-exception';
@@ -0,0 +1,22 @@
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-types"), exports);
18
+ __exportStar(require("./exception"), exports);
19
+ __exportStar(require("./caused-exception"), exports);
20
+ __exportStar(require("./developer-exception"), exports);
21
+ __exportStar(require("./assertion-exception"), exports);
22
+ __exportStar(require("./multiple-exception"), exports);
@@ -0,0 +1,18 @@
1
+ import { CommonFqn, CommonFqnSecure } from "./index-types";
2
+ import { Leyyo } from "../leyyo";
3
+ import { CommonFqnHook, FqnStereoType } from "../shared";
4
+ export declare class CommonFqnImpl implements CommonFqn, CommonFqnSecure {
5
+ private hook;
6
+ private proper;
7
+ constructor();
8
+ get $back(): CommonFqn;
9
+ $init(leyyo: Leyyo): void;
10
+ get $secure(): CommonFqnSecure;
11
+ name(value: any): string;
12
+ exists(target: any): boolean;
13
+ register(name: string, value: any, type: FqnStereoType, pckName: string): void;
14
+ get isProper(): boolean;
15
+ addHook(target: Function | Object, callback: CommonFqnHook): boolean;
16
+ isSysFunction(method: string): boolean;
17
+ isSysClass(clazz: string | Function): boolean;
18
+ }
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CommonFqnImpl = void 0;
4
+ const shared_1 = require("../shared");
5
+ const literal_1 = require("../literal");
6
+ // noinspection JSUnusedLocalSymbols,JSUnusedGlobalSymbols
7
+ class CommonFqnImpl {
8
+ constructor() {
9
+ this.name.bind(this);
10
+ this.exists.bind(this);
11
+ this.register.bind(this);
12
+ }
13
+ get $back() {
14
+ return this;
15
+ }
16
+ $init(leyyo) {
17
+ this.hook = leyyo.hook;
18
+ const rec = {
19
+ proper: false,
20
+ exists: this.exists,
21
+ name: this.name,
22
+ register: this.register,
23
+ };
24
+ // define itself temporarily for fqn operations
25
+ leyyo.hook.defineProvider(shared_1.LY_ATTACHED_FQN, CommonFqnImpl, rec);
26
+ // when new fqn provider is defined, replace all common methods
27
+ leyyo.hook.whenProviderDefined(shared_1.LY_ATTACHED_FQN, CommonFqnImpl, (ins) => {
28
+ if (ins.proper) {
29
+ this.proper = true;
30
+ }
31
+ this.exists = ins.exists;
32
+ this.name = ins.name;
33
+ this.register = ins.register;
34
+ });
35
+ }
36
+ get $secure() {
37
+ return this;
38
+ }
39
+ name(value) {
40
+ switch (typeof value) {
41
+ case "function":
42
+ return value.name;
43
+ case "object":
44
+ return value.constructor.name;
45
+ case "string":
46
+ return value;
47
+ default:
48
+ return null;
49
+ }
50
+ }
51
+ exists(target) {
52
+ return false;
53
+ }
54
+ register(name, value, type, pckName) {
55
+ this.hook.queueForCallback(shared_1.LY_PENDING_FQN_REGISTER, name, value, type, pckName);
56
+ }
57
+ get isProper() {
58
+ return this.proper;
59
+ }
60
+ addHook(target, callback) {
61
+ var _a;
62
+ if (typeof target === 'object') {
63
+ try {
64
+ target = target.constructor;
65
+ }
66
+ catch (e) {
67
+ }
68
+ }
69
+ if (typeof target !== 'function' || typeof callback !== 'function') {
70
+ return false;
71
+ }
72
+ if (this.proper) {
73
+ callback(this.name(target));
74
+ return true;
75
+ }
76
+ let callbacks;
77
+ try {
78
+ callbacks = (_a = Object.getOwnPropertyDescriptor(target, shared_1.LY_SIGN_FQN_HOOK)) !== null && _a !== void 0 ? _a : [];
79
+ }
80
+ catch (e) {
81
+ console.log(`CommonFqnImpl.hook.get`, e.message);
82
+ }
83
+ if (!Array.isArray(callbacks)) {
84
+ callbacks = [];
85
+ }
86
+ callbacks.push(callback);
87
+ try {
88
+ Object.defineProperty(target, shared_1.LY_SIGN_FQN_HOOK, {
89
+ value: callbacks,
90
+ configurable: false,
91
+ writable: false,
92
+ enumerable: false
93
+ });
94
+ }
95
+ catch (e) {
96
+ console.log(`CommonFqnImpl.hook.set`, e.message);
97
+ return false;
98
+ }
99
+ return true;
100
+ }
101
+ isSysFunction(method) {
102
+ if (typeof method !== 'string') {
103
+ return false;
104
+ }
105
+ return literal_1.SysFunctionItems.includes(method);
106
+ }
107
+ isSysClass(clazz) {
108
+ let name;
109
+ if (typeof clazz === 'function') {
110
+ name = clazz.name;
111
+ }
112
+ else if (typeof clazz === 'string') {
113
+ name = clazz;
114
+ }
115
+ if (!name) {
116
+ return false;
117
+ }
118
+ return literal_1.SysClassItems.includes(name);
119
+ }
120
+ }
121
+ exports.CommonFqnImpl = CommonFqnImpl;
@@ -0,0 +1,9 @@
1
+ import { CommonFqnHook, FqnStereoType, InitLike, ShiftMain, ShiftSecure } from "../shared";
2
+ export interface CommonFqn extends ShiftSecure<CommonFqnSecure> {
3
+ name(target: any): string;
4
+ exists(target: any): boolean;
5
+ register(name: string, target: any, type: FqnStereoType, pckName: string): void;
6
+ addHook(target: Function | Object, callback: CommonFqnHook): boolean;
7
+ get isProper(): boolean;
8
+ }
9
+ export type CommonFqnSecure = ShiftMain<CommonFqn> & InitLike;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export * from './index-types';
2
+ export * from './common-fqn-impl';
@@ -15,4 +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("./common-callback-impl"), exports);
18
+ __exportStar(require("./common-fqn-impl"), exports);
@@ -0,0 +1,30 @@
1
+ import { Arr, HookDefinedProvider, HookDefinedProviderLambda } from "../shared";
2
+ import { Leyyo } from "../leyyo";
3
+ import { CommonHook, CommonHookSecure } from "./index-types";
4
+ export declare class CommonHookImpl implements CommonHook, CommonHookSecure {
5
+ private _waitingForCallbacks;
6
+ private _attachedCallbacks;
7
+ private _waitingForProviders;
8
+ private _definedProviders;
9
+ /**
10
+ * Default constructor
11
+ *
12
+ * Responsibilities
13
+ * - Create repositories => ie: callbacks
14
+ * - Trigger clear pending operation
15
+ * */
16
+ constructor();
17
+ $init(leyyo: Leyyo): void;
18
+ /**
19
+ * Clear jobs in the queue which channel as pending
20
+ *
21
+ * Because the expected callback may not be defined
22
+ * */
23
+ private _clearPending;
24
+ get $secure(): CommonHookSecure;
25
+ attachCallback(channel: string, fn: Function): void;
26
+ queueForCallback(channel: string, ...args: Arr): boolean;
27
+ get $back(): CommonHook;
28
+ whenProviderDefined<T extends HookDefinedProvider = HookDefinedProvider>(channel: string, consumer: Function, callback: HookDefinedProviderLambda<T>): void;
29
+ defineProvider<T extends HookDefinedProvider = HookDefinedProvider>(channel: string, producer: Function, instance: T): void;
30
+ }