@leyyo/common 1.0.13 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (334) hide show
  1. package/dist/deploy/deploy.common.d.ts +12 -7
  2. package/dist/deploy/deploy.common.js +29 -10
  3. package/dist/deploy/deploy.common.js.map +1 -1
  4. package/dist/deploy/index.types.d.ts +12 -8
  5. package/dist/error/error.common.d.ts +12 -20
  6. package/dist/error/error.common.js +151 -85
  7. package/dist/error/error.common.js.map +1 -1
  8. package/dist/error/http-error.map.d.ts +6 -0
  9. package/dist/error/http-error.map.js +25 -0
  10. package/dist/error/http-error.map.js.map +1 -0
  11. package/dist/error/index.d.ts +2 -0
  12. package/dist/error/index.js +2 -0
  13. package/dist/error/index.js.map +1 -1
  14. package/dist/error/index.types.d.ts +35 -36
  15. package/dist/error/items/bad-request.error.d.ts +10 -0
  16. package/dist/error/items/bad-request.error.js +16 -0
  17. package/dist/error/items/bad-request.error.js.map +1 -0
  18. package/dist/error/items/caused.error.d.ts +8 -0
  19. package/dist/error/items/caused.error.js +16 -0
  20. package/dist/error/items/caused.error.js.map +1 -0
  21. package/dist/error/items/conflict.error.d.ts +10 -0
  22. package/dist/error/items/conflict.error.js +16 -0
  23. package/dist/error/items/conflict.error.js.map +1 -0
  24. package/dist/error/items/content-too-large.error.d.ts +10 -0
  25. package/dist/error/items/content-too-large.error.js +16 -0
  26. package/dist/error/items/content-too-large.error.js.map +1 -0
  27. package/dist/error/items/developer.error.d.ts +4 -0
  28. package/dist/error/items/developer.error.js +9 -0
  29. package/dist/error/items/developer.error.js.map +1 -0
  30. package/dist/error/items/forbidden.error.d.ts +10 -0
  31. package/dist/error/items/forbidden.error.js +16 -0
  32. package/dist/error/items/forbidden.error.js.map +1 -0
  33. package/dist/error/items/gone.error.d.ts +10 -0
  34. package/dist/error/items/gone.error.js +16 -0
  35. package/dist/error/items/gone.error.js.map +1 -0
  36. package/dist/error/items/http.error.d.ts +15 -0
  37. package/dist/error/items/http.error.js +21 -0
  38. package/dist/error/items/http.error.js.map +1 -0
  39. package/dist/error/items/index.d.ts +21 -0
  40. package/dist/error/items/index.js +38 -0
  41. package/dist/error/items/index.js.map +1 -0
  42. package/dist/error/items/invalid-value.error.d.ts +6 -0
  43. package/dist/error/items/invalid-value.error.js +11 -0
  44. package/dist/error/items/invalid-value.error.js.map +1 -0
  45. package/dist/error/items/length-required.error.d.ts +10 -0
  46. package/dist/error/items/length-required.error.js +16 -0
  47. package/dist/error/items/length-required.error.js.map +1 -0
  48. package/dist/error/items/leyyo.error.d.ts +50 -0
  49. package/dist/error/items/leyyo.error.js +98 -0
  50. package/dist/error/items/leyyo.error.js.map +1 -0
  51. package/dist/error/items/method-not-allowed.error.d.ts +10 -0
  52. package/dist/error/items/method-not-allowed.error.js +16 -0
  53. package/dist/error/items/method-not-allowed.error.js.map +1 -0
  54. package/dist/error/items/multiple.error.d.ts +11 -0
  55. package/dist/error/items/multiple.error.js +34 -0
  56. package/dist/error/items/multiple.error.js.map +1 -0
  57. package/dist/error/items/not-acceptable.error.d.ts +10 -0
  58. package/dist/error/items/not-acceptable.error.js +16 -0
  59. package/dist/error/items/not-acceptable.error.js.map +1 -0
  60. package/dist/error/items/not-found.error.d.ts +10 -0
  61. package/dist/error/items/not-found.error.js +16 -0
  62. package/dist/error/items/not-found.error.js.map +1 -0
  63. package/dist/error/items/payment-required.error.d.ts +10 -0
  64. package/dist/error/items/payment-required.error.js +16 -0
  65. package/dist/error/items/payment-required.error.js.map +1 -0
  66. package/dist/error/items/precondition-failed.error.d.ts +10 -0
  67. package/dist/error/items/precondition-failed.error.js +16 -0
  68. package/dist/error/items/precondition-failed.error.js.map +1 -0
  69. package/dist/error/items/proxy-authentication-required.error.d.ts +10 -0
  70. package/dist/error/items/proxy-authentication-required.error.js +16 -0
  71. package/dist/error/items/proxy-authentication-required.error.js.map +1 -0
  72. package/dist/error/items/request-timeout.error.d.ts +10 -0
  73. package/dist/error/items/request-timeout.error.js +16 -0
  74. package/dist/error/items/request-timeout.error.js.map +1 -0
  75. package/dist/error/items/silent.error.d.ts +11 -0
  76. package/dist/error/items/silent.error.js +19 -0
  77. package/dist/error/items/silent.error.js.map +1 -0
  78. package/dist/error/items/unauthorized.error.d.ts +10 -0
  79. package/dist/error/items/unauthorized.error.js +16 -0
  80. package/dist/error/items/unauthorized.error.js.map +1 -0
  81. package/dist/event/event.common.d.ts +77 -0
  82. package/dist/event/event.common.js +308 -0
  83. package/dist/event/event.common.js.map +1 -0
  84. package/dist/event/event.error.d.ts +3 -0
  85. package/dist/event/event.error.js +8 -0
  86. package/dist/event/event.error.js.map +1 -0
  87. package/dist/event/index.js.map +1 -0
  88. package/dist/event/index.types.d.ts +261 -0
  89. package/dist/{hook → event}/index.types.js.map +1 -1
  90. package/dist/hub/hub.channel.d.ts +27 -0
  91. package/dist/hub/hub.channel.js +83 -0
  92. package/dist/hub/hub.channel.js.map +1 -0
  93. package/dist/hub/hub.common.d.ts +27 -0
  94. package/dist/hub/hub.common.js +92 -0
  95. package/dist/hub/hub.common.js.map +1 -0
  96. package/dist/hub/index.js.map +1 -0
  97. package/dist/hub/index.types.d.ts +105 -0
  98. package/dist/{to → hub}/index.types.js.map +1 -1
  99. package/dist/index.d.ts +5 -23
  100. package/dist/index.js +7 -25
  101. package/dist/index.js.map +1 -1
  102. package/dist/leyyo/index.d.ts +0 -1
  103. package/dist/leyyo/index.js +0 -1
  104. package/dist/leyyo/index.js.map +1 -1
  105. package/dist/leyyo/index.types.d.ts +4 -22
  106. package/dist/leyyo/leyyo.d.ts +4 -22
  107. package/dist/leyyo/leyyo.js +12 -39
  108. package/dist/leyyo/leyyo.js.map +1 -1
  109. package/dist/log/index.types.d.ts +19 -26
  110. package/dist/log/log.common.d.ts +1 -1
  111. package/dist/log/log.common.js +24 -49
  112. package/dist/log/log.common.js.map +1 -1
  113. package/dist/log/logger.error.d.ts +3 -0
  114. package/dist/log/logger.error.js +8 -0
  115. package/dist/log/logger.error.js.map +1 -0
  116. package/dist/log/logger.instance.d.ts +7 -9
  117. package/dist/log/logger.instance.js +40 -50
  118. package/dist/log/logger.instance.js.map +1 -1
  119. package/dist/name/index.types.d.ts +1 -1
  120. package/dist/name/name.common.js +64 -37
  121. package/dist/name/name.common.js.map +1 -1
  122. package/dist/name/name.error.d.ts +3 -0
  123. package/dist/name/name.error.js +8 -0
  124. package/dist/name/name.error.js.map +1 -0
  125. package/dist/opt/index.js.map +1 -0
  126. package/dist/opt/index.types.d.ts +33 -0
  127. package/dist/{fqn → opt}/index.types.js.map +1 -1
  128. package/dist/opt/opt.common.d.ts +15 -0
  129. package/dist/opt/opt.common.js +93 -0
  130. package/dist/opt/opt.common.js.map +1 -0
  131. package/dist/repo/index.types.d.ts +1 -19
  132. package/dist/repo/repo.common.d.ts +0 -6
  133. package/dist/repo/repo.common.js +0 -20
  134. package/dist/repo/repo.common.js.map +1 -1
  135. package/dist/shared/index.d.ts +3 -0
  136. package/dist/shared/index.enum.d.ts +7 -0
  137. package/dist/{exception/index.types.js → shared/index.enum.js} +1 -1
  138. package/dist/shared/index.enum.js.map +1 -0
  139. package/dist/shared/index.fqn.d.ts +3 -0
  140. package/dist/shared/index.fqn.js +3 -0
  141. package/dist/shared/index.fqn.js.map +1 -0
  142. package/dist/shared/index.js +3 -0
  143. package/dist/shared/index.js.map +1 -1
  144. package/dist/shared/index.json.d.ts +33 -0
  145. package/dist/shared/index.json.js +3 -0
  146. package/dist/shared/index.json.js.map +1 -0
  147. package/dist/shared/index.types.d.ts +78 -100
  148. package/dist/shared/index.types.js +31 -0
  149. package/dist/shared/index.types.js.map +1 -1
  150. package/dist/util/delay.d.ts +9 -0
  151. package/dist/util/delay.js +21 -0
  152. package/dist/util/delay.js.map +1 -0
  153. package/dist/util/empty.fn.d.ts +8 -0
  154. package/dist/util/empty.fn.js +11 -0
  155. package/dist/util/empty.fn.js.map +1 -0
  156. package/dist/util/index.d.ts +5 -0
  157. package/dist/{developer → util}/index.js +5 -2
  158. package/dist/util/index.js.map +1 -0
  159. package/dist/util/one-or-more.d.ts +8 -0
  160. package/dist/util/one-or-more.js +19 -0
  161. package/dist/util/one-or-more.js.map +1 -0
  162. package/dist/util/secure-clone.d.ts +3 -0
  163. package/dist/util/secure-clone.js +38 -0
  164. package/dist/util/secure-clone.js.map +1 -0
  165. package/dist/util/secure-json.d.ts +37 -0
  166. package/dist/util/secure-json.js +126 -0
  167. package/dist/util/secure-json.js.map +1 -0
  168. package/package.json +2 -2
  169. package/dist/assertion/assertion.common.d.ts +0 -183
  170. package/dist/assertion/assertion.common.js +0 -663
  171. package/dist/assertion/assertion.common.js.map +0 -1
  172. package/dist/assertion/index.js.map +0 -1
  173. package/dist/assertion/index.types.d.ts +0 -661
  174. package/dist/assertion/index.types.js.map +0 -1
  175. package/dist/descriptor/descriptor.common.d.ts +0 -22
  176. package/dist/descriptor/descriptor.common.js +0 -117
  177. package/dist/descriptor/descriptor.common.js.map +0 -1
  178. package/dist/descriptor/index.js.map +0 -1
  179. package/dist/descriptor/index.types.d.ts +0 -23
  180. package/dist/descriptor/index.types.js.map +0 -1
  181. package/dist/developer/developer.common.d.ts +0 -32
  182. package/dist/developer/developer.common.js +0 -245
  183. package/dist/developer/developer.common.js.map +0 -1
  184. package/dist/developer/index.d.ts +0 -2
  185. package/dist/developer/index.errors.d.ts +0 -13
  186. package/dist/developer/index.errors.js +0 -24
  187. package/dist/developer/index.errors.js.map +0 -1
  188. package/dist/developer/index.js.map +0 -1
  189. package/dist/developer/index.types.d.ts +0 -85
  190. package/dist/developer/index.types.js.map +0 -1
  191. package/dist/exception/assertion.exception.d.ts +0 -5
  192. package/dist/exception/assertion.exception.js +0 -12
  193. package/dist/exception/assertion.exception.js.map +0 -1
  194. package/dist/exception/caused.exception.d.ts +0 -5
  195. package/dist/exception/caused.exception.js +0 -13
  196. package/dist/exception/caused.exception.js.map +0 -1
  197. package/dist/exception/developer.exception.d.ts +0 -5
  198. package/dist/exception/developer.exception.js +0 -12
  199. package/dist/exception/developer.exception.js.map +0 -1
  200. package/dist/exception/exception.d.ts +0 -32
  201. package/dist/exception/exception.js +0 -117
  202. package/dist/exception/exception.js.map +0 -1
  203. package/dist/exception/index.d.ts +0 -7
  204. package/dist/exception/index.js +0 -24
  205. package/dist/exception/index.js.map +0 -1
  206. package/dist/exception/index.types.d.ts +0 -30
  207. package/dist/exception/index.types.js.map +0 -1
  208. package/dist/exception/invalid-value.exception.d.ts +0 -5
  209. package/dist/exception/invalid-value.exception.js +0 -12
  210. package/dist/exception/invalid-value.exception.js.map +0 -1
  211. package/dist/exception/multiple.exception.d.ts +0 -8
  212. package/dist/exception/multiple.exception.js +0 -34
  213. package/dist/exception/multiple.exception.js.map +0 -1
  214. package/dist/fqn/fqn.common.d.ts +0 -20
  215. package/dist/fqn/fqn.common.js +0 -123
  216. package/dist/fqn/fqn.common.js.map +0 -1
  217. package/dist/fqn/index.js.map +0 -1
  218. package/dist/fqn/index.types.d.ts +0 -20
  219. package/dist/fqn/index.types.js +0 -3
  220. package/dist/hook/hook.common.d.ts +0 -25
  221. package/dist/hook/hook.common.js +0 -95
  222. package/dist/hook/hook.common.js.map +0 -1
  223. package/dist/hook/index.d.ts +0 -1
  224. package/dist/hook/index.js +0 -18
  225. package/dist/hook/index.js.map +0 -1
  226. package/dist/hook/index.types.d.ts +0 -72
  227. package/dist/hook/index.types.js +0 -3
  228. package/dist/is/index.d.ts +0 -1
  229. package/dist/is/index.js +0 -18
  230. package/dist/is/index.js.map +0 -1
  231. package/dist/is/index.types.d.ts +0 -240
  232. package/dist/is/index.types.js +0 -3
  233. package/dist/is/index.types.js.map +0 -1
  234. package/dist/is/is.common.d.ts +0 -71
  235. package/dist/is/is.common.js +0 -177
  236. package/dist/is/is.common.js.map +0 -1
  237. package/dist/leyyo/leyyo-hook.common.d.ts +0 -10
  238. package/dist/leyyo/leyyo-hook.common.js +0 -18
  239. package/dist/leyyo/leyyo-hook.common.js.map +0 -1
  240. package/dist/mixin/index.d.ts +0 -1
  241. package/dist/mixin/index.js +0 -18
  242. package/dist/mixin/index.js.map +0 -1
  243. package/dist/mixin/index.types.d.ts +0 -19
  244. package/dist/mixin/index.types.js +0 -3
  245. package/dist/mixin/index.types.js.map +0 -1
  246. package/dist/mixin/mixin.common.d.ts +0 -22
  247. package/dist/mixin/mixin.common.js +0 -165
  248. package/dist/mixin/mixin.common.js.map +0 -1
  249. package/dist/system/country-code.d.ts +0 -10
  250. package/dist/system/country-code.js +0 -19
  251. package/dist/system/country-code.js.map +0 -1
  252. package/dist/system/environment.d.ts +0 -7
  253. package/dist/system/environment.js +0 -6
  254. package/dist/system/environment.js.map +0 -1
  255. package/dist/system/index.d.ts +0 -7
  256. package/dist/system/index.js +0 -24
  257. package/dist/system/index.js.map +0 -1
  258. package/dist/system/index.types.d.ts +0 -6
  259. package/dist/system/index.types.js +0 -3
  260. package/dist/system/index.types.js.map +0 -1
  261. package/dist/system/language-code.d.ts +0 -7
  262. package/dist/system/language-code.js +0 -11
  263. package/dist/system/language-code.js.map +0 -1
  264. package/dist/system/locale-code.d.ts +0 -9
  265. package/dist/system/locale-code.js +0 -16
  266. package/dist/system/locale-code.js.map +0 -1
  267. package/dist/system/sys-class.d.ts +0 -4
  268. package/dist/system/sys-class.js +0 -21
  269. package/dist/system/sys-class.js.map +0 -1
  270. package/dist/system/sys-function.d.ts +0 -4
  271. package/dist/system/sys-function.js +0 -8
  272. package/dist/system/sys-function.js.map +0 -1
  273. package/dist/system/system.common.d.ts +0 -11
  274. package/dist/system/system.common.js +0 -64
  275. package/dist/system/system.common.js.map +0 -1
  276. package/dist/test/index.d.ts +0 -2
  277. package/dist/test/index.js +0 -19
  278. package/dist/test/index.js.map +0 -1
  279. package/dist/test/index.types.d.ts +0 -9
  280. package/dist/test/index.types.js +0 -3
  281. package/dist/test/index.types.js.map +0 -1
  282. package/dist/test/test.common.d.ts +0 -14
  283. package/dist/test/test.common.js +0 -48
  284. package/dist/test/test.common.js.map +0 -1
  285. package/dist/test/tested.d.ts +0 -1
  286. package/dist/test/tested.js +0 -9
  287. package/dist/test/tested.js.map +0 -1
  288. package/dist/to/index.d.ts +0 -7
  289. package/dist/to/index.js +0 -24
  290. package/dist/to/index.js.map +0 -1
  291. package/dist/to/index.types.d.ts +0 -76
  292. package/dist/to/index.types.js +0 -3
  293. package/dist/to/key-value.d.ts +0 -4
  294. package/dist/to/key-value.js +0 -8
  295. package/dist/to/key-value.js.map +0 -1
  296. package/dist/to/list.d.ts +0 -20
  297. package/dist/to/list.js +0 -38
  298. package/dist/to/list.js.map +0 -1
  299. package/dist/to/primitive.d.ts +0 -7
  300. package/dist/to/primitive.js +0 -6
  301. package/dist/to/primitive.js.map +0 -1
  302. package/dist/to/real-value.d.ts +0 -7
  303. package/dist/to/real-value.js +0 -6
  304. package/dist/to/real-value.js.map +0 -1
  305. package/dist/to/to.common.d.ts +0 -77
  306. package/dist/to/to.common.js +0 -1079
  307. package/dist/to/to.common.js.map +0 -1
  308. package/dist/to/weak-false.d.ts +0 -7
  309. package/dist/to/weak-false.js +0 -6
  310. package/dist/to/weak-false.js.map +0 -1
  311. package/dist/to/weak-true.d.ts +0 -7
  312. package/dist/to/weak-true.js +0 -9
  313. package/dist/to/weak-true.js.map +0 -1
  314. package/dist/wrapper/index.d.ts +0 -2
  315. package/dist/wrapper/index.js +0 -19
  316. package/dist/wrapper/index.js.map +0 -1
  317. package/dist/wrapper/index.types.d.ts +0 -29
  318. package/dist/wrapper/index.types.js +0 -3
  319. package/dist/wrapper/index.types.js.map +0 -1
  320. package/dist/wrapper/wrap.d.ts +0 -7
  321. package/dist/wrapper/wrap.js +0 -11
  322. package/dist/wrapper/wrap.js.map +0 -1
  323. package/dist/wrapper/wrapper.common.d.ts +0 -26
  324. package/dist/wrapper/wrapper.common.js +0 -82
  325. package/dist/wrapper/wrapper.common.js.map +0 -1
  326. /package/dist/{assertion → event}/index.d.ts +0 -0
  327. /package/dist/{assertion → event}/index.js +0 -0
  328. /package/dist/{assertion → event}/index.types.js +0 -0
  329. /package/dist/{descriptor → hub}/index.d.ts +0 -0
  330. /package/dist/{descriptor → hub}/index.js +0 -0
  331. /package/dist/{descriptor → hub}/index.types.js +0 -0
  332. /package/dist/{fqn → opt}/index.d.ts +0 -0
  333. /package/dist/{fqn → opt}/index.js +0 -0
  334. /package/dist/{developer → opt}/index.types.js +0 -0
