@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,248 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CommonAssertionImpl = void 0;
4
- const exception_1 = require("../exception");
5
- // noinspection JSUnusedGlobalSymbols
6
- /** @inheritDoc */
7
- class CommonAssertionImpl {
8
- // endregion properties
9
- constructor() {
10
- }
11
- // region internal
12
- /**
13
- * Build error parameters as message and params
14
- * */
15
- buildErrorParameters(v2, indicator) {
16
- if (typeof v2 === 'string') {
17
- return { message: v2, params: { indicator } };
18
- }
19
- if (v2 && typeof v2 === 'object' && !Array.isArray(v2)) {
20
- const params = v2;
21
- if (params.indicator !== undefined) {
22
- params.indicator2 = params.indicator;
23
- params.indicator = indicator;
24
- }
25
- return { params };
26
- }
27
- if (typeof v2 === 'function') {
28
- try {
29
- return this.buildErrorParameters(v2(), indicator);
30
- }
31
- catch (e) {
32
- return { params: { indicator, callbackError: e.message } };
33
- }
34
- }
35
- if (v2 === null || v2 === undefined) {
36
- return { params: { indicator } };
37
- }
38
- const json = this.secureJson(v2);
39
- if (json && typeof json === 'object' && !Array.isArray(json)) {
40
- return { params: Object.assign(Object.assign({}, json), { indicator }) };
41
- }
42
- return { params: { json, indicator } };
43
- }
44
- /**
45
- * Inner secure json function, it will be used after creating weak set
46
- * */
47
- _secureJson(value, level, set) {
48
- if ([null, undefined].includes(value)) {
49
- return null;
50
- }
51
- switch (typeof value) {
52
- case 'object':
53
- if (set.has(value)) {
54
- return `<circular>${this.fqn.name(value === null || value === void 0 ? void 0 : value.constructor)}`;
55
- }
56
- if (level >= 10) {
57
- return `<max-depth>${this.fqn.name(value === null || value === void 0 ? void 0 : value.constructor)}`;
58
- }
59
- set.add(value);
60
- if (Array.isArray(value)) {
61
- return value.map(item => this._secureJson(item, level + 1, set));
62
- }
63
- const obj = {};
64
- if (value instanceof Map) {
65
- for (const [k, v] of value.entries()) {
66
- obj[k] = JSON.parse(JSON.stringify(this._secureJson(v, level + 1, set)));
67
- }
68
- }
69
- else if (value instanceof Set) {
70
- return Array.from(value).map(item => this._secureJson(item, level + 1, set));
71
- }
72
- else {
73
- for (const [k, v] of Object.entries(value)) {
74
- obj[k] = JSON.parse(JSON.stringify(this._secureJson(v, level + 1, set)));
75
- }
76
- }
77
- return obj;
78
- case 'function':
79
- return `<function>${this.fqn.name(value)}`;
80
- case 'symbol':
81
- return `<symbol>${value.toString()}`;
82
- }
83
- return value;
84
- }
85
- // endregion internal
86
- // region raise
87
- /** @inheritDoc */
88
- raise(opt, value, indicator, def) {
89
- const { message, params } = this.buildErrorParameters(opt, indicator);
90
- const type = typeof value;
91
- switch (type) {
92
- case "object":
93
- params.type = `object(${this.fqn.name(value.constructor)})`;
94
- break;
95
- case "function":
96
- params.type = `function(${this.fqn.name(value)})`;
97
- break;
98
- default:
99
- params.type = type;
100
- break;
101
- }
102
- def = def !== null && def !== void 0 ? def : 'Assertion error';
103
- throw new exception_1.AssertionException(message !== null && message !== void 0 ? message : def, params);
104
- }
105
- /** @inheritDoc */
106
- // noinspection JSUnusedLocalSymbols
107
- emptyFn(...params) {
108
- }
109
- /** @inheritDoc */
110
- secureJson(value) {
111
- return this._secureJson(value, 0, new WeakSet());
112
- }
113
- // endregion raise
114
- // region types
115
- /** @inheritDoc */
116
- array(value, opt) {
117
- if (!this.is.array(value)) {
118
- this.raise(opt, value, 'invalid.array.value', 'Invalid array value');
119
- }
120
- }
121
- /** @inheritDoc */
122
- boolean(value, opt) {
123
- if (!this.is.boolean(value)) {
124
- this.raise(opt, value, 'invalid.boolean.value', 'Invalid boolean value');
125
- }
126
- }
127
- /** @inheritDoc */
128
- clazz(value, opt) {
129
- if (!this.is.clazz(value)) {
130
- this.raise(opt, value, 'invalid.class.value', 'Invalid class value');
131
- }
132
- }
133
- /** @inheritDoc */
134
- date(value, opt) {
135
- if (!(value instanceof Date)) {
136
- this.raise(opt, value, 'invalid.date.value', 'Invalid date value');
137
- }
138
- }
139
- /** @inheritDoc */
140
- func(value, opt) {
141
- if (!this.is.func(value)) {
142
- this.raise(opt, value, 'invalid.function.value', 'Invalid function value');
143
- }
144
- }
145
- /** @inheritDoc */
146
- integer(value, opt) {
147
- if (!this.is.integer(value)) {
148
- this.raise(opt, value, 'invalid.integer.value', 'Invalid integer value');
149
- }
150
- }
151
- /** @inheritDoc */
152
- key(value, opt) {
153
- if (!this.is.key(value)) {
154
- this.raise(opt, value, 'invalid.key.value', 'Invalid key value');
155
- }
156
- }
157
- /** @inheritDoc */
158
- notEmpty(value, opt) {
159
- if (this.is.empty(value)) {
160
- this.raise(opt, value, 'empty.value', 'Empty value');
161
- }
162
- }
163
- /** @inheritDoc */
164
- number(value, opt) {
165
- if (!this.is.number(value)) {
166
- this.raise(opt, value, 'invalid.number.value', 'Invalid number value');
167
- }
168
- }
169
- /** @inheritDoc */
170
- realNumber(value, opt) {
171
- if (isNaN(value) || !isFinite(value)) {
172
- if (!opt) {
173
- opt = {};
174
- }
175
- if (!opt.silent) {
176
- delete opt.silent;
177
- this.raise(opt, value, 'not.real.number', 'Not real number');
178
- }
179
- return null;
180
- }
181
- return value;
182
- }
183
- /** @inheritDoc */
184
- object(value, opt) {
185
- if (!this.is.object(value)) {
186
- this.raise(opt, value, 'invalid.object.value', 'Invalid object value');
187
- }
188
- }
189
- /** @inheritDoc */
190
- positiveInteger(value, opt) {
191
- if (!this.is.integer(value) || (value <= 0)) {
192
- this.raise(opt, value, 'invalid.positive.integer.value', 'Invalid positive integer value');
193
- }
194
- }
195
- /** @inheritDoc */
196
- safeInteger(value, opt) {
197
- if (!this.is.safeInteger(value) || (value <= 0)) {
198
- this.raise(opt, value, 'invalid.safe.integer.value', 'Invalid safe integer value');
199
- }
200
- }
201
- /** @inheritDoc */
202
- positiveNumber(value, opt) {
203
- if (!this.is.number(value) || (value <= 0)) {
204
- this.raise(opt, value, 'invalid.positive.number.value', 'Invalid positive number value');
205
- }
206
- }
207
- /** @inheritDoc */
208
- primitive(value, opt) {
209
- if (!this.is.primitive(value)) {
210
- this.raise(opt, value, 'invalid.primitive.value', 'Invalid primitive value');
211
- }
212
- }
213
- /** @inheritDoc */
214
- string(value, opt) {
215
- if (!this.is.string(value)) {
216
- this.raise(opt, value, 'invalid.string.value', 'Invalid string value');
217
- }
218
- }
219
- /** @inheritDoc */
220
- text(value, opt) {
221
- if (!this.is.text(value)) {
222
- this.raise(opt, value, 'invalid.text.value', 'Invalid text value');
223
- }
224
- return value.trim();
225
- }
226
- /** @inheritDoc */
227
- realValue(value, opt) {
228
- if (!this.is.text(value)) {
229
- this.raise(opt, value, 'invalid.value.value', 'Invalid regular value');
230
- }
231
- }
232
- // endregion types
233
- // region secure
234
- /** @inheritDoc */
235
- get $back() {
236
- return this;
237
- }
238
- /** @inheritDoc */
239
- $init(leyyo) {
240
- this.is = leyyo.is;
241
- this.fqn = leyyo.fqn;
242
- }
243
- /** @inheritDoc */
244
- get $secure() {
245
- return this;
246
- }
247
- }
248
- exports.CommonAssertionImpl = CommonAssertionImpl;
@@ -1,92 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CommonErrorImpl = void 0;
4
- const shared_1 = require("../shared");
5
- const exception_1 = require("../exception");
6
- // noinspection JSUnusedLocalSymbols
7
- class CommonErrorImpl {
8
- get $back() {
9
- return this;
10
- }
11
- $init(leyyo) {
12
- this.hook = leyyo.hook;
13
- const fields = ['build', 'afterCreate', 'causedBy', 'toObject', 'buildStack', 'copyStack',
14
- 'initSign', 'addSign', 'getSign', 'removeSign', 'hasSign',
15
- 'initOmit', 'addOmit', 'getOmit', 'inheritOmit'];
16
- const rec = { proper: false };
17
- fields.forEach(field => {
18
- rec[field] = this[field];
19
- });
20
- // define itself temporarily for error operations
21
- this.hook.defineProvider(shared_1.LY_ATTACHED_ERROR, CommonErrorImpl, rec);
22
- // when new error provider is defined, replace all common methods
23
- this.hook.whenProviderDefined(shared_1.LY_ATTACHED_ERROR, CommonErrorImpl, (ins) => {
24
- fields.forEach(field => {
25
- if (typeof ins[field] === 'function') {
26
- this[field] = ins[field];
27
- }
28
- });
29
- });
30
- }
31
- get $secure() {
32
- return this;
33
- }
34
- addOmit(clz, ...properties) {
35
- return false;
36
- }
37
- addSign(err, ...keys) {
38
- return false;
39
- }
40
- afterCreate(e) {
41
- e.$secure.$setName(e.constructor.name);
42
- }
43
- register(cls) {
44
- this.hook.queueForCallback(shared_1.LY_PENDING_ERROR_REGISTER, cls);
45
- }
46
- build(e) {
47
- if (e instanceof exception_1.Exception) {
48
- return e;
49
- }
50
- else if (e instanceof Error) {
51
- const err = new exception_1.Exception(e.message, this.toObject(e, 'message', 'stack'));
52
- this.copyStack(err, e);
53
- return err;
54
- }
55
- else if (typeof e === 'string') {
56
- return new exception_1.Exception(e);
57
- }
58
- return new exception_1.Exception(`Unknown error`, Object.assign(Object.assign({}, this.toObject(e)), { type: typeof e }));
59
- }
60
- buildStack(e) {
61
- }
62
- copyStack(exception, error) {
63
- }
64
- causedBy(e) {
65
- return undefined;
66
- }
67
- getOmit(clz) {
68
- return undefined;
69
- }
70
- getSign(err) {
71
- return undefined;
72
- }
73
- hasSign(err, key) {
74
- return false;
75
- }
76
- inheritOmit(clz) {
77
- return undefined;
78
- }
79
- initOmit(clz) {
80
- return false;
81
- }
82
- initSign(err) {
83
- return false;
84
- }
85
- removeSign(err, ...keys) {
86
- return false;
87
- }
88
- toObject(e, ...omittedFields) {
89
- return undefined;
90
- }
91
- }
92
- exports.CommonErrorImpl = CommonErrorImpl;
@@ -1,18 +0,0 @@
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
- }
@@ -1,121 +0,0 @@
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;
@@ -1,91 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CommonIsImpl = void 0;
4
- const literal_1 = require("../literal");
5
- // noinspection JSUnusedGlobalSymbols, JSUnusedLocalSymbols
6
- /** @inheritDoc */
7
- class CommonIsImpl {
8
- // region is
9
- /** @inheritDoc */
10
- empty(value) {
11
- return (value === undefined || value === null || (typeof value === 'string' && value.trim() === ''));
12
- }
13
- /** @inheritDoc */
14
- primitive(value) {
15
- return literal_1.PrimitiveItems.includes((typeof value));
16
- }
17
- /** @inheritDoc */
18
- realValue(value) {
19
- return literal_1.RealValueItems.includes((typeof value));
20
- }
21
- /** @inheritDoc */
22
- key(value) {
23
- return literal_1.KeyValueItems.includes((typeof value));
24
- }
25
- /** @inheritDoc */
26
- object(value) {
27
- return value && typeof value === 'object' && !Array.isArray(value);
28
- }
29
- /** @inheritDoc */
30
- array(value) {
31
- return value && typeof value === 'object' && Array.isArray(value);
32
- }
33
- /** @inheritDoc */
34
- func(value) {
35
- return typeof value === 'function';
36
- }
37
- /** @inheritDoc */
38
- number(value) {
39
- return (typeof value === 'number') && !isNaN(value) && isFinite(value);
40
- }
41
- /** @inheritDoc */
42
- integer(value) {
43
- return this.number(value) && Number.isInteger(value);
44
- }
45
- /** @inheritDoc */
46
- safeInteger(value) {
47
- return this.number(value) && Number.isSafeInteger(value);
48
- }
49
- /** @inheritDoc */
50
- string(value) {
51
- return typeof value === 'string';
52
- }
53
- /** @inheritDoc */
54
- text(value) {
55
- return this.string(value) && value.trim() !== '';
56
- }
57
- /** @inheritDoc */
58
- clazz(value) {
59
- return this.text(value) || this.func(value) || this.object(value);
60
- }
61
- /** @inheritDoc */
62
- boolean(value) {
63
- return (typeof value === 'boolean');
64
- }
65
- /** @inheritDoc */
66
- true(value) {
67
- return (value === true) ||
68
- (this.text(value) && literal_1.WeakTrueItems.includes(value.toLowerCase())) ||
69
- (this.number(value) && value > 0);
70
- }
71
- /** @inheritDoc */
72
- false(value) {
73
- return (value === false) ||
74
- (this.text(value) && literal_1.WeakFalseItems.includes(value.toLowerCase())) ||
75
- (this.number(value) && value <= 0);
76
- }
77
- // endregion is
78
- // region secure
79
- /** @inheritDoc */
80
- $init(leyyo) {
81
- }
82
- /** @inheritDoc */
83
- get $back() {
84
- return this;
85
- }
86
- /** @inheritDoc */
87
- get $secure() {
88
- return this;
89
- }
90
- }
91
- exports.CommonIsImpl = CommonIsImpl;
@@ -1,26 +0,0 @@
1
- import { CommonHook } from "../hook";
2
- import { Leyyo } from "./index-types";
3
- import { CommonIs } from "../is";
4
- import { CommonAssertion } from "../assertion";
5
- import { CommonError } from "../error";
6
- import { CommonLog } from "../log";
7
- import { CommonStorage } from "../storage";
8
- import { CommonTo } from "../to";
9
- import { CommonFqn } from "../fqn";
10
- export declare class LeyyoImpl implements Leyyo {
11
- readonly hook: CommonHook;
12
- readonly is: CommonIs;
13
- readonly assertion: CommonAssertion;
14
- readonly error: CommonError;
15
- readonly log: CommonLog;
16
- readonly storage: CommonStorage;
17
- readonly to: CommonTo;
18
- readonly fqn: CommonFqn;
19
- constructor();
20
- private init;
21
- private postInit;
22
- private initFqnRegister;
23
- private initErrorRegister;
24
- private initEnumRegister;
25
- }
26
- export declare const leyyo: Leyyo;
@@ -1,94 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.leyyo = exports.LeyyoImpl = void 0;
7
- const hook_1 = require("../hook");
8
- const is_1 = require("../is");
9
- const assertion_1 = require("../assertion");
10
- const error_1 = require("../error");
11
- const log_1 = require("../log");
12
- const storage_1 = require("../storage");
13
- const to_1 = require("../to");
14
- const shared_1 = require("../shared");
15
- const internal_1 = require("../internal");
16
- const literal_1 = require("../literal");
17
- const exception_1 = require("../exception");
18
- const node_assert_1 = __importDefault(require("node:assert"));
19
- const fqn_1 = require("../fqn");
20
- class LeyyoImpl {
21
- constructor() {
22
- this.is = new is_1.CommonIsImpl();
23
- this.storage = new storage_1.CommonStorageImpl();
24
- this.hook = new hook_1.CommonHookImpl(); // storage
25
- this.log = new log_1.CommonLogImpl(); // hook
26
- this.error = new error_1.CommonErrorImpl(); // hook
27
- this.assertion = new assertion_1.CommonAssertionImpl(); // is, hook
28
- this.to = new to_1.CommonToImpl(); // is, hook, assertion
29
- this.fqn = new fqn_1.CommonFqnImpl(); // hook
30
- this.init();
31
- this.postInit();
32
- this.initFqnRegister();
33
- this.initErrorRegister();
34
- this.initEnumRegister();
35
- }
36
- init() {
37
- this.is.$secure.$init(this);
38
- this.storage.$secure.$init(this);
39
- this.hook.$secure.$init(this);
40
- this.log.$secure.$init(this);
41
- this.error.$secure.$init(this);
42
- this.assertion.$secure.$init(this);
43
- this.to.$secure.$init(this);
44
- }
45
- postInit() {
46
- (0, shared_1.$$setLeyyo)(this);
47
- log_1.LoggerImpl.$setLeyyo(this);
48
- exception_1.Exception.$setLeyyo(this);
49
- }
50
- initFqnRegister() {
51
- this.fqn.register(null, is_1.CommonIsImpl, 'class', internal_1.FQN_PCK);
52
- this.fqn.register(null, storage_1.CommonStorageImpl, 'class', internal_1.FQN_PCK);
53
- this.fqn.register(null, hook_1.CommonHookImpl, 'class', internal_1.FQN_PCK);
54
- this.fqn.register(null, fqn_1.CommonFqnImpl, 'class', internal_1.FQN_PCK);
55
- this.fqn.register(null, log_1.CommonLogImpl, 'class', internal_1.FQN_PCK);
56
- this.fqn.register(null, error_1.CommonErrorImpl, 'class', internal_1.FQN_PCK);
57
- this.fqn.register(null, assertion_1.CommonAssertionImpl, 'class', internal_1.FQN_PCK);
58
- this.fqn.register(null, to_1.CommonToImpl, 'class', internal_1.FQN_PCK);
59
- this.fqn.register(null, shared_1.List, 'class', internal_1.FQN_PCK);
60
- this.fqn.register(null, log_1.LoggerImpl, 'class', internal_1.FQN_PCK);
61
- this.fqn.register(null, node_assert_1.default, 'function', internal_1.FQN_PCK);
62
- }
63
- initErrorRegister() {
64
- [exception_1.Exception, exception_1.AssertionException, exception_1.CausedException, exception_1.DeveloperException, exception_1.MultipleException].forEach(cls => {
65
- this.fqn.register(null, cls, 'class', internal_1.FQN_PCK);
66
- this.error.register(cls);
67
- });
68
- }
69
- initEnumRegister() {
70
- const enumMap = {
71
- Primitive: literal_1.PrimitiveItems,
72
- StorageType: literal_1.StorageTypeItems,
73
- RealValue: literal_1.RealValueItems,
74
- KeyValue: literal_1.KeyValueItems,
75
- WeakTrue: literal_1.WeakTrueItems,
76
- WeakFalse: literal_1.WeakFalseItems,
77
- HttpMethod: literal_1.HttpMethodItems,
78
- HttpPlace: literal_1.HttpPlaceItems,
79
- Severity: literal_1.SeverityItems,
80
- Environment: literal_1.EnvironmentItems,
81
- CountryCode: literal_1.CountryCodeItems,
82
- LanguageCode: literal_1.LanguageCodeItems,
83
- LocaleCode: literal_1.LocaleCodeItems,
84
- SysClass: literal_1.SysClassItems,
85
- SysFunction: literal_1.SysFunctionItems,
86
- };
87
- for (const [name, value] of Object.entries(enumMap)) {
88
- this.fqn.register(name, value, 'enum', internal_1.FQN_PCK);
89
- this.hook.queueForCallback(shared_1.LY_PENDING_ENUM_REGISTER, value);
90
- }
91
- }
92
- }
93
- exports.LeyyoImpl = LeyyoImpl;
94
- exports.leyyo = new LeyyoImpl();
@@ -1,6 +0,0 @@
1
- import { WeakTrue } from "./weak-true";
2
- import { WeakFalse } from "./weak-false";
3
- /**
4
- * Weak Boolean
5
- * */
6
- export type WeakBoolean = WeakTrue & WeakFalse;