@leyyo/common 1.0.4 → 1.0.6

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 (239) hide show
  1. package/dist/assertion/common-assertion.d.ts +54 -0
  2. package/dist/assertion/common-assertion.js +180 -0
  3. package/dist/assertion/common-assertion.js.map +1 -0
  4. package/dist/assertion/index-types.d.ts +154 -159
  5. package/dist/assertion/index-types.js +1 -0
  6. package/dist/assertion/index-types.js.map +1 -0
  7. package/dist/assertion/index.d.ts +0 -1
  8. package/dist/assertion/index.js +1 -1
  9. package/dist/assertion/index.js.map +1 -0
  10. package/dist/descriptor/common-descriptor.d.ts +19 -0
  11. package/dist/descriptor/common-descriptor.js +92 -0
  12. package/dist/descriptor/common-descriptor.js.map +1 -0
  13. package/dist/descriptor/index-types.d.ts +21 -0
  14. package/dist/{literal → descriptor}/index-types.js +1 -0
  15. package/dist/descriptor/index-types.js.map +1 -0
  16. package/dist/descriptor/index.d.ts +1 -0
  17. package/dist/{storage → descriptor}/index.js +1 -1
  18. package/dist/descriptor/index.js.map +1 -0
  19. package/dist/developer/common-developer.d.ts +29 -0
  20. package/dist/developer/common-developer.js +266 -0
  21. package/dist/developer/common-developer.js.map +1 -0
  22. package/dist/developer/index-types.d.ts +77 -0
  23. package/dist/{storage → developer}/index-types.js +1 -0
  24. package/dist/developer/index-types.js.map +1 -0
  25. package/dist/developer/index.d.ts +1 -0
  26. package/dist/developer/index.js +18 -0
  27. package/dist/developer/index.js.map +1 -0
  28. package/dist/error/{common-error-impl.d.ts → common-error.d.ts} +5 -5
  29. package/dist/error/common-error.js +104 -0
  30. package/dist/error/common-error.js.map +1 -0
  31. package/dist/error/index-types.d.ts +21 -2
  32. package/dist/error/index-types.js +1 -0
  33. package/dist/error/index-types.js.map +1 -0
  34. package/dist/error/index.d.ts +0 -1
  35. package/dist/error/index.js +1 -1
  36. package/dist/error/index.js.map +1 -0
  37. package/dist/exception/assertion-exception.d.ts +2 -2
  38. package/dist/exception/assertion-exception.js +3 -2
  39. package/dist/exception/assertion-exception.js.map +1 -0
  40. package/dist/exception/caused-exception.d.ts +2 -2
  41. package/dist/exception/caused-exception.js +3 -2
  42. package/dist/exception/caused-exception.js.map +1 -0
  43. package/dist/exception/developer-exception.d.ts +2 -2
  44. package/dist/exception/developer-exception.js +3 -2
  45. package/dist/exception/developer-exception.js.map +1 -0
  46. package/dist/exception/exception.d.ts +7 -5
  47. package/dist/exception/exception.js +14 -4
  48. package/dist/exception/exception.js.map +1 -0
  49. package/dist/exception/index-types.d.ts +1 -1
  50. package/dist/exception/index-types.js +1 -0
  51. package/dist/exception/index-types.js.map +1 -0
  52. package/dist/exception/index.d.ts +1 -0
  53. package/dist/exception/index.js +2 -0
  54. package/dist/exception/index.js.map +1 -0
  55. package/dist/exception/invalid-value-exception.d.ts +5 -0
  56. package/dist/exception/invalid-value-exception.js +12 -0
  57. package/dist/exception/invalid-value-exception.js.map +1 -0
  58. package/dist/exception/multiple-exception.js +1 -0
  59. package/dist/exception/multiple-exception.js.map +1 -0
  60. package/dist/fqn/common-fqn.d.ts +20 -0
  61. package/dist/fqn/common-fqn.js +116 -0
  62. package/dist/fqn/common-fqn.js.map +1 -0
  63. package/dist/fqn/index-types.d.ts +14 -5
  64. package/dist/fqn/index-types.js +1 -0
  65. package/dist/fqn/index-types.js.map +1 -0
  66. package/dist/fqn/index.d.ts +0 -1
  67. package/dist/fqn/index.js +1 -1
  68. package/dist/fqn/index.js.map +1 -0
  69. package/dist/hook/{common-hook-impl.d.ts → common-hook.d.ts} +12 -10
  70. package/dist/hook/{common-hook-impl.js → common-hook.js} +27 -21
  71. package/dist/hook/common-hook.js.map +1 -0
  72. package/dist/hook/index-types.d.ts +29 -14
  73. package/dist/hook/index-types.js +1 -0
  74. package/dist/hook/index-types.js.map +1 -0
  75. package/dist/hook/index.d.ts +0 -1
  76. package/dist/hook/index.js +1 -1
  77. package/dist/hook/index.js.map +1 -0
  78. package/dist/index.d.ts +27 -11
  79. package/dist/index.js +30 -20
  80. package/dist/index.js.map +1 -0
  81. package/dist/internal.d.ts +2 -0
  82. package/dist/internal.js +4 -1
  83. package/dist/internal.js.map +1 -0
  84. package/dist/is/{common-is-impl.d.ts → common-is.d.ts} +19 -5
  85. package/dist/is/common-is.js +136 -0
  86. package/dist/is/common-is.js.map +1 -0
  87. package/dist/is/index-types.d.ts +48 -3
  88. package/dist/is/index-types.js +1 -0
  89. package/dist/is/index-types.js.map +1 -0
  90. package/dist/is/index.d.ts +0 -1
  91. package/dist/is/index.js +1 -1
  92. package/dist/is/index.js.map +1 -0
  93. package/dist/leyyo/index-types.d.ts +30 -17
  94. package/dist/leyyo/index-types.js +1 -0
  95. package/dist/leyyo/index-types.js.map +1 -0
  96. package/dist/leyyo/index.d.ts +1 -1
  97. package/dist/leyyo/index.js +2 -1
  98. package/dist/leyyo/index.js.map +1 -0
  99. package/dist/leyyo/leyyo-common-hook.d.ts +10 -0
  100. package/dist/leyyo/leyyo-common-hook.js +18 -0
  101. package/dist/leyyo/leyyo-common-hook.js.map +1 -0
  102. package/dist/leyyo/leyyo.d.ts +35 -0
  103. package/dist/leyyo/leyyo.js +77 -0
  104. package/dist/leyyo/leyyo.js.map +1 -0
  105. package/dist/log/common-log.d.ts +14 -0
  106. package/dist/log/common-log.js +92 -0
  107. package/dist/log/common-log.js.map +1 -0
  108. package/dist/log/index-types.d.ts +57 -3
  109. package/dist/log/index-types.js +1 -0
  110. package/dist/log/index-types.js.map +1 -0
  111. package/dist/log/index.d.ts +2 -2
  112. package/dist/log/index.js +3 -2
  113. package/dist/log/index.js.map +1 -0
  114. package/dist/log/logger-instance.d.ts +31 -0
  115. package/dist/log/logger-instance.js +114 -0
  116. package/dist/log/logger-instance.js.map +1 -0
  117. package/dist/{literal → log}/severity.js +1 -0
  118. package/dist/log/severity.js.map +1 -0
  119. package/dist/repo/common-repo.d.ts +44 -0
  120. package/dist/repo/common-repo.js +180 -0
  121. package/dist/repo/common-repo.js.map +1 -0
  122. package/dist/repo/index-types.d.ts +104 -0
  123. package/dist/{shared/index-aliases.js → repo/index-types.js} +1 -2
  124. package/dist/repo/index-types.js.map +1 -0
  125. package/dist/repo/index.d.ts +2 -0
  126. package/dist/repo/index.js +19 -0
  127. package/dist/repo/index.js.map +1 -0
  128. package/dist/repo/repo-type.d.ts +8 -0
  129. package/dist/repo/repo-type.js +8 -0
  130. package/dist/repo/repo-type.js.map +1 -0
  131. package/dist/server.d.ts +1 -0
  132. package/dist/server.js +5 -0
  133. package/dist/server.js.map +1 -0
  134. package/dist/shared/index-types.d.ts +162 -132
  135. package/dist/shared/index-types.js +2 -1
  136. package/dist/shared/index-types.js.map +1 -0
  137. package/dist/shared/index.d.ts +0 -4
  138. package/dist/shared/index.js +1 -4
  139. package/dist/shared/index.js.map +1 -0
  140. package/dist/system/common-system.d.ts +10 -0
  141. package/dist/system/common-system.js +65 -0
  142. package/dist/system/common-system.js.map +1 -0
  143. package/dist/{literal → system}/country-code.js +1 -0
  144. package/dist/system/country-code.js.map +1 -0
  145. package/dist/{literal → system}/environment.js +1 -0
  146. package/dist/system/environment.js.map +1 -0
  147. package/dist/{literal → system}/http-method.js +1 -0
  148. package/dist/system/http-method.js.map +1 -0
  149. package/dist/{literal → system}/http-place.js +1 -0
  150. package/dist/system/http-place.js.map +1 -0
  151. package/dist/system/index-types.d.ts +6 -0
  152. package/dist/system/index-types.js +3 -0
  153. package/dist/system/index-types.js.map +1 -0
  154. package/dist/{literal → system}/index.d.ts +1 -8
  155. package/dist/{literal → system}/index.js +2 -8
  156. package/dist/system/index.js.map +1 -0
  157. package/dist/{literal → system}/language-code.js +1 -0
  158. package/dist/system/language-code.js.map +1 -0
  159. package/dist/{literal → system}/locale-code.js +1 -0
  160. package/dist/system/locale-code.js.map +1 -0
  161. package/dist/{literal → system}/sys-class.js +1 -0
  162. package/dist/system/sys-class.js.map +1 -0
  163. package/dist/{literal → system}/sys-function.js +1 -0
  164. package/dist/system/sys-function.js.map +1 -0
  165. package/dist/to/common-to.d.ts +45 -0
  166. package/dist/to/common-to.js +868 -0
  167. package/dist/to/common-to.js.map +1 -0
  168. package/dist/to/index-types.d.ts +38 -18
  169. package/dist/to/index-types.js +1 -0
  170. package/dist/to/index-types.js.map +1 -0
  171. package/dist/to/index.d.ts +6 -1
  172. package/dist/to/index.js +7 -1
  173. package/dist/to/index.js.map +1 -0
  174. package/dist/{literal → to}/key-value.js +1 -0
  175. package/dist/to/key-value.js.map +1 -0
  176. package/dist/{shared → to}/list.d.ts +1 -0
  177. package/dist/{shared → to}/list.js +4 -0
  178. package/dist/to/list.js.map +1 -0
  179. package/dist/{literal → to}/primitive.js +1 -0
  180. package/dist/to/primitive.js.map +1 -0
  181. package/dist/{literal → to}/real-value.js +1 -0
  182. package/dist/to/real-value.js.map +1 -0
  183. package/dist/{literal → to}/weak-false.js +1 -0
  184. package/dist/to/weak-false.js.map +1 -0
  185. package/dist/{literal → to}/weak-true.js +1 -0
  186. package/dist/to/weak-true.js.map +1 -0
  187. package/dist/wrapper/common-wrapper.d.ts +26 -0
  188. package/dist/wrapper/common-wrapper.js +81 -0
  189. package/dist/wrapper/common-wrapper.js.map +1 -0
  190. package/dist/wrapper/index-types.d.ts +29 -0
  191. package/dist/wrapper/index-types.js +3 -0
  192. package/dist/wrapper/index-types.js.map +1 -0
  193. package/dist/wrapper/index.d.ts +2 -0
  194. package/dist/wrapper/index.js +19 -0
  195. package/dist/wrapper/index.js.map +1 -0
  196. package/dist/wrapper/wrap.d.ts +7 -0
  197. package/dist/wrapper/wrap.js +11 -0
  198. package/dist/wrapper/wrap.js.map +1 -0
  199. package/package.json +13 -15
  200. package/dist/assertion/common-assertion-impl.d.ts +0 -65
  201. package/dist/assertion/common-assertion-impl.js +0 -248
  202. package/dist/error/common-error-impl.js +0 -92
  203. package/dist/fqn/common-fqn-impl.d.ts +0 -18
  204. package/dist/fqn/common-fqn-impl.js +0 -121
  205. package/dist/is/common-is-impl.js +0 -91
  206. package/dist/leyyo/leyyo-impl.d.ts +0 -26
  207. package/dist/leyyo/leyyo-impl.js +0 -94
  208. package/dist/literal/index-types.d.ts +0 -6
  209. package/dist/literal/storage-type.d.ts +0 -8
  210. package/dist/literal/storage-type.js +0 -7
  211. package/dist/log/common-log-impl.d.ts +0 -14
  212. package/dist/log/common-log-impl.js +0 -59
  213. package/dist/log/logger-impl.d.ts +0 -23
  214. package/dist/log/logger-impl.js +0 -77
  215. package/dist/shared/assert.d.ts +0 -6
  216. package/dist/shared/assert.js +0 -14
  217. package/dist/shared/index-aliases.d.ts +0 -167
  218. package/dist/shared/index-constants.d.ts +0 -8
  219. package/dist/shared/index-constants.js +0 -11
  220. package/dist/storage/common-storage-impl.d.ts +0 -47
  221. package/dist/storage/common-storage-impl.js +0 -150
  222. package/dist/storage/index-types.d.ts +0 -87
  223. package/dist/storage/index.d.ts +0 -2
  224. package/dist/to/common-to-impl.d.ts +0 -38
  225. package/dist/to/common-to-impl.js +0 -553
  226. /package/dist/{literal → log}/severity.d.ts +0 -0
  227. /package/dist/{literal → system}/country-code.d.ts +0 -0
  228. /package/dist/{literal → system}/environment.d.ts +0 -0
  229. /package/dist/{literal → system}/http-method.d.ts +0 -0
  230. /package/dist/{literal → system}/http-place.d.ts +0 -0
  231. /package/dist/{literal → system}/language-code.d.ts +0 -0
  232. /package/dist/{literal → system}/locale-code.d.ts +0 -0
  233. /package/dist/{literal → system}/sys-class.d.ts +0 -0
  234. /package/dist/{literal → system}/sys-function.d.ts +0 -0
  235. /package/dist/{literal → to}/key-value.d.ts +0 -0
  236. /package/dist/{literal → to}/primitive.d.ts +0 -0
  237. /package/dist/{literal → to}/real-value.d.ts +0 -0
  238. /package/dist/{literal → to}/weak-false.d.ts +0 -0
  239. /package/dist/{literal → to}/weak-true.d.ts +0 -0
@@ -1,8 +0,0 @@
1
- /**
2
- * Weak True items
3
- * */
4
- export declare const StorageTypeItems: readonly ["array", "list", "map", "set"];
5
- /**
6
- * Storage type literal, as an enum
7
- * */
8
- export type StorageType = typeof StorageTypeItems[number];
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.StorageTypeItems = void 0;
4
- /**
5
- * Weak True items
6
- * */
7
- exports.StorageTypeItems = ['array', 'list', 'map', 'set'];
@@ -1,14 +0,0 @@
1
- import { Leyyo } from "../leyyo";
2
- import { CommonLog, CommonLogSecure } from "./index-types";
3
- import { Logger, LogLine } from "../shared";
4
- export declare class CommonLogImpl implements CommonLog, CommonLogSecure {
5
- private hook;
6
- constructor();
7
- get $secure(): CommonLogSecure;
8
- $init(leyyo: Leyyo): void;
9
- create(clazz: Object | Function | string): Logger;
10
- apply(line: LogLine): void;
11
- private check;
12
- private print;
13
- get $back(): CommonLog;
14
- }
@@ -1,59 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CommonLogImpl = void 0;
4
- const logger_impl_1 = require("./logger-impl");
5
- const shared_1 = require("../shared");
6
- // noinspection JSUnusedLocalSymbols,JSUnusedGlobalSymbols
7
- class CommonLogImpl {
8
- constructor() {
9
- this.create.bind(this);
10
- this.apply.bind(this);
11
- this.check.bind(this);
12
- this.print.bind(this);
13
- }
14
- get $secure() {
15
- throw this;
16
- }
17
- $init(leyyo) {
18
- this.hook = leyyo.hook;
19
- const fields = ['create', 'apply', 'check', 'print'];
20
- const rec = { proper: false };
21
- fields.forEach(field => {
22
- rec[field] = this[field];
23
- });
24
- // define itself temporarily for log operations
25
- this.hook.defineProvider(shared_1.LY_ATTACHED_LOG, CommonLogImpl, rec);
26
- // when new log provider is defined, replace all common methods
27
- this.hook.whenProviderDefined(shared_1.LY_ATTACHED_LOG, CommonLogImpl, (ins) => {
28
- fields.forEach(field => {
29
- if (typeof ins[field] === 'function') {
30
- this[field] = ins[field];
31
- }
32
- });
33
- });
34
- }
35
- create(clazz) {
36
- const ins = new logger_impl_1.LoggerImpl(clazz);
37
- this.hook.queueForCallback(shared_1.LY_PENDING_LOG_REGISTER, ins, clazz);
38
- return ins;
39
- }
40
- apply(line) {
41
- if ((global === null || global === void 0 ? void 0 : global.leyyo_is_testing) || !line) {
42
- return;
43
- }
44
- const lineEnhanced = line;
45
- lineEnhanced.time = new Date();
46
- this.check(lineEnhanced);
47
- this.print(lineEnhanced);
48
- }
49
- check(line) {
50
- // nothing
51
- }
52
- print(line) {
53
- console[line.severity](`[${line.time}] ${line.severity} ${line.holder} ${line.message}`, line.params);
54
- }
55
- get $back() {
56
- return this;
57
- }
58
- }
59
- exports.CommonLogImpl = CommonLogImpl;
@@ -1,23 +0,0 @@
1
- import { Leyyo } from "../leyyo";
2
- import { Severity } from "../literal";
3
- import { Logger, LoggerLambda, LoggerSecure } from "../shared";
4
- export declare class LoggerImpl implements Logger, LoggerSecure {
5
- private readonly _clazz;
6
- private _name;
7
- private static _fqn;
8
- private static _log;
9
- constructor(value: Object | Function | string);
10
- debug(message: any, params?: any): void;
11
- error(message: any, params?: any): void;
12
- info(message: any, params?: any): void;
13
- log(message: any, params?: any): void;
14
- trace(message: any, params?: any): void;
15
- warn(message: any, params?: any): void;
16
- get $back(): Logger;
17
- get $secure(): LoggerSecure;
18
- get $clazz(): Function;
19
- get $name(): string;
20
- static $setLeyyo(leyyo: Leyyo): void;
21
- $setMethod(method: Severity, lambda?: LoggerLambda): void;
22
- $assert(error: Error, indicator: string, params?: unknown): void;
23
- }
@@ -1,77 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LoggerImpl = void 0;
4
- const exception_1 = require("../exception");
5
- // noinspection JSUnusedLocalSymbols
6
- class LoggerImpl {
7
- constructor(value) {
8
- switch (typeof value) {
9
- case "function":
10
- this._clazz = value;
11
- this._name = LoggerImpl._fqn.name(value);
12
- break;
13
- case "object":
14
- this._clazz = value.constructor;
15
- this._name = LoggerImpl._fqn.name(value);
16
- break;
17
- case "string":
18
- this._name = value;
19
- break;
20
- default:
21
- throw new exception_1.DeveloperException('invalid.logger.name', { type: typeof value });
22
- }
23
- // when this object is signed by FQN, then refresh logger name
24
- if (!LoggerImpl._fqn.exists(value)) {
25
- LoggerImpl._fqn.addHook(value, (name) => {
26
- this._name = name;
27
- });
28
- }
29
- }
30
- debug(message, params) {
31
- LoggerImpl._log.apply({ severity: 'debug', message: message, holder: this._name, params: params });
32
- }
33
- error(message, params) {
34
- LoggerImpl._log.apply({ severity: 'error', message: message, holder: this._name, params: params });
35
- }
36
- info(message, params) {
37
- LoggerImpl._log.apply({ severity: 'info', message: message, holder: this._name, params: params });
38
- }
39
- log(message, params) {
40
- LoggerImpl._log.apply({ severity: 'log', message: message, holder: this._name, params: params });
41
- }
42
- trace(message, params) {
43
- LoggerImpl._log.apply({ severity: 'trace', message: message, holder: this._name, params: params });
44
- }
45
- warn(message, params) {
46
- LoggerImpl._log.apply({ severity: 'warn', message: message, holder: this._name, params: params });
47
- }
48
- // region secure
49
- get $back() {
50
- return this;
51
- }
52
- get $secure() {
53
- return this;
54
- }
55
- get $clazz() {
56
- return this._clazz;
57
- }
58
- get $name() {
59
- return this._name;
60
- }
61
- static $setLeyyo(leyyo) {
62
- this._fqn = leyyo.fqn;
63
- this._log = leyyo.log;
64
- }
65
- $setMethod(method, lambda) {
66
- if (typeof lambda === 'function') {
67
- this[method] = lambda;
68
- }
69
- else {
70
- this[method] = () => {
71
- };
72
- }
73
- }
74
- $assert(error, indicator, params) {
75
- }
76
- }
77
- exports.LoggerImpl = LoggerImpl;
@@ -1,6 +0,0 @@
1
- import { Leyyo } from "../leyyo";
2
- import { AssertionOpt } from "./index-types";
3
- export declare function assert(flag: boolean, message?: string): void;
4
- export declare function assert(flag: boolean, opt?: AssertionOpt): void;
5
- export declare function assert(flag: boolean, fn?: Function): void;
6
- export declare function $$setLeyyo(leyyo: Leyyo): void;
@@ -1,14 +0,0 @@
1
- "use strict";
2
- // noinspection JSUnusedGlobalSymbols
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.assert = assert;
5
- exports.$$setLeyyo = $$setLeyyo;
6
- let assertion;
7
- function assert(flag, v2) {
8
- if (!flag) {
9
- assertion.raise(v2);
10
- }
11
- }
12
- function $$setLeyyo(leyyo) {
13
- assertion = leyyo.assertion;
14
- }
@@ -1,167 +0,0 @@
1
- import { LanguageCode, LocaleCode } from "../literal";
2
- export type BasicType = 'undefined' | 'string' | 'object' | 'number' | 'boolean' | 'function' | 'symbol' | 'bigint';
3
- export type Dict<T = any> = Record<KeyValue, T>;
4
- export type Arr<T = any> = Array<T>;
5
- export type KeyValue = string | number;
6
- export type Id = string | number;
7
- export type Unknown = unknown;
8
- export type Integer = number;
9
- export type Float = number;
10
- export type Boolean = boolean;
11
- export type Enum = string;
12
- export type Alpha = string;
13
- export type String = string;
14
- export type Digit = string;
15
- export type Title = string;
16
- export type Description = string;
17
- export type RichText = string;
18
- export type Uuid = string;
19
- export type Host = string;
20
- export type Url = string;
21
- export type Email = string;
22
- export type Folder = string;
23
- export type Timestamp = number;
24
- export type IsoDatetime = string;
25
- export type IsoDate = string;
26
- export type IsoTime = string;
27
- interface _Func {
28
- readonly name?: string;
29
- readonly length?: number;
30
- bind(thisArg: any, ...args: Array<any>): any;
31
- apply(thisArg: any, args: Array<any>): any;
32
- call(thisArg: any, ...args: Array<any>): any;
33
- }
34
- export interface Fnc<R = any> extends _Func {
35
- (...args: Array<any>): R;
36
- }
37
- export interface AsyncFnc<R = any> extends _Func {
38
- (...args: Array<any>): Promise<R>;
39
- }
40
- export type Func<R = any> = Function | Fnc<R>;
41
- export type Async<R = any> = Function | AsyncFnc<R>;
42
- export interface ClassLike<T = {}> extends _Func {
43
- new (...args: Array<any>): T;
44
- }
45
- /**
46
- * Serialized version of another type
47
- */
48
- export type Serialized<T> = {
49
- [P in keyof T]: T[P];
50
- };
51
- export type ClassOrName = ClassLike | string;
52
- export type FuncOrName = Function | string;
53
- /**
54
- * Referenced from Object
55
- * */
56
- export type Obj = Object & {};
57
- export interface Abstract<T> extends Function {
58
- prototype: T;
59
- }
60
- export interface Entity<I extends Id = Uuid> {
61
- id?: I;
62
- }
63
- export interface Pair<I extends Id = Uuid> extends Entity<I> {
64
- name?: string;
65
- }
66
- export type TypeOfMethod<T, M extends keyof T> = T[M] extends Function ? T[M] : never;
67
- export type KeyOf<T> = keyof T;
68
- export type Keys<T> = Array<keyof T>;
69
- export type ValueOf<T> = T[KeyOf<T>];
70
- export type Values<T> = Array<T[KeyOf<T>]>;
71
- export type MaximumOneOf<T, K extends keyof T = keyof T> = K extends keyof T ? {
72
- [P in K]: T[K];
73
- } & Partial<Record<Exclude<keyof T, K>, never>> : never;
74
- export type OneOf<Obj> = ValueOf<OneOfByKey<Obj>>;
75
- export type Xor<A, B> = XorIn<A & {
76
- [K in keyof B]?: undefined;
77
- }> | XorIn<B & {
78
- [K in keyof A]?: undefined;
79
- }>;
80
- export type Mutable<A> = {
81
- -readonly [K in keyof A]: A[K];
82
- };
83
- export type OneOrMore<T> = T | Array<T>;
84
- export type SameType<A, T> = {
85
- [K in keyof A]: T;
86
- };
87
- type OneOnly<T, K extends keyof T> = Omit<T, Exclude<keyof T, K>> | Pick<T, K>;
88
- type OneOfByKey<T> = {
89
- [key in keyof T]: OneOnly<T, key>;
90
- };
91
- type XorIn<T> = {
92
- [K in keyof T]: T[K];
93
- } & unknown;
94
- /**
95
- * An interface which contains secure mode members and provides to shift to main mode
96
- * */
97
- export interface ShiftSecure<S extends ShiftMain<any>> {
98
- /**
99
- * Shifts to secure mode
100
- * */
101
- get $secure(): S;
102
- }
103
- /**
104
- * An interface which contains main mode members and provides to shift to secure mode
105
- *
106
- * IT's so useful to hide some public members
107
- * - to see clean auto-completed members in IDE
108
- * - to indicated that secure mode members should be used in special cases
109
- * */
110
- export interface ShiftMain<M extends ShiftSecure<any>> {
111
- /**
112
- * Shifts to main mode
113
- * */
114
- get $back(): M;
115
- }
116
- /**
117
- * An interface which provides to flat generic interfaces/classes to prevent verbose casting commands
118
- * */
119
- export interface ShiftFlat<D> {
120
- /**
121
- * Flats current classes, or eliminate generic parameters
122
- * */
123
- get $flat(): D;
124
- }
125
- /**
126
- * Useful interface which provides initialization state for instances
127
- * */
128
- export interface InitLike {
129
- /**
130
- * Initializes the instance
131
- * */
132
- $init(...args: Arr): void;
133
- }
134
- /**
135
- * JSON Object
136
- */
137
- export type JsonObject = {
138
- [K in string]?: JsonValue;
139
- };
140
- /**
141
- * JSON Array
142
- */
143
- export type JsonArray = Array<JsonValue>;
144
- /**
145
- * JSON Primitives
146
- */
147
- export type JsonPrimitive = string | number | boolean | null;
148
- /**
149
- * JSON Values
150
- */
151
- export type JsonValue = JsonPrimitive | JsonObject | JsonArray;
152
- /**
153
- * Primitive language key
154
- *
155
- * It can be language (xx), local (xx-xx) or string (not preferred)
156
- * */
157
- export type I18nKey = LanguageCode | LocaleCode | string;
158
- /**
159
- * Language map
160
- *
161
- * @example
162
- * const name = {en: "Apple", tr: "Elma"};
163
- *
164
- * */
165
- export type I18nRaw<V = unknown> = Dict<V>;
166
- export type I18nAny<V = unknown> = I18nRaw<V> | V;
167
- export {};
@@ -1,8 +0,0 @@
1
- export declare const LY_ATTACHED_ERROR = "#lyy.attached.error";
2
- export declare const LY_PENDING_ERROR_REGISTER = "#lyy.pending.error.register";
3
- export declare const LY_PENDING_ENUM_REGISTER = "#lyy.pending.enum.register";
4
- export declare const LY_SIGN_FQN_HOOK: unique symbol;
5
- export declare const LY_ATTACHED_FQN = "#lyy.attached.fqn";
6
- export declare const LY_PENDING_FQN_REGISTER = "#lyy.pending.fqn.register";
7
- export declare const LY_ATTACHED_LOG = "#lyy.attached.log";
8
- export declare const LY_PENDING_LOG_REGISTER = "#lyy.pending.log.register";
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LY_PENDING_LOG_REGISTER = exports.LY_ATTACHED_LOG = exports.LY_PENDING_FQN_REGISTER = exports.LY_ATTACHED_FQN = exports.LY_SIGN_FQN_HOOK = exports.LY_PENDING_ENUM_REGISTER = exports.LY_PENDING_ERROR_REGISTER = exports.LY_ATTACHED_ERROR = void 0;
4
- exports.LY_ATTACHED_ERROR = '#lyy.attached.error';
5
- exports.LY_PENDING_ERROR_REGISTER = '#lyy.pending.error.register';
6
- exports.LY_PENDING_ENUM_REGISTER = '#lyy.pending.enum.register';
7
- exports.LY_SIGN_FQN_HOOK = Symbol.for(`#lyy.fqn.h`);
8
- exports.LY_ATTACHED_FQN = '#lyy.attached.fqn';
9
- exports.LY_PENDING_FQN_REGISTER = '#lyy.pending.fqn.register';
10
- exports.LY_ATTACHED_LOG = '#lyy.attached.log';
11
- exports.LY_PENDING_LOG_REGISTER = '#lyy.pending.log.register';
@@ -1,47 +0,0 @@
1
- import { List, StorageDetail, StorageItem } from "../shared";
2
- import { CommonStorage, CommonStorageSecure } from "./index-types";
3
- import { Leyyo } from "../leyyo";
4
- import { StorageType } from "../literal";
5
- /** @inheritDoc */
6
- export declare class CommonStorageImpl implements CommonStorage, CommonStorageSecure {
7
- private readonly _lists;
8
- private readonly _arrays;
9
- private readonly _maps;
10
- private readonly _sets;
11
- /**
12
- * Default constructor
13
- *
14
- * Responsibilities
15
- * - Create repositories => ie: lists, arrays, maps, sets
16
- * */
17
- constructor();
18
- $init(leyyo: Leyyo): void;
19
- /**
20
- * Get sizes of each repository by given type and name (optional)
21
- *
22
- * @param {StorageType} type
23
- * @param {string?} name
24
- * @return {StorageItem}
25
- * */
26
- protected detailItem(type: StorageType, name?: string): StorageItem;
27
- /** @inheritDoc */
28
- newList<V>(name: string): List<V>;
29
- /** @inheritDoc */
30
- getList<V>(name: string): List<V>;
31
- /** @inheritDoc */
32
- newArray<V>(name: string): Array<V>;
33
- /** @inheritDoc */
34
- getArray<V>(name: string): Array<V>;
35
- /** @inheritDoc */
36
- newMap<V>(name: string): Map<string, V>;
37
- /** @inheritDoc */
38
- getMap<V>(name: string): Map<string, V>;
39
- /** @inheritDoc */
40
- newSet<V>(name: string): Set<V>;
41
- /** @inheritDoc */
42
- getSet<V>(name: string): Set<V>;
43
- /** @inheritDoc */
44
- details(type?: StorageType, name?: string): StorageDetail;
45
- get $back(): CommonStorage;
46
- get $secure(): CommonStorageSecure;
47
- }
@@ -1,150 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CommonStorageImpl = void 0;
4
- const shared_1 = require("../shared");
5
- // noinspection JSUnusedLocalSymbols,JSUnusedGlobalSymbols
6
- /** @inheritDoc */
7
- class CommonStorageImpl {
8
- /**
9
- * Default constructor
10
- *
11
- * Responsibilities
12
- * - Create repositories => ie: lists, arrays, maps, sets
13
- * */
14
- constructor() {
15
- this._lists = new Map();
16
- this._arrays = new Map();
17
- this._maps = new Map();
18
- this._sets = new Map();
19
- }
20
- $init(leyyo) {
21
- }
22
- /**
23
- * Get sizes of each repository by given type and name (optional)
24
- *
25
- * @param {StorageType} type
26
- * @param {string?} name
27
- * @return {StorageItem}
28
- * */
29
- detailItem(type, name) {
30
- const result = {};
31
- switch (type) {
32
- case "array":
33
- if (name) {
34
- if (this._arrays.has(name)) {
35
- return { [name]: this._arrays.get(name).length };
36
- }
37
- return { [name]: -1 };
38
- }
39
- for (const [key, list] of this._arrays.entries()) {
40
- result[key] = list.length;
41
- }
42
- return result;
43
- case "list":
44
- if (name) {
45
- if (this._lists.has(name)) {
46
- return { [name]: this._lists.get(name).length };
47
- }
48
- return { [name]: -1 };
49
- }
50
- for (const [key, list] of this._lists.entries()) {
51
- result[key] = list.length;
52
- }
53
- return result;
54
- case "map":
55
- if (name) {
56
- if (this._maps.has(name)) {
57
- return { [name]: this._maps.get(name).size };
58
- }
59
- return { [name]: -1 };
60
- }
61
- for (const [key, map] of this._maps.entries()) {
62
- result[key] = map.size;
63
- }
64
- return result;
65
- case "set":
66
- if (name) {
67
- if (this._sets.has(name)) {
68
- return { [name]: this._sets.get(name).size };
69
- }
70
- return { [name]: -1 };
71
- }
72
- for (const [key, set] of this._sets.entries()) {
73
- result[key] = set.size;
74
- }
75
- return result;
76
- default:
77
- return { [name]: -1 };
78
- }
79
- }
80
- // region list
81
- /** @inheritDoc */
82
- newList(name) {
83
- const list = new shared_1.List();
84
- this._lists.set(name, list);
85
- return list;
86
- }
87
- /** @inheritDoc */
88
- getList(name) {
89
- return this._lists.get(name);
90
- }
91
- // endregion list
92
- // region array
93
- /** @inheritDoc */
94
- newArray(name) {
95
- const arr = [];
96
- this._arrays.set(name, arr);
97
- return arr;
98
- }
99
- /** @inheritDoc */
100
- getArray(name) {
101
- return this._arrays.get(name);
102
- }
103
- // endregion array
104
- // region map
105
- /** @inheritDoc */
106
- newMap(name) {
107
- const map = new Map;
108
- this._maps.set(name, map);
109
- return map;
110
- }
111
- /** @inheritDoc */
112
- getMap(name) {
113
- return this._maps.get(name);
114
- }
115
- // endregion map
116
- // region set
117
- /** @inheritDoc */
118
- newSet(name) {
119
- const set = new Set;
120
- this._sets.set(name, set);
121
- return set;
122
- }
123
- /** @inheritDoc */
124
- getSet(name) {
125
- return this._sets.get(name);
126
- }
127
- // endregion set
128
- /** @inheritDoc */
129
- details(type, name) {
130
- const result = {};
131
- if (type) {
132
- result[type] = this.detailItem(type, name);
133
- return result;
134
- }
135
- else {
136
- result['array'] = this.detailItem('array', name);
137
- result['list'] = this.detailItem('list', name);
138
- result['map'] = this.detailItem('map', name);
139
- result['set'] = this.detailItem('set', name);
140
- return result;
141
- }
142
- }
143
- get $back() {
144
- return this;
145
- }
146
- get $secure() {
147
- return this;
148
- }
149
- }
150
- exports.CommonStorageImpl = CommonStorageImpl;
@@ -1,87 +0,0 @@
1
- import { InitLike, List, ShiftMain, ShiftSecure, StorageDetail } from "../shared";
2
- import { StorageType } from "../literal";
3
- /**
4
- * Storage factory
5
- *
6
- * Purpose, unify all iteration based data in some place to track memory usage in your applications
7
- * */
8
- export interface CommonStorage extends ShiftSecure<CommonStorageSecure> {
9
- /**
10
- * Creates new array
11
- *
12
- * @param {string} name
13
- * @return {Array<any>}
14
- * */
15
- newArray<V>(name: string): Array<V>;
16
- /**
17
- * Returns an array by given name
18
- *
19
- * @param {string} name
20
- * @return {Array<any>}
21
- *
22
- * Note:
23
- * If the array does not exist than it returns null
24
- * */
25
- getArray<V>(name: string): Array<V>;
26
- /**
27
- * Creates new list
28
- *
29
- * @param {string} name
30
- * @return {List<any>}
31
- * */
32
- newList<V>(name: string): List<V>;
33
- /**
34
- * Returns a list by given name
35
- *
36
- * @param {string} name
37
- * @return {List<any>}
38
- *
39
- * Note:
40
- * If the list does not exist than it returns null
41
- * */
42
- getList<V>(name: string): List<V>;
43
- /**
44
- * Creates new map
45
- *
46
- * @param {string} name
47
- * @return {Map<string, any>}
48
- * */
49
- newMap<V>(name: string): Map<string, V>;
50
- /**
51
- * Returns a map by given name
52
- *
53
- * @param {string} name
54
- * @return {Map<string, any>}
55
- *
56
- * Note:
57
- * If the map does not exist than it returns null
58
- * */
59
- getMap<V>(name: string): Map<string, V>;
60
- /**
61
- * Creates new set
62
- *
63
- * @param {string} name
64
- * @return {Set<any>}
65
- * */
66
- newSet<V>(name: string): Set<V>;
67
- /**
68
- * Returns a set by given name
69
- *
70
- * @param {string} name
71
- * @return {Set<any>}
72
- *
73
- * Note:
74
- * If the set does not exist than it returns null
75
- * */
76
- getSet<V>(name: string): Set<V>;
77
- /**
78
- * Exports sizes of repositories by given type and name
79
- *
80
- *
81
- * @param {StorageType?} type
82
- * @param {string?} name
83
- * @return {StorageDetail}
84
- * */
85
- details(type?: StorageType, name?: string): StorageDetail;
86
- }
87
- export type CommonStorageSecure = ShiftMain<CommonStorage> & InitLike;