@@ -1,663 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AssertionCommon = void 0;
4
- const internal_1 = require("../internal");
5
- // noinspection JSUnusedGlobalSymbols
6
- /** @inheritDoc */
7
- class AssertionCommon {
8
- // endregion properties
9
- constructor(lyy) {
10
- this.lyy = lyy;
11
- // region properties
12
- this._EMPTY = [null, undefined];
13
- }
14
- // region internal
15
- _run(opt) {
16
- if (typeof opt === 'string') {
17
- return { issue: opt };
18
- }
19
- else if (typeof opt === 'function') {
20
- try {
21
- const values = opt();
22
- if (Array.isArray(values)) {
23
- let [pck, testCase, opt2] = values;
24
- if (!opt2) {
25
- opt2 = {};
26
- }
27
- opt2['message'] = this.lyy.test.code(pck, testCase);
28
- return opt2;
29
- }
30
- else if (typeof values === 'string') {
31
- return { issue: values };
32
- }
33
- else {
34
- return (values && values.contructor === Object) ? values : {};
35
- }
36
- }
37
- catch (e) {
38
- const now = Date.now();
39
- return {
40
- message: e.message,
41
- [`e-${now}-name`]: e.name,
42
- };
43
- }
44
- }
45
- else {
46
- return ((opt === null || opt === void 0 ? void 0 : opt.contructor) === Object) ? opt : {};
47
- }
48
- }
49
- _optional(value, fn) {
50
- if (this._EMPTY.includes(value)) {
51
- return;
52
- }
53
- fn();
54
- }
55
- _array(value, opt, issue, fn) {
56
- if (!Array.isArray(value)) {
57
- throw this.lyy.dev.invalidError(this._run(opt), { issue, reason: 'type', type: typeof value });
58
- }
59
- const arr = value;
60
- if (arr.length < 1) {
61
- throw this.lyy.dev.invalidError(this._run(opt), { issue, reason: 'size', size: 0 });
62
- }
63
- const wrongIndexes = arr.filter(item => !fn(item)).map((_v, index) => index);
64
- if (wrongIndexes.length > 0) {
65
- throw this.lyy.dev.invalidError(this._run(opt), { issue, reason: 'items', wrongIndexes });
66
- }
67
- }
68
- _is(value, opt, issue, fn, extra) {
69
- if (!fn(value)) {
70
- throw this.lyy.dev.invalidError(this._run(opt), Object.assign({ issue, value, type: typeof value }, extra));
71
- }
72
- }
73
- _replaceMethod(method) {
74
- if (method.endsWith('?')) {
75
- method = method.slice(0, -1) + 'Optional';
76
- }
77
- else if (method.endsWith('[]')) {
78
- method = method.slice(0, -2) + 'Array';
79
- }
80
- return method;
81
- }
82
- _execLambda(value, method, opt, isDual, throwable, another) {
83
- if (typeof method !== 'string') {
84
- if (throwable) {
85
- throw this.lyy.dev.invalidError(this._run(opt), { issue: 'invalid.method.name', value: method });
86
- }
87
- return 'invalid.method.name';
88
- }
89
- method = this._replaceMethod(method);
90
- const fn = this[method];
91
- if (typeof fn !== 'function') {
92
- if (throwable) {
93
- throw this.lyy.dev.invalidError(this._run(opt), { issue: 'unknown.assertion.method', value: method });
94
- }
95
- return 'unknown.assertion.method';
96
- }
97
- try {
98
- if (isDual) {
99
- fn(value, another, opt);
100
- }
101
- else {
102
- fn(value, opt);
103
- }
104
- }
105
- catch (e) {
106
- if (throwable) {
107
- throw e;
108
- }
109
- return e.message;
110
- }
111
- return undefined;
112
- }
113
- _isTupleReason(value, setting) {
114
- if (!Array.isArray(setting)) {
115
- return 'invalid.tuple.setting';
116
- }
117
- if (!Array.isArray(value)) {
118
- return 'tuple.should.be.array';
119
- }
120
- const arr = value;
121
- if (arr.length < 1) {
122
- return 'tuple.empty.array';
123
- }
124
- if (arr.length !== setting.length) {
125
- return 'tuple.size.conflict';
126
- }
127
- let index = -1;
128
- for (const set of setting) {
129
- index++;
130
- let method;
131
- let another;
132
- let isDual;
133
- if (Array.isArray(set)) {
134
- if (set[0] === 'or') {
135
- const orCase = set;
136
- if (!this._isOrCase(arr[index], orCase[1])) {
137
- return 'invalid-or-case';
138
- }
139
- break;
140
- }
141
- const dualCase = set;
142
- method = dualCase[0];
143
- another = dualCase[1];
144
- isDual = true;
145
- if (another === undefined) {
146
- return 'invalid.tuple.setting';
147
- }
148
- }
149
- else if (typeof set === 'string') {
150
- method = set;
151
- }
152
- const issue = this._execLambda(arr[index], method, {}, isDual, false, another);
153
- if (issue) {
154
- return issue;
155
- }
156
- }
157
- return undefined;
158
- }
159
- _isTuple(value, setting) {
160
- return !this._isTupleReason(value, setting);
161
- }
162
- _isOrCase(value, types) {
163
- for (const type of types) {
164
- let method;
165
- let another;
166
- let isDual;
167
- if (typeof type === 'string') {
168
- method = type;
169
- }
170
- else if (Array.isArray(type) && type.length === 2) {
171
- method = type[0];
172
- another = type[1];
173
- isDual = true;
174
- }
175
- const issue = this._execLambda(value, method, {}, isDual, false, another);
176
- if (!issue) {
177
- return true;
178
- }
179
- }
180
- return false;
181
- }
182
- // endregion internal
183
- // region general
184
- /** @inheritDoc */
185
- notEmpty(value, opt) {
186
- if (this._EMPTY.includes(value)) {
187
- throw this.lyy.dev.invalidError(this._run(opt), { issue: 'empty', value, type: typeof value });
188
- }
189
- return value;
190
- }
191
- // endregion general
192
- // region or
193
- orCase(value, types, opt) {
194
- let firstError;
195
- for (const type of types) {
196
- let method;
197
- let another;
198
- let isDual;
199
- let errorOccurred;
200
- if (Array.isArray(type)) {
201
- const dualCase = type;
202
- method = dualCase[0];
203
- another = dualCase[1];
204
- isDual = true;
205
- if (another === undefined) {
206
- if (!firstError) {
207
- firstError = this.lyy.dev.invalidError(this._run(opt), { issue: 'invalid.tuple.setting', value: method });
208
- }
209
- errorOccurred = true;
210
- }
211
- }
212
- else if (typeof type === 'string') {
213
- method = type;
214
- }
215
- if (!errorOccurred) {
216
- const issue = this._execLambda(value, method, opt, isDual, false, another);
217
- if (!issue) {
218
- return;
219
- }
220
- if (!firstError) {
221
- firstError = this.lyy.dev.invalidError(this._run(opt), { issue, value: method });
222
- }
223
- }
224
- }
225
- if (firstError) {
226
- throw firstError;
227
- }
228
- }
229
- /** @inheritDoc */
230
- orCaseOptional(value, types, opt) {
231
- this._optional(value, () => this.orCase(value, types, opt));
232
- }
233
- /** @inheritDoc */
234
- orCaseArray(value, types, opt) {
235
- this._array(value, opt, 'invalid.orCase.array', (v) => this._isOrCase(v, types));
236
- }
237
- // endregion or
238
- // region realValue
239
- /** @inheritDoc */
240
- realValue(value, opt) {
241
- this._is(value, opt, 'invalid.realValue', v => this.lyy.is.realValue(v), {});
242
- }
243
- /** @inheritDoc */
244
- realValueOptional(value, opt) {
245
- this._optional(value, () => this.realValue(value, opt));
246
- }
247
- /** @inheritDoc */
248
- realValueArray(value, opt) {
249
- this._array(value, opt, 'invalid.realValue.array', (v) => this.lyy.is.realValue(v));
250
- }
251
- // endregion realValue
252
- // region object
253
- /** @inheritDoc */
254
- object(value, opt) {
255
- this._is(value, opt, 'invalid.object', v => this.lyy.is.object(v), {});
256
- }
257
- /** @inheritDoc */
258
- objectOptional(value, opt) {
259
- this._optional(value, () => this.object(value, opt));
260
- }
261
- objectArray(value, opt) {
262
- this._array(value, opt, 'invalid.object.array', (v) => this.lyy.is.object(v));
263
- }
264
- // endregion object
265
- // region bareObject
266
- /** @inheritDoc */
267
- bareObject(value, opt) {
268
- this._is(value, opt, 'invalid.bareObject', v => this.lyy.is.bareObject(v), {});
269
- }
270
- /** @inheritDoc */
271
- bareObjectOptional(value, opt) {
272
- this._optional(value, () => this.bareObject(value, opt));
273
- }
274
- bareObjectArray(value, opt) {
275
- this._array(value, opt, 'invalid.bareObject.array', (v) => this.lyy.is.bareObject(v));
276
- }
277
- // endregion bareObject
278
- // region anotherObject
279
- /** @inheritDoc */
280
- anotherObject(value, opt) {
281
- this._is(value, opt, 'invalid.anotherObject', v => this.lyy.is.anotherObject(v), {});
282
- }
283
- /** @inheritDoc */
284
- anotherObjectOptional(value, opt) {
285
- this._optional(value, () => this.anotherObject(value, opt));
286
- }
287
- /** @inheritDoc */
288
- anotherObjectArray(value, opt) {
289
- this._array(value, opt, 'invalid.anotherObject.array', (v) => this.lyy.is.anotherObject(v));
290
- }
291
- // endregion anotherObject
292
- // region array
293
- /** @inheritDoc */
294
- array(value, opt) {
295
- this._is(value, opt, 'invalid.array', v => Array.isArray(v) && v.length > 0, {});
296
- }
297
- /** @inheritDoc */
298
- arrayOptional(value, opt) {
299
- this._optional(value, () => this.array(value, opt));
300
- }
301
- /** @inheritDoc */
302
- arrayArray(value, opt) {
303
- this._array(value, opt, 'invalid.array.array', (v) => Array.isArray(v));
304
- }
305
- // endregion array
306
- // region instanceOf
307
- /** @inheritDoc */
308
- instanceOf(value, clazz, opt) {
309
- this._is(value, opt, 'invalid.instanceOf', v => this.lyy.is.instanceOf(v, clazz), { clazz });
310
- }
311
- /** @inheritDoc */
312
- instanceOfOptional(value, clazz, opt) {
313
- this._optional(value, () => this.instanceOf(value, clazz, opt));
314
- }
315
- /** @inheritDoc */
316
- instanceOfArray(value, clazz, opt) {
317
- this._array(value, opt, 'invalid.instanceOf.array', (v) => this.lyy.is.instanceOf(v, clazz));
318
- }
319
- // endregion instanceOf
320
- // region tuple
321
- /** @inheritDoc */
322
- tuple(value, setting, opt) {
323
- if (!Array.isArray(setting)) {
324
- throw this.lyy.dev.invalidError(this._run(opt), {
325
- issue: 'invalid.tuple.setting',
326
- value: setting,
327
- type: typeof setting
328
- });
329
- }
330
- if (!Array.isArray(value)) {
331
- throw this.lyy.dev.invalidError(this._run(opt), {
332
- issue: 'tuple.should.be.array',
333
- value: setting,
334
- type: typeof setting
335
- });
336
- }
337
- const arr = value;
338
- if (arr.length !== setting.length) {
339
- throw this.lyy.dev.invalidError(this._run(opt), {
340
- issue: 'tuple.size.conflict',
341
- value: arr.length,
342
- setting: setting.length
343
- });
344
- }
345
- setting.forEach((set, index) => {
346
- let method;
347
- let another;
348
- let isDual;
349
- if (Array.isArray(set)) {
350
- if (set[0] === 'or') {
351
- const orCase = set;
352
- this.orCase(arr[index], orCase[1], opt);
353
- return;
354
- }
355
- const dualCase = set;
356
- method = dualCase[0];
357
- another = dualCase[1];
358
- isDual = true;
359
- if (another === undefined) {
360
- throw this.lyy.dev.invalidError(this._run(opt), {
361
- issue: 'invalid.tuple.setting',
362
- index,
363
- value: setting,
364
- type: typeof setting
365
- });
366
- }
367
- }
368
- else if (typeof set === 'string') {
369
- method = set;
370
- }
371
- this._execLambda(arr[index], method, opt, isDual, true, another);
372
- });
373
- }
374
- /** @inheritDoc */
375
- tupleOptional(value, setting, opt) {
376
- this._optional(value, () => this.tuple(value, setting, opt));
377
- }
378
- /** @inheritDoc */
379
- tupleArray(value, setting, opt) {
380
- this._array(value, opt, 'invalid.tuple.array', (v) => this._isTuple(v, setting));
381
- }
382
- // endregion tuple
383
- // region primitive
384
- /** @inheritDoc */
385
- primitive(value, opt) {
386
- this._is(value, opt, 'invalid.primitive', v => this.lyy.is.primitive(v), {});
387
- }
388
- /** @inheritDoc */
389
- primitiveOptional(value, opt) {
390
- this._optional(value, () => this.primitive(value, opt));
391
- }
392
- /** @inheritDoc */
393
- primitiveArray(value, opt) {
394
- this._array(value, opt, 'invalid.primitive.array', (v) => this.lyy.is.primitive(v));
395
- }
396
- // endregion primitive
397
- // region key
398
- /** @inheritDoc */
399
- key(value, opt) {
400
- this._is(value, opt, 'invalid.key', v => this.lyy.is.key(v), {});
401
- }
402
- /** @inheritDoc */
403
- keyOptional(value, opt) {
404
- this._optional(value, () => this.key(value, opt));
405
- }
406
- /** @inheritDoc */
407
- keyArray(value, opt) {
408
- this._array(value, opt, 'invalid.key.array', (v) => this.lyy.is.key(v));
409
- }
410
- // endregion key
411
- // region arrayLike
412
- /** @inheritDoc */
413
- arrayLike(value, opt) {
414
- this._is(value, opt, 'invalid.arrayLike', v => this.lyy.is.arrayLike(v), {});
415
- }
416
- /** @inheritDoc */
417
- arrayLikeOptional(value, opt) {
418
- this._optional(value, () => this.arrayLike(value, opt));
419
- }
420
- /** @inheritDoc */
421
- arrayLikeArray(value, opt) {
422
- this._array(value, opt, 'invalid.arrayLike.array', (v) => this.lyy.is.arrayLike(v));
423
- }
424
- // endregion arrayLike
425
- // region function
426
- /** @inheritDoc */
427
- func(value, opt) {
428
- this._is(value, opt, 'invalid.function', v => this.lyy.is.func(v), {});
429
- }
430
- /** @inheritDoc */
431
- funcOptional(value, opt) {
432
- this._optional(value, () => this.func(value, opt));
433
- }
434
- /** @inheritDoc */
435
- funcArray(value, opt) {
436
- this._array(value, opt, 'invalid.function.array', (v) => this.lyy.is.func(v));
437
- }
438
- // endregion function
439
- // region symbol
440
- /** @inheritDoc */
441
- sym(value, opt) {
442
- this._is(value, opt, 'invalid.symbol', v => this.lyy.is.sym(v), {});
443
- }
444
- /** @inheritDoc */
445
- symOptional(value, opt) {
446
- this._optional(value, () => this.sym(value, opt));
447
- }
448
- /** @inheritDoc */
449
- symArray(value, opt) {
450
- this._array(value, opt, 'invalid.symbol.array', (v) => this.lyy.is.sym(v));
451
- }
452
- // endregion symbol
453
- // region number
454
- /** @inheritDoc */
455
- number(value, opt) {
456
- this._is(value, opt, 'invalid.number', v => this.lyy.is.number(v), {});
457
- }
458
- /** @inheritDoc */
459
- numberOptional(value, opt) {
460
- this._optional(value, () => this.number(value, opt));
461
- }
462
- /** @inheritDoc */
463
- numberArray(value, opt) {
464
- this._array(value, opt, 'invalid.number.array', (v) => this.lyy.is.number(v));
465
- }
466
- // endregion number
467
- // region positiveNumber
468
- /** @inheritDoc */
469
- positiveNumber(value, opt) {
470
- this._is(value, opt, 'invalid.positiveNumber', v => this.lyy.is.positiveNumber(v), {});
471
- }
472
- /** @inheritDoc */
473
- positiveNumberOptional(value, opt) {
474
- this._optional(value, () => this.positiveNumber(value, opt));
475
- }
476
- /** @inheritDoc */
477
- positiveNumberArray(value, opt) {
478
- this._array(value, opt, 'invalid.positiveNumber.array', (v) => this.lyy.is.positiveNumber(v));
479
- }
480
- // endregion positiveNumber
481
- // region nonNegativeNumber
482
- /** @inheritDoc */
483
- nonNegativeNumber(value, opt) {
484
- this._is(value, opt, 'invalid.nonNegativeNumber', v => this.lyy.is.nonNegativeNumber(v), {});
485
- }
486
- /** @inheritDoc */
487
- nonNegativeNumberOptional(value, opt) {
488
- this._optional(value, () => this.nonNegativeNumber(value, opt));
489
- }
490
- /** @inheritDoc */
491
- nonNegativeNumberArray(value, opt) {
492
- this._array(value, opt, 'invalid.nonNegativeNumber.array', (v) => this.lyy.is.nonNegativeNumber(v));
493
- }
494
- // endregion nonNegativeNumber
495
- // region integer
496
- /** @inheritDoc */
497
- integer(value, opt) {
498
- this._is(value, opt, 'invalid.integer', v => this.lyy.is.integer(v), {});
499
- }
500
- /** @inheritDoc */
501
- integerOptional(value, opt) {
502
- this._optional(value, () => this.integer(value, opt));
503
- }
504
- /** @inheritDoc */
505
- integerArray(value, opt) {
506
- this._array(value, opt, 'invalid.integer.array', (v) => this.lyy.is.integer(v));
507
- }
508
- // endregion integer
509
- // region safeInteger
510
- /** @inheritDoc */
511
- safeInteger(value, opt) {
512
- this._is(value, opt, 'invalid.safeInteger', v => this.lyy.is.safeInteger(v), {});
513
- }
514
- /** @inheritDoc */
515
- safeIntegerOptional(value, opt) {
516
- this._optional(value, () => this.safeInteger(value, opt));
517
- }
518
- /** @inheritDoc */
519
- safeIntegerArray(value, opt) {
520
- this._array(value, opt, 'invalid.safeInteger.array', (v) => this.lyy.is.safeInteger(v));
521
- }
522
- // endregion safeInteger
523
- // region positiveInteger
524
- /** @inheritDoc */
525
- positiveInteger(value, opt) {
526
- this._is(value, opt, 'invalid.positiveInteger', v => this.lyy.is.positiveInteger(v), {});
527
- }
528
- /** @inheritDoc */
529
- positiveIntegerOptional(value, opt) {
530
- this._optional(value, () => this.positiveInteger(value, opt));
531
- }
532
- /** @inheritDoc */
533
- positiveIntegerArray(value, opt) {
534
- this._array(value, opt, 'invalid.positiveInteger.array', (v) => this.lyy.is.positiveInteger(v));
535
- }
536
- // endregion positiveInteger
537
- // region nonNegativeInteger
538
- nonNegativeInteger(value, opt) {
539
- this._is(value, opt, 'invalid.nonNegativeInteger', v => this.lyy.is.nonNegativeInteger(v), {});
540
- }
541
- nonNegativeIntegerArray(value, opt) {
542
- this._optional(value, () => this.nonNegativeInteger(value, opt));
543
- }
544
- nonNegativeIntegerOptional(value, opt) {
545
- this._array(value, opt, 'invalid.nonNegativeInteger.array', (v) => this.lyy.is.nonNegativeInteger(v));
546
- }
547
- // endregion nonNegativeInteger
548
- // region string
549
- /** @inheritDoc */
550
- string(value, opt) {
551
- this._is(value, opt, 'invalid.string', v => this.lyy.is.string(v), {});
552
- }
553
- /** @inheritDoc */
554
- stringOptional(value, opt) {
555
- this._optional(value, () => this.string(value, opt));
556
- }
557
- /** @inheritDoc */
558
- stringArray(value, opt) {
559
- this._array(value, opt, 'invalid.string.array', (v) => this.lyy.is.string(v));
560
- }
561
- // endregion string
562
- // region text
563
- /** @inheritDoc */
564
- text(value, opt) {
565
- this._is(value, opt, 'invalid.text', v => this.lyy.is.text(v), {});
566
- }
567
- /** @inheritDoc */
568
- textOptional(value, opt) {
569
- this._optional(value, () => this.text(value, opt));
570
- }
571
- /** @inheritDoc */
572
- textArray(value, opt) {
573
- this._array(value, opt, 'invalid.text.array', (v) => this.lyy.is.text(v));
574
- }
575
- // endregion text
576
- // region clazz
577
- /** @inheritDoc */
578
- clazz(value, opt) {
579
- this._is(value, opt, 'invalid.class', v => this.lyy.is.clazz(v), {});
580
- }
581
- /** @inheritDoc */
582
- clazzOptional(value, opt) {
583
- this._optional(value, () => this.clazz(value, opt));
584
- }
585
- /** @inheritDoc */
586
- clazzArray(value, opt) {
587
- this._array(value, opt, 'invalid.clazz.array', (v) => this.lyy.is.clazz(v));
588
- }
589
- // endregion clazz
590
- // region possibleFunc
591
- /** @inheritDoc */
592
- possibleFunc(value, opt) {
593
- this._is(value, opt, 'invalid.possibleFunc', v => this.lyy.is.possibleFunc(v), {});
594
- }
595
- /** @inheritDoc */
596
- possibleFuncOptional(value, opt) {
597
- this._optional(value, () => this.possibleFunc(value, opt));
598
- }
599
- /** @inheritDoc */
600
- possibleFuncArray(value, opt) {
601
- this._array(value, opt, 'invalid.possibleFunc.array', (v) => this.lyy.is.possibleFunc(v));
602
- }
603
- // endregion possibleFunc
604
- // region boolean
605
- /** @inheritDoc */
606
- boolean(value, opt) {
607
- this._is(value, opt, 'invalid.boolean', v => this.lyy.is.boolean(v), {});
608
- }
609
- /** @inheritDoc */
610
- booleanOptional(value, opt) {
611
- this._optional(value, () => this.boolean(value, opt));
612
- }
613
- /** @inheritDoc */
614
- booleanArray(value, opt) {
615
- this._array(value, opt, 'invalid.boolean.array', (v) => this.lyy.is.boolean(v));
616
- }
617
- // endregion boolean
618
- // region enum
619
- /** @inheritDoc */
620
- enum(value, map, opt) {
621
- this._is(value, opt, 'invalid.enum', v => this.lyy.is.enumeration(v, map), {});
622
- }
623
- /** @inheritDoc */
624
- enumOptional(value, map, opt) {
625
- this._optional(value, () => this.enum(value, map, opt));
626
- }
627
- /** @inheritDoc */
628
- enumArray(value, map, opt) {
629
- this._array(value, opt, 'invalid.enum.array', (v) => this.lyy.is.enumeration(v, map));
630
- }
631
- // endregion enum
632
- // region literal
633
- /** @inheritDoc */
634
- literal(value, items, opt) {
635
- this._is(value, opt, 'invalid.literal', v => this.lyy.is.literal(v, items), {});
636
- }
637
- /** @inheritDoc */
638
- literalOptional(value, items, opt) {
639
- this._optional(value, () => this.literal(value, items, opt));
640
- }
641
- /** @inheritDoc */
642
- literalArray(value, items, opt) {
643
- this._array(value, opt, 'invalid.literal.array', (v) => this.lyy.is.literal(v, items));
644
- }
645
- // endregion literal
646
- // region secure
647
- /** @inheritDoc */
648
- get $back() {
649
- return this;
650
- }
651
- /** @inheritDoc */
652
- $init() {
653
- this.lyy.$secure.$lazyRun(() => {
654
- this.lyy.fqn.register(null, AssertionCommon, 'class', internal_1.FQN);
655
- });
656
- }
657
- /** @inheritDoc */
658
- get $secure() {
659
- return this;
660
- }
661
- }
662
- exports.AssertionCommon = AssertionCommon;
663
- //# sourceMappingURL=assertion.common.js.map