@naturalcycles/js-lib 14.276.0 → 15.0.0

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 (353) hide show
  1. package/cfg/frontend/tsconfig.json +3 -3
  2. package/dist/abort.js +1 -4
  3. package/dist/array/array.util.d.ts +1 -1
  4. package/dist/array/array.util.js +47 -88
  5. package/dist/array/range.d.ts +2 -2
  6. package/dist/array/range.js +7 -12
  7. package/dist/bot.js +6 -10
  8. package/dist/browser/adminService.d.ts +1 -1
  9. package/dist/browser/adminService.js +10 -14
  10. package/dist/browser/analytics.util.js +10 -15
  11. package/dist/browser/i18n/fetchTranslationLoader.d.ts +3 -3
  12. package/dist/browser/i18n/fetchTranslationLoader.js +1 -5
  13. package/dist/browser/i18n/translation.service.d.ts +1 -1
  14. package/dist/browser/i18n/translation.service.js +5 -10
  15. package/dist/browser/imageFitter.js +1 -5
  16. package/dist/browser/script.util.js +8 -12
  17. package/dist/browser/topbar.js +7 -10
  18. package/dist/datetime/dateInterval.d.ts +2 -2
  19. package/dist/datetime/dateInterval.js +7 -11
  20. package/dist/datetime/localDate.d.ts +3 -3
  21. package/dist/datetime/localDate.js +40 -44
  22. package/dist/datetime/localTime.d.ts +3 -3
  23. package/dist/datetime/localTime.js +36 -40
  24. package/dist/datetime/timeInterval.d.ts +2 -2
  25. package/dist/datetime/timeInterval.js +6 -10
  26. package/dist/datetime/wallTime.d.ts +3 -3
  27. package/dist/datetime/wallTime.js +5 -9
  28. package/dist/decorators/asyncMemo.decorator.d.ts +3 -3
  29. package/dist/decorators/asyncMemo.decorator.js +12 -17
  30. package/dist/decorators/createPromiseDecorator.js +3 -6
  31. package/dist/decorators/debounce.d.ts +1 -1
  32. package/dist/decorators/debounce.decorator.d.ts +1 -1
  33. package/dist/decorators/debounce.decorator.js +5 -9
  34. package/dist/decorators/debounce.js +2 -6
  35. package/dist/decorators/decorator.util.d.ts +1 -1
  36. package/dist/decorators/decorator.util.js +3 -8
  37. package/dist/decorators/logMethod.decorator.d.ts +1 -1
  38. package/dist/decorators/logMethod.decorator.js +11 -14
  39. package/dist/decorators/memo.decorator.d.ts +3 -3
  40. package/dist/decorators/memo.decorator.js +11 -16
  41. package/dist/decorators/memo.util.d.ts +2 -2
  42. package/dist/decorators/memo.util.js +11 -17
  43. package/dist/decorators/memoFn.d.ts +3 -3
  44. package/dist/decorators/memoFn.js +3 -6
  45. package/dist/decorators/memoFnAsync.d.ts +3 -3
  46. package/dist/decorators/memoFnAsync.js +5 -8
  47. package/dist/decorators/memoSimple.decorator.d.ts +1 -1
  48. package/dist/decorators/memoSimple.decorator.js +6 -10
  49. package/dist/decorators/retry.decorator.d.ts +1 -1
  50. package/dist/decorators/retry.decorator.js +3 -6
  51. package/dist/decorators/swarmSafe.decorator.js +3 -7
  52. package/dist/decorators/timeout.decorator.d.ts +1 -1
  53. package/dist/decorators/timeout.decorator.js +7 -10
  54. package/dist/define.d.ts +1 -1
  55. package/dist/define.js +11 -19
  56. package/dist/deviceIdService.js +7 -11
  57. package/dist/enum.util.d.ts +1 -1
  58. package/dist/enum.util.js +20 -42
  59. package/dist/env/buildInfo.d.ts +1 -1
  60. package/dist/env/buildInfo.js +3 -6
  61. package/dist/env.js +2 -6
  62. package/dist/error/assert.d.ts +3 -3
  63. package/dist/error/assert.js +30 -44
  64. package/dist/error/error.model.d.ts +2 -2
  65. package/dist/error/error.model.js +1 -2
  66. package/dist/error/error.util.d.ts +1 -1
  67. package/dist/error/error.util.js +25 -44
  68. package/dist/error/errorMode.js +2 -5
  69. package/dist/error/try.d.ts +2 -2
  70. package/dist/error/try.js +15 -23
  71. package/dist/error/tryCatch.d.ts +2 -2
  72. package/dist/error/tryCatch.js +6 -11
  73. package/dist/form.util.d.ts +1 -1
  74. package/dist/form.util.js +2 -6
  75. package/dist/http/fetcher.d.ts +3 -3
  76. package/dist/http/fetcher.js +48 -53
  77. package/dist/http/fetcher.model.d.ts +5 -5
  78. package/dist/http/fetcher.model.js +1 -2
  79. package/dist/http/http.model.js +1 -4
  80. package/dist/index.d.ts +96 -96
  81. package/dist/index.js +96 -99
  82. package/dist/is.util.d.ts +2 -2
  83. package/dist/is.util.js +12 -27
  84. package/dist/iter/asyncIterable2.d.ts +3 -3
  85. package/dist/iter/asyncIterable2.js +8 -12
  86. package/dist/iter/iterable2.d.ts +2 -2
  87. package/dist/iter/iterable2.js +8 -12
  88. package/dist/json-schema/from-data/generateJsonSchemaFromData.d.ts +1 -1
  89. package/dist/json-schema/from-data/generateJsonSchemaFromData.js +4 -7
  90. package/dist/json-schema/jsonSchema.cnst.d.ts +1 -1
  91. package/dist/json-schema/jsonSchema.cnst.js +1 -4
  92. package/dist/json-schema/jsonSchema.model.d.ts +1 -1
  93. package/dist/json-schema/jsonSchema.model.js +1 -2
  94. package/dist/json-schema/jsonSchema.util.d.ts +2 -2
  95. package/dist/json-schema/jsonSchema.util.js +5 -8
  96. package/dist/json-schema/jsonSchemaBuilder.d.ts +2 -2
  97. package/dist/json-schema/jsonSchemaBuilder.js +16 -25
  98. package/dist/json-schema/jsonSchemas.d.ts +2 -2
  99. package/dist/json-schema/jsonSchemas.js +5 -8
  100. package/dist/log/commonLogger.js +14 -21
  101. package/dist/math/accumulatingAverage.js +1 -5
  102. package/dist/math/math.util.js +11 -19
  103. package/dist/math/sma.js +1 -5
  104. package/dist/math/stack.util.js +11 -16
  105. package/dist/nanoid.js +2 -6
  106. package/dist/number/createDeterministicRandom.js +1 -4
  107. package/dist/number/number.util.d.ts +1 -1
  108. package/dist/number/number.util.js +9 -20
  109. package/dist/object/deepEquals.js +3 -8
  110. package/dist/object/map2.js +1 -5
  111. package/dist/object/object.util.d.ts +2 -2
  112. package/dist/object/object.util.js +40 -70
  113. package/dist/object/set2.js +1 -5
  114. package/dist/object/sortObject.d.ts +1 -1
  115. package/dist/object/sortObject.js +1 -4
  116. package/dist/object/sortObjectDeep.js +1 -4
  117. package/dist/polyfill.js +1 -4
  118. package/dist/promise/abortable.d.ts +1 -1
  119. package/dist/promise/abortable.js +2 -7
  120. package/dist/promise/pDefer.js +1 -4
  121. package/dist/promise/pDelay.d.ts +2 -2
  122. package/dist/promise/pDelay.js +4 -8
  123. package/dist/promise/pFilter.d.ts +1 -1
  124. package/dist/promise/pFilter.js +1 -4
  125. package/dist/promise/pHang.js +1 -4
  126. package/dist/promise/pMap.d.ts +2 -2
  127. package/dist/promise/pMap.js +17 -20
  128. package/dist/promise/pProps.js +1 -4
  129. package/dist/promise/pQueue.d.ts +2 -2
  130. package/dist/promise/pQueue.js +7 -11
  131. package/dist/promise/pRetry.d.ts +1 -1
  132. package/dist/promise/pRetry.js +8 -12
  133. package/dist/promise/pState.js +1 -4
  134. package/dist/promise/pTimeout.d.ts +3 -3
  135. package/dist/promise/pTimeout.js +7 -11
  136. package/dist/semver.d.ts +1 -1
  137. package/dist/semver.js +13 -18
  138. package/dist/string/case.js +9 -14
  139. package/dist/string/escape.js +2 -6
  140. package/dist/string/hash.util.d.ts +1 -1
  141. package/dist/string/hash.util.js +4 -10
  142. package/dist/string/json.util.d.ts +1 -1
  143. package/dist/string/json.util.js +5 -10
  144. package/dist/string/leven.js +1 -4
  145. package/dist/string/lodash/unicodeWords.js +1 -4
  146. package/dist/string/lodash/words.js +3 -6
  147. package/dist/string/pupa.d.ts +1 -1
  148. package/dist/string/pupa.js +4 -9
  149. package/dist/string/readingTime.d.ts +1 -1
  150. package/dist/string/readingTime.js +1 -4
  151. package/dist/string/regex.js +1 -4
  152. package/dist/string/safeJsonStringify.d.ts +1 -1
  153. package/dist/string/safeJsonStringify.js +1 -4
  154. package/dist/string/slugify.js +1 -4
  155. package/dist/string/string.util.js +15 -32
  156. package/dist/string/stringify.d.ts +1 -1
  157. package/dist/string/stringify.js +10 -14
  158. package/dist/string/url.util.d.ts +1 -1
  159. package/dist/string/url.util.js +2 -6
  160. package/dist/time/time.util.d.ts +1 -1
  161. package/dist/time/time.util.js +3 -8
  162. package/dist/typeFest.js +1 -2
  163. package/dist/types.d.ts +7 -3
  164. package/dist/types.js +21 -23
  165. package/dist/unit/size.util.js +5 -12
  166. package/dist/web.d.ts +1 -1
  167. package/dist/web.js +1 -5
  168. package/dist/zod/index.d.ts +2 -2
  169. package/dist/zod/index.js +4 -10
  170. package/dist/zod/zod.shared.schemas.js +36 -39
  171. package/dist/zod/zod.util.js +7 -14
  172. package/package.json +7 -8
  173. package/src/array/array.util.ts +3 -3
  174. package/src/array/range.ts +2 -2
  175. package/src/bot.ts +1 -1
  176. package/src/browser/adminService.ts +4 -4
  177. package/src/browser/analytics.util.ts +1 -1
  178. package/src/browser/i18n/fetchTranslationLoader.ts +3 -3
  179. package/src/browser/i18n/translation.service.ts +2 -2
  180. package/src/browser/script.util.ts +2 -2
  181. package/src/datetime/dateInterval.ts +3 -3
  182. package/src/datetime/localDate.ts +5 -5
  183. package/src/datetime/localTime.ts +6 -6
  184. package/src/datetime/timeInterval.ts +3 -3
  185. package/src/datetime/wallTime.ts +4 -4
  186. package/src/decorators/asyncMemo.decorator.ts +7 -7
  187. package/src/decorators/createPromiseDecorator.ts +1 -1
  188. package/src/decorators/debounce.decorator.ts +2 -2
  189. package/src/decorators/debounce.ts +1 -1
  190. package/src/decorators/decorator.util.ts +1 -1
  191. package/src/decorators/logMethod.decorator.ts +4 -4
  192. package/src/decorators/memo.decorator.ts +7 -7
  193. package/src/decorators/memo.util.ts +4 -4
  194. package/src/decorators/memoFn.ts +4 -4
  195. package/src/decorators/memoFnAsync.ts +5 -5
  196. package/src/decorators/memoSimple.decorator.ts +4 -4
  197. package/src/decorators/retry.decorator.ts +2 -2
  198. package/src/decorators/swarmSafe.decorator.ts +2 -2
  199. package/src/decorators/timeout.decorator.ts +4 -4
  200. package/src/define.ts +3 -3
  201. package/src/deviceIdService.ts +3 -3
  202. package/src/enum.util.ts +1 -1
  203. package/src/env/buildInfo.ts +2 -2
  204. package/src/error/assert.ts +7 -7
  205. package/src/error/error.model.ts +2 -2
  206. package/src/error/error.util.ts +5 -5
  207. package/src/error/try.ts +5 -5
  208. package/src/error/tryCatch.ts +3 -3
  209. package/src/form.util.ts +1 -1
  210. package/src/http/fetcher.model.ts +5 -5
  211. package/src/http/fetcher.ts +20 -15
  212. package/src/index.ts +96 -96
  213. package/src/is.util.ts +2 -2
  214. package/src/iter/asyncIterable2.ts +3 -3
  215. package/src/iter/iterable2.ts +2 -2
  216. package/src/json-schema/from-data/generateJsonSchemaFromData.ts +2 -2
  217. package/src/json-schema/jsonSchema.cnst.ts +1 -1
  218. package/src/json-schema/jsonSchema.model.ts +1 -1
  219. package/src/json-schema/jsonSchema.util.ts +4 -4
  220. package/src/json-schema/jsonSchemaBuilder.ts +5 -5
  221. package/src/json-schema/jsonSchemas.ts +2 -2
  222. package/src/math/math.util.ts +2 -2
  223. package/src/math/stack.util.ts +1 -1
  224. package/src/number/number.util.ts +1 -1
  225. package/src/object/object.util.ts +3 -3
  226. package/src/object/sortObject.ts +1 -1
  227. package/src/promise/abortable.ts +1 -1
  228. package/src/promise/pDelay.ts +3 -3
  229. package/src/promise/pFilter.ts +1 -1
  230. package/src/promise/pMap.ts +2 -2
  231. package/src/promise/pQueue.ts +4 -4
  232. package/src/promise/pRetry.ts +2 -2
  233. package/src/promise/pTimeout.ts +4 -4
  234. package/src/semver.ts +3 -3
  235. package/src/string/case.ts +2 -2
  236. package/src/string/hash.util.ts +1 -1
  237. package/src/string/json.util.ts +2 -2
  238. package/src/string/lodash/words.ts +1 -1
  239. package/src/string/pupa.ts +2 -2
  240. package/src/string/readingTime.ts +1 -1
  241. package/src/string/safeJsonStringify.ts +1 -1
  242. package/src/string/stringify.ts +4 -4
  243. package/src/string/url.util.ts +1 -1
  244. package/src/time/time.util.ts +1 -1
  245. package/src/types.ts +15 -3
  246. package/src/web.ts +1 -1
  247. package/src/zod/index.ts +2 -2
  248. package/src/zod/zod.util.ts +1 -1
  249. package/dist-esm/abort.js +0 -12
  250. package/dist-esm/array/array.util.js +0 -458
  251. package/dist-esm/array/range.js +0 -34
  252. package/dist-esm/bot.js +0 -130
  253. package/dist-esm/browser/adminService.js +0 -94
  254. package/dist-esm/browser/analytics.util.js +0 -54
  255. package/dist-esm/browser/i18n/fetchTranslationLoader.js +0 -13
  256. package/dist-esm/browser/i18n/translation.service.js +0 -56
  257. package/dist-esm/browser/imageFitter.js +0 -65
  258. package/dist-esm/browser/script.util.js +0 -46
  259. package/dist-esm/browser/topbar.js +0 -135
  260. package/dist-esm/datetime/dateInterval.js +0 -80
  261. package/dist-esm/datetime/localDate.js +0 -719
  262. package/dist-esm/datetime/localTime.js +0 -996
  263. package/dist-esm/datetime/timeInterval.js +0 -88
  264. package/dist-esm/datetime/wallTime.js +0 -70
  265. package/dist-esm/decorators/asyncMemo.decorator.js +0 -111
  266. package/dist-esm/decorators/createPromiseDecorator.js +0 -82
  267. package/dist-esm/decorators/debounce.decorator.js +0 -17
  268. package/dist-esm/decorators/debounce.js +0 -114
  269. package/dist-esm/decorators/decorator.util.js +0 -31
  270. package/dist-esm/decorators/logMethod.decorator.js +0 -85
  271. package/dist-esm/decorators/memo.decorator.js +0 -80
  272. package/dist-esm/decorators/memo.util.js +0 -97
  273. package/dist-esm/decorators/memoFn.js +0 -29
  274. package/dist-esm/decorators/memoFnAsync.js +0 -35
  275. package/dist-esm/decorators/memoSimple.decorator.js +0 -55
  276. package/dist-esm/decorators/retry.decorator.js +0 -9
  277. package/dist-esm/decorators/swarmSafe.decorator.js +0 -38
  278. package/dist-esm/decorators/timeout.decorator.js +0 -19
  279. package/dist-esm/define.js +0 -109
  280. package/dist-esm/deviceIdService.js +0 -105
  281. package/dist-esm/enum.util.js +0 -157
  282. package/dist-esm/env/buildInfo.js +0 -19
  283. package/dist-esm/env.js +0 -19
  284. package/dist-esm/error/assert.js +0 -122
  285. package/dist-esm/error/error.model.js +0 -1
  286. package/dist-esm/error/error.util.js +0 -337
  287. package/dist-esm/error/errorMode.js +0 -20
  288. package/dist-esm/error/try.js +0 -105
  289. package/dist-esm/error/tryCatch.js +0 -41
  290. package/dist-esm/form.util.js +0 -16
  291. package/dist-esm/http/fetcher.js +0 -704
  292. package/dist-esm/http/fetcher.model.js +0 -3
  293. package/dist-esm/http/http.model.js +0 -1
  294. package/dist-esm/index.js +0 -96
  295. package/dist-esm/is.util.js +0 -70
  296. package/dist-esm/iter/asyncIterable2.js +0 -103
  297. package/dist-esm/iter/iterable2.js +0 -87
  298. package/dist-esm/json-schema/from-data/generateJsonSchemaFromData.js +0 -86
  299. package/dist-esm/json-schema/jsonSchema.cnst.js +0 -38
  300. package/dist-esm/json-schema/jsonSchema.model.js +0 -1
  301. package/dist-esm/json-schema/jsonSchema.util.js +0 -27
  302. package/dist-esm/json-schema/jsonSchemaBuilder.js +0 -352
  303. package/dist-esm/json-schema/jsonSchemas.js +0 -6
  304. package/dist-esm/log/commonLogger.js +0 -78
  305. package/dist-esm/math/accumulatingAverage.js +0 -32
  306. package/dist-esm/math/math.util.js +0 -85
  307. package/dist-esm/math/sma.js +0 -43
  308. package/dist-esm/math/stack.util.js +0 -82
  309. package/dist-esm/nanoid.js +0 -57
  310. package/dist-esm/number/createDeterministicRandom.js +0 -18
  311. package/dist-esm/number/number.util.js +0 -109
  312. package/dist-esm/object/deepEquals.js +0 -170
  313. package/dist-esm/object/map2.js +0 -21
  314. package/dist-esm/object/object.util.js +0 -435
  315. package/dist-esm/object/set2.js +0 -15
  316. package/dist-esm/object/sortObject.js +0 -21
  317. package/dist-esm/object/sortObjectDeep.js +0 -17
  318. package/dist-esm/polyfill.js +0 -6
  319. package/dist-esm/promise/abortable.js +0 -31
  320. package/dist-esm/promise/pDefer.js +0 -17
  321. package/dist-esm/promise/pDelay.js +0 -37
  322. package/dist-esm/promise/pFilter.js +0 -5
  323. package/dist-esm/promise/pHang.js +0 -6
  324. package/dist-esm/promise/pMap.js +0 -174
  325. package/dist-esm/promise/pProps.js +0 -20
  326. package/dist-esm/promise/pQueue.js +0 -101
  327. package/dist-esm/promise/pRetry.js +0 -64
  328. package/dist-esm/promise/pState.js +0 -14
  329. package/dist-esm/promise/pTimeout.js +0 -64
  330. package/dist-esm/semver.js +0 -149
  331. package/dist-esm/string/case.js +0 -24
  332. package/dist-esm/string/escape.js +0 -49
  333. package/dist-esm/string/hash.util.js +0 -67
  334. package/dist-esm/string/json.util.js +0 -46
  335. package/dist-esm/string/leven.js +0 -77
  336. package/dist-esm/string/lodash/unicodeWords.js +0 -68
  337. package/dist-esm/string/lodash/words.js +0 -31
  338. package/dist-esm/string/pupa.js +0 -54
  339. package/dist-esm/string/readingTime.js +0 -102
  340. package/dist-esm/string/regex.js +0 -6
  341. package/dist-esm/string/safeJsonStringify.js +0 -39
  342. package/dist-esm/string/slugify.js +0 -66
  343. package/dist-esm/string/string.util.js +0 -99
  344. package/dist-esm/string/stringify.js +0 -133
  345. package/dist-esm/string/url.util.js +0 -42
  346. package/dist-esm/time/time.util.js +0 -61
  347. package/dist-esm/typeFest.js +0 -2
  348. package/dist-esm/types.js +0 -59
  349. package/dist-esm/unit/size.util.js +0 -43
  350. package/dist-esm/web.js +0 -40
  351. package/dist-esm/zod/index.js +0 -4
  352. package/dist-esm/zod/zod.shared.schemas.js +0 -92
  353. package/dist-esm/zod/zod.util.js +0 -52
package/dist/enum.util.js CHANGED
@@ -1,47 +1,25 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._numberEnumKeys = _numberEnumKeys;
4
- exports._numberEnumValues = _numberEnumValues;
5
- exports._stringEnumKeys = _stringEnumKeys;
6
- exports._stringEnumValues = _stringEnumValues;
7
- exports._numberEnumEntries = _numberEnumEntries;
8
- exports._numberEnumEntriesReversed = _numberEnumEntriesReversed;
9
- exports._numberEnumAsMap = _numberEnumAsMap;
10
- exports._numberEnumAsMapReversed = _numberEnumAsMapReversed;
11
- exports._stringEnumEntries = _stringEnumEntries;
12
- exports._stringEnumEntriesReversed = _stringEnumEntriesReversed;
13
- exports._stringEnumAsMap = _stringEnumAsMap;
14
- exports._stringEnumAsMapReversed = _stringEnumAsMapReversed;
15
- exports._numberEnumValue = _numberEnumValue;
16
- exports._numberEnumValueOrUndefined = _numberEnumValueOrUndefined;
17
- exports._numberEnumNormalize = _numberEnumNormalize;
18
- exports._numberEnumNormalizeOrUndefined = _numberEnumNormalizeOrUndefined;
19
- exports._numberEnumKeyOrUndefined = _numberEnumKeyOrUndefined;
20
- exports._numberEnumKey = _numberEnumKey;
21
- exports._stringEnumKeyOrUndefined = _stringEnumKeyOrUndefined;
22
- exports._stringEnumKey = _stringEnumKey;
23
1
  /**
24
2
  * Returns all String keys of a number-enum.
25
3
  */
26
- function _numberEnumKeys(en) {
4
+ export function _numberEnumKeys(en) {
27
5
  return Object.values(en).filter(k => typeof k === 'string');
28
6
  }
29
7
  /**
30
8
  * Returns all Number values of a number-enum.
31
9
  */
32
- function _numberEnumValues(en) {
10
+ export function _numberEnumValues(en) {
33
11
  return Object.values(en).filter(k => typeof k === 'number');
34
12
  }
35
13
  /**
36
14
  * Returns all String keys of a string-enum.
37
15
  */
38
- function _stringEnumKeys(en) {
16
+ export function _stringEnumKeys(en) {
39
17
  return Object.keys(en);
40
18
  }
41
19
  /**
42
20
  * Returns all String values of a string-enum.
43
21
  */
44
- function _stringEnumValues(en) {
22
+ export function _stringEnumValues(en) {
45
23
  // filtering here is unnecessary, but works as a safety in case Number-enum is passed
46
24
  return Object.values(en).filter(k => typeof k === 'string');
47
25
  }
@@ -51,7 +29,7 @@ function _stringEnumValues(en) {
51
29
  *
52
30
  * Doesn't work on String-enums!
53
31
  */
54
- function _numberEnumEntries(en) {
32
+ export function _numberEnumEntries(en) {
55
33
  return Object.values(en)
56
34
  .filter(k => typeof k === 'string')
57
35
  .map(k => [k, en[k]]);
@@ -60,7 +38,7 @@ function _numberEnumEntries(en) {
60
38
  * Like _numberEnumEntries, but reversed.
61
39
  * So, keys are Numbers, values are Strings.
62
40
  */
63
- function _numberEnumEntriesReversed(en) {
41
+ export function _numberEnumEntriesReversed(en) {
64
42
  return Object.values(en)
65
43
  .filter(k => typeof k === 'string')
66
44
  .map(k => [en[k], k]);
@@ -69,7 +47,7 @@ function _numberEnumEntriesReversed(en) {
69
47
  * Like _numberEnumEntries, but as a Map.
70
48
  * Keys are Strings, values are Numbers.
71
49
  */
72
- function _numberEnumAsMap(en) {
50
+ export function _numberEnumAsMap(en) {
73
51
  return new Map(Object.values(en)
74
52
  .filter(k => typeof k === 'string')
75
53
  .map(k => [k, en[k]]));
@@ -78,7 +56,7 @@ function _numberEnumAsMap(en) {
78
56
  * Like _numberEnumEntriesReversed, but as a Map.
79
57
  * Keys are Numbers (actual Numbers, because it's a Map, not an Object), values are Strings.
80
58
  */
81
- function _numberEnumAsMapReversed(en) {
59
+ export function _numberEnumAsMapReversed(en) {
82
60
  return new Map(Object.values(en)
83
61
  .filter(k => typeof k === 'string')
84
62
  .map(k => [en[k], k]));
@@ -89,25 +67,25 @@ function _numberEnumAsMapReversed(en) {
89
67
  *
90
68
  * Doesn't work on Number-enums!
91
69
  */
92
- function _stringEnumEntries(en) {
70
+ export function _stringEnumEntries(en) {
93
71
  return Object.entries(en);
94
72
  }
95
73
  /**
96
74
  * Like _stringEnumEntries, but keys and values are reversed.
97
75
  */
98
- function _stringEnumEntriesReversed(en) {
76
+ export function _stringEnumEntriesReversed(en) {
99
77
  return Object.entries(en).map(([k, v]) => [v, k]);
100
78
  }
101
79
  /**
102
80
  * Return String enum as Map (with the same keys and values).
103
81
  */
104
- function _stringEnumAsMap(en) {
82
+ export function _stringEnumAsMap(en) {
105
83
  return new Map(Object.entries(en));
106
84
  }
107
85
  /**
108
86
  * Return String enum as Map, with keys and values reversed.
109
87
  */
110
- function _stringEnumAsMapReversed(en) {
88
+ export function _stringEnumAsMapReversed(en) {
111
89
  return new Map(Object.entries(en).map(([k, v]) => [v, k]));
112
90
  }
113
91
  /**
@@ -118,7 +96,7 @@ function _stringEnumAsMapReversed(en) {
118
96
  *
119
97
  * Throws if value is not found!
120
98
  */
121
- function _numberEnumValue(en, k) {
99
+ export function _numberEnumValue(en, k) {
122
100
  const r = en[k];
123
101
  if (!r)
124
102
  throw new Error(`_numberEnumValue not found for: ${k}`);
@@ -127,7 +105,7 @@ function _numberEnumValue(en, k) {
127
105
  /**
128
106
  * _numberEnumKey, but allows to get/return undefined output.
129
107
  */
130
- function _numberEnumValueOrUndefined(en, k) {
108
+ export function _numberEnumValueOrUndefined(en, k) {
131
109
  return en[k];
132
110
  }
133
111
  /**
@@ -136,7 +114,7 @@ function _numberEnumValueOrUndefined(en, k) {
136
114
  *
137
115
  * Throws if value is not found!
138
116
  */
139
- function _numberEnumNormalize(en, v) {
117
+ export function _numberEnumNormalize(en, v) {
140
118
  const r = _numberEnumNormalizeOrUndefined(en, v);
141
119
  if (!r || !en[r])
142
120
  throw new Error(`_numberEnumNormalize value not found for: ${v}`);
@@ -145,13 +123,13 @@ function _numberEnumNormalize(en, v) {
145
123
  /**
146
124
  * Same as _numberEnumNormalize, but allows to return undefined values.
147
125
  */
148
- function _numberEnumNormalizeOrUndefined(en, v) {
126
+ export function _numberEnumNormalizeOrUndefined(en, v) {
149
127
  return typeof v === 'string' ? en[v] : v;
150
128
  }
151
129
  /**
152
130
  * Returns a String key for given NumberEnum value, or undefined if not found.
153
131
  */
154
- function _numberEnumKeyOrUndefined(en, v) {
132
+ export function _numberEnumKeyOrUndefined(en, v) {
155
133
  const key = en[v];
156
134
  // This prevents passing a Key (not a Value) of enum here, which returns unexpected result (number, not string)
157
135
  return typeof key === 'string' ? key : undefined;
@@ -159,19 +137,19 @@ function _numberEnumKeyOrUndefined(en, v) {
159
137
  /**
160
138
  * Returns a String key for given NumberEnum value, throws if not found.
161
139
  */
162
- function _numberEnumKey(en, v) {
140
+ export function _numberEnumKey(en, v) {
163
141
  const key = en[v];
164
142
  // This prevents passing a Key (not a Value) of enum here, which returns unexpected result (number, not string)
165
143
  if (typeof key !== 'string')
166
144
  throw new Error(`_numberEnumKey not found for: ${v}`);
167
145
  return key;
168
146
  }
169
- function _stringEnumKeyOrUndefined(en,
147
+ export function _stringEnumKeyOrUndefined(en,
170
148
  // v: T[keyof T] | undefined | null, // cannot make it type-safe :(
171
149
  v) {
172
150
  return Object.entries(en).find(([_, v2]) => v2 === v)?.[0];
173
151
  }
174
- function _stringEnumKey(en, v) {
152
+ export function _stringEnumKey(en, v) {
175
153
  const r = _stringEnumKeyOrUndefined(en, v);
176
154
  if (!r)
177
155
  throw new Error(`_stringEnumKey not found for: ${v}`);
@@ -1,4 +1,4 @@
1
- import type { UnixTimestamp } from '../types';
1
+ import type { UnixTimestamp } from '../types.js';
2
2
  export interface BuildInfo {
3
3
  /**
4
4
  * Unix timestamp of when the build was made.
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateBuildInfoDev = generateBuildInfoDev;
4
- const localTime_1 = require("../datetime/localTime");
5
- function generateBuildInfoDev() {
6
- const now = localTime_1.localTime.now();
1
+ import { localTime } from '../datetime/localTime.js';
2
+ export function generateBuildInfoDev() {
3
+ const now = localTime.now();
7
4
  const ts = now.unix;
8
5
  const rev = 'devRev';
9
6
  const branchName = 'devBranch';
package/dist/env.js CHANGED
@@ -1,14 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isServerSide = isServerSide;
4
- exports.isClientSide = isClientSide;
5
1
  /**
6
2
  * Use it to detect SSR/Node.js environment.
7
3
  *
8
4
  * Will return `true` in Node.js.
9
5
  * Will return `false` in the Browser.
10
6
  */
11
- function isServerSide() {
7
+ export function isServerSide() {
12
8
  return !isClientSide();
13
9
  }
14
10
  /**
@@ -17,7 +13,7 @@ function isServerSide() {
17
13
  * Will return `true` in the Browser.
18
14
  * Will return `false` in Node.js.
19
15
  */
20
- function isClientSide() {
16
+ export function isClientSide() {
21
17
  // eslint-disable-next-line unicorn/prefer-global-this
22
18
  return typeof window !== 'undefined' && !!window?.document;
23
19
  }
@@ -1,6 +1,6 @@
1
- import type { Class } from '../typeFest';
2
- import type { UnixTimestamp } from '../types';
3
- import type { BackendErrorResponseObject, ErrorData, ErrorObject } from './error.model';
1
+ import type { Class } from '../typeFest.js';
2
+ import type { UnixTimestamp } from '../types.js';
3
+ import type { BackendErrorResponseObject, ErrorData, ErrorObject } from './error.model.js';
4
4
  /**
5
5
  * Evaluates the `condition` (casts it to Boolean).
6
6
  * Expects it to be truthy, otherwise throws AppError.
@@ -1,21 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports._assert = _assert;
4
- exports._assertEquals = _assertEquals;
5
- exports._assertDeepEquals = _assertDeepEquals;
6
- exports._assertIsError = _assertIsError;
7
- exports._assertErrorClassOrRethrow = _assertErrorClassOrRethrow;
8
- exports._assertIsErrorObject = _assertIsErrorObject;
9
- exports._assertIsBackendErrorResponseObject = _assertIsBackendErrorResponseObject;
10
- exports._assertIsString = _assertIsString;
11
- exports._assertIsNumber = _assertIsNumber;
12
- exports._assertTypeOf = _assertTypeOf;
13
- exports.asUnixTimestamp = asUnixTimestamp;
14
- exports.asUnixTimestamp2000 = asUnixTimestamp2000;
15
- const deepEquals_1 = require("../object/deepEquals");
16
- const stringify_1 = require("../string/stringify");
17
- const zod_shared_schemas_1 = require("../zod/zod.shared.schemas");
18
- const error_util_1 = require("./error.util");
1
+ import { _deepEquals } from '../object/deepEquals.js';
2
+ import { _stringify } from '../string/stringify.js';
3
+ import { TS_2000, TS_2500 } from '../zod/zod.shared.schemas.js';
4
+ import { _isBackendErrorResponseObject, _isErrorObject, AssertionError } from './error.util.js';
19
5
  /**
20
6
  * Evaluates the `condition` (casts it to Boolean).
21
7
  * Expects it to be truthy, otherwise throws AppError.
@@ -32,10 +18,10 @@ const error_util_1 = require("./error.util");
32
18
  *
33
19
  * Since 2024-07-10 it no longer sets `userFriendly: true` by default.
34
20
  */
35
- function _assert(condition, // will be evaluated as Boolean
21
+ export function _assert(condition, // will be evaluated as Boolean
36
22
  message, errorData) {
37
23
  if (!condition) {
38
- throw new error_util_1.AssertionError(message || 'condition failed', {
24
+ throw new AssertionError(message || 'condition failed', {
39
25
  ...errorData,
40
26
  });
41
27
  }
@@ -46,13 +32,13 @@ message, errorData) {
46
32
  *
47
33
  * Does SHALLOW, but strict equality (===), use _assertDeepEquals() for deep equality.
48
34
  */
49
- function _assertEquals(actual, expected, message, errorData) {
35
+ export function _assertEquals(actual, expected, message, errorData) {
50
36
  if (actual !== expected) {
51
37
  const msg = message ||
52
- ['not equal', `expected: ${(0, stringify_1._stringify)(expected)}`, `got : ${(0, stringify_1._stringify)(actual)}`]
38
+ ['not equal', `expected: ${_stringify(expected)}`, `got : ${_stringify(actual)}`]
53
39
  .filter(Boolean)
54
40
  .join('\n');
55
- throw new error_util_1.AssertionError(msg, {
41
+ throw new AssertionError(msg, {
56
42
  ...errorData,
57
43
  });
58
44
  }
@@ -63,20 +49,20 @@ function _assertEquals(actual, expected, message, errorData) {
63
49
  *
64
50
  * Does DEEP equality via _deepEquals()
65
51
  */
66
- function _assertDeepEquals(actual, expected, message, errorData) {
67
- if (!(0, deepEquals_1._deepEquals)(actual, expected)) {
52
+ export function _assertDeepEquals(actual, expected, message, errorData) {
53
+ if (!_deepEquals(actual, expected)) {
68
54
  const msg = message ||
69
- ['not deeply equal', `expected: ${(0, stringify_1._stringify)(expected)}`, `got : ${(0, stringify_1._stringify)(actual)}`]
55
+ ['not deeply equal', `expected: ${_stringify(expected)}`, `got : ${_stringify(actual)}`]
70
56
  .filter(Boolean)
71
57
  .join('\n');
72
- throw new error_util_1.AssertionError(msg, {
58
+ throw new AssertionError(msg, {
73
59
  ...errorData,
74
60
  });
75
61
  }
76
62
  }
77
- function _assertIsError(err, errorClass = Error) {
63
+ export function _assertIsError(err, errorClass = Error) {
78
64
  if (!(err instanceof errorClass)) {
79
- throw new error_util_1.AssertionError(`Expected to be instanceof ${errorClass.name}, actual typeof: ${typeof err}`);
65
+ throw new AssertionError(`Expected to be instanceof ${errorClass.name}, actual typeof: ${typeof err}`);
80
66
  }
81
67
  }
82
68
  /**
@@ -84,33 +70,33 @@ function _assertIsError(err, errorClass = Error) {
84
70
  * If yes - returns peacefully (with TypeScript assertion).
85
71
  * In not - throws (re-throws) that error up.
86
72
  */
87
- function _assertErrorClassOrRethrow(err, errorClass) {
73
+ export function _assertErrorClassOrRethrow(err, errorClass) {
88
74
  if (!(err instanceof errorClass)) {
89
75
  // re-throw
90
76
  throw err;
91
77
  }
92
78
  }
93
- function _assertIsErrorObject(obj) {
94
- if (!(0, error_util_1._isErrorObject)(obj)) {
95
- throw new error_util_1.AssertionError(`Expected to be ErrorObject, actual typeof: ${typeof obj}`);
79
+ export function _assertIsErrorObject(obj) {
80
+ if (!_isErrorObject(obj)) {
81
+ throw new AssertionError(`Expected to be ErrorObject, actual typeof: ${typeof obj}`);
96
82
  }
97
83
  }
98
- function _assertIsBackendErrorResponseObject(obj) {
99
- if (!(0, error_util_1._isBackendErrorResponseObject)(obj)) {
100
- throw new error_util_1.AssertionError(`Expected to be BackendErrorResponseObject, actual typeof: ${typeof obj}`);
84
+ export function _assertIsBackendErrorResponseObject(obj) {
85
+ if (!_isBackendErrorResponseObject(obj)) {
86
+ throw new AssertionError(`Expected to be BackendErrorResponseObject, actual typeof: ${typeof obj}`);
101
87
  }
102
88
  }
103
- function _assertIsString(v, message) {
89
+ export function _assertIsString(v, message) {
104
90
  _assertTypeOf(v, 'string', message);
105
91
  }
106
- function _assertIsNumber(v, message) {
92
+ export function _assertIsNumber(v, message) {
107
93
  _assertTypeOf(v, 'number', message);
108
94
  }
109
- function _assertTypeOf(v, expectedType, message) {
95
+ export function _assertTypeOf(v, expectedType, message) {
110
96
  // biome-ignore lint/suspicious/useValidTypeof: ok
111
97
  if (typeof v !== expectedType) {
112
98
  const msg = message || `Expected typeof ${expectedType}, actual typeof: ${typeof v}`;
113
- throw new error_util_1.AssertionError(msg);
99
+ throw new AssertionError(msg);
114
100
  }
115
101
  }
116
102
  /**
@@ -118,7 +104,7 @@ function _assertTypeOf(v, expectedType, message) {
118
104
  * Right now does not perform any validation (unlike `asUnixTimestamp2000`),
119
105
  * but only type casting.
120
106
  */
121
- function asUnixTimestamp(n) {
107
+ export function asUnixTimestamp(n) {
122
108
  return n;
123
109
  }
124
110
  /**
@@ -126,9 +112,9 @@ function asUnixTimestamp(n) {
126
112
  * Throws if the number is not inside 2000-01-01 and 2500-01-01 time interval,
127
113
  * which would indicate a bug.
128
114
  */
129
- function asUnixTimestamp2000(n) {
130
- if (!n || n < zod_shared_schemas_1.TS_2000 || n > zod_shared_schemas_1.TS_2500) {
131
- throw new error_util_1.AssertionError(`Number is not a valid UnixTimestamp2000: ${n}`, {
115
+ export function asUnixTimestamp2000(n) {
116
+ if (!n || n < TS_2000 || n > TS_2500) {
117
+ throw new AssertionError(`Number is not a valid UnixTimestamp2000: ${n}`, {
132
118
  fingerprint: 'asUnixTimestamp2000',
133
119
  });
134
120
  }
@@ -1,5 +1,5 @@
1
- import type { HttpMethod, HttpStatusCode } from '../http/http.model';
2
- import type { NumberOfMilliseconds } from '../types';
1
+ import type { HttpMethod, HttpStatusCode } from '../http/http.model.js';
2
+ import type { NumberOfMilliseconds } from '../types.js';
3
3
  /**
4
4
  * Extendable payload object to transfer custom additional data with AppError.
5
5
  */
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,4 +1,4 @@
1
- import type { BackendErrorResponseObject, Class, ErrorData, ErrorLike, ErrorObject, HttpRequestErrorData } from '..';
1
+ import type { BackendErrorResponseObject, Class, ErrorData, ErrorLike, ErrorObject, HttpRequestErrorData } from '../index.js';
2
2
  /**
3
3
  * Useful to ensure that error in `catch (err) { ... }`
4
4
  * is indeed an Error (and not e.g `string` or `undefined`).
@@ -1,20 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UnexpectedPassError = exports.TimeoutError = exports.JsonParseError = exports.AssertionError = exports.HttpRequestError = exports.AppError = void 0;
4
- exports._anyToError = _anyToError;
5
- exports._anyToErrorObject = _anyToErrorObject;
6
- exports._errorLikeToErrorObject = _errorLikeToErrorObject;
7
- exports._errorObjectToError = _errorObjectToError;
8
- exports._errorSnippet = _errorSnippet;
9
- exports._isBackendErrorResponseObject = _isBackendErrorResponseObject;
10
- exports._isHttpRequestErrorObject = _isHttpRequestErrorObject;
11
- exports._isErrorObject = _isErrorObject;
12
- exports._isErrorLike = _isErrorLike;
13
- exports._errorDataAppend = _errorDataAppend;
14
- const env_1 = require("../env");
15
- const json_util_1 = require("../string/json.util");
16
- const string_util_1 = require("../string/string.util");
17
- const stringify_1 = require("../string/stringify");
1
+ import { isServerSide } from '../env.js';
2
+ import { _jsonParseIfPossible } from '../string/json.util.js';
3
+ import { _truncate, _truncateMiddle } from '../string/string.util.js';
4
+ import { _stringify } from '../string/stringify.js';
18
5
  /**
19
6
  * Useful to ensure that error in `catch (err) { ... }`
20
7
  * is indeed an Error (and not e.g `string` or `undefined`).
@@ -23,7 +10,7 @@ const stringify_1 = require("../string/stringify");
23
10
  *
24
11
  * Alternatively, if you're sure it's Error - you can use `_assertIsError(err)`.
25
12
  */
26
- function _anyToError(o, errorClass = Error, errorData) {
13
+ export function _anyToError(o, errorClass = Error, errorData) {
27
14
  let e;
28
15
  if (o instanceof errorClass) {
29
16
  e = o;
@@ -48,13 +35,13 @@ function _anyToError(o, errorClass = Error, errorData) {
48
35
  * If object is Error - Error.message will be used.
49
36
  * Objects (not Errors) get converted to prettified JSON string (via `_stringify`).
50
37
  */
51
- function _anyToErrorObject(o, errorData) {
38
+ export function _anyToErrorObject(o, errorData) {
52
39
  let eo;
53
40
  if (_isErrorLike(o)) {
54
41
  eo = _errorLikeToErrorObject(o);
55
42
  }
56
43
  else {
57
- o = (0, json_util_1._jsonParseIfPossible)(o);
44
+ o = _jsonParseIfPossible(o);
58
45
  if (_isBackendErrorResponseObject(o)) {
59
46
  eo = o.error;
60
47
  }
@@ -69,7 +56,7 @@ function _anyToErrorObject(o, errorData) {
69
56
  // so, fair to return `data: {}` in the end
70
57
  // Also we're sure it includes no "error name", e.g no `Error: ...`,
71
58
  // so, fair to include `name: 'Error'`
72
- const message = (0, stringify_1._stringify)(o);
59
+ const message = _stringify(o);
73
60
  eo = {
74
61
  name: 'Error',
75
62
  message,
@@ -80,7 +67,7 @@ function _anyToErrorObject(o, errorData) {
80
67
  Object.assign(eo.data, errorData);
81
68
  return eo;
82
69
  }
83
- function _errorLikeToErrorObject(e) {
70
+ export function _errorLikeToErrorObject(e) {
84
71
  // If it's already an ErrorObject - just return it
85
72
  // AppError satisfies ErrorObject interface
86
73
  // Error does not satisfy (lacks `data`)
@@ -101,7 +88,7 @@ function _errorLikeToErrorObject(e) {
101
88
  }
102
89
  return obj;
103
90
  }
104
- function _errorObjectToError(o, errorClass = Error) {
91
+ export function _errorObjectToError(o, errorClass = Error) {
105
92
  if (o instanceof errorClass)
106
93
  return o;
107
94
  // Here we pass constructor values assuming it's AppError or sub-class of it
@@ -160,7 +147,7 @@ const commonErrorClasses = new Set([
160
147
  *
161
148
  * It's not supposed to have full information about the error, just a small extract from it.
162
149
  */
163
- function _errorSnippet(err, opt = {}) {
150
+ export function _errorSnippet(err, opt = {}) {
164
151
  const { maxLineLength = 60, maxLines = 3 } = opt;
165
152
  const e = _anyToErrorObject(err);
166
153
  const lines = [errorObjectToSnippet(e)];
@@ -169,7 +156,7 @@ function _errorSnippet(err, opt = {}) {
169
156
  lines.push('Caused by ' + errorObjectToSnippet(cause));
170
157
  cause = cause.cause; // insert DiCaprio Inception meme
171
158
  }
172
- return lines.map(line => (0, string_util_1._truncate)(line, maxLineLength)).join('\n');
159
+ return lines.map(line => _truncate(line, maxLineLength)).join('\n');
173
160
  function errorObjectToSnippet(e) {
174
161
  // Return snippet if it was already prepared
175
162
  if (e.data.snippet)
@@ -186,23 +173,23 @@ function _errorSnippet(err, opt = {}) {
186
173
  .join(': ');
187
174
  }
188
175
  }
189
- function _isBackendErrorResponseObject(o) {
176
+ export function _isBackendErrorResponseObject(o) {
190
177
  return _isErrorObject(o?.error);
191
178
  }
192
- function _isHttpRequestErrorObject(o) {
179
+ export function _isHttpRequestErrorObject(o) {
193
180
  return !!o && o.name === 'HttpRequestError' && typeof o.data?.requestUrl === 'string';
194
181
  }
195
182
  /**
196
183
  * Note: any instance of AppError is also automatically an ErrorObject
197
184
  */
198
- function _isErrorObject(o) {
185
+ export function _isErrorObject(o) {
199
186
  return (!!o &&
200
187
  typeof o === 'object' &&
201
188
  typeof o.name === 'string' &&
202
189
  typeof o.message === 'string' &&
203
190
  typeof o.data === 'object');
204
191
  }
205
- function _isErrorLike(o) {
192
+ export function _isErrorLike(o) {
206
193
  return !!o && typeof o === 'object' && typeof o.name === 'string' && typeof o.message === 'string';
207
194
  }
208
195
  /**
@@ -219,7 +206,7 @@ function _isErrorLike(o) {
219
206
  * })
220
207
  * }
221
208
  */
222
- function _errorDataAppend(err, data) {
209
+ export function _errorDataAppend(err, data) {
223
210
  if (!data)
224
211
  return err;
225
212
  err.data ||= {}; // create err.data if it doesn't exist
@@ -236,7 +223,7 @@ function _errorDataAppend(err, data) {
236
223
  *
237
224
  * Based on: https://medium.com/@xpl/javascript-deriving-from-error-properly-8d2f8f315801
238
225
  */
239
- class AppError extends Error {
226
+ export class AppError extends Error {
240
227
  data;
241
228
  /**
242
229
  * `cause` here is normalized to be an ErrorObject
@@ -255,7 +242,7 @@ class AppError extends Error {
255
242
  super(message);
256
243
  // Here we default to `this.constructor.name` on Node, but to 'AppError' on the Frontend
257
244
  // because Frontend tends to minify class names, so `constructor.name` is not reliable
258
- const { name = (0, env_1.isServerSide)() ? this.constructor.name : 'AppError', cause } = opt;
245
+ const { name = isServerSide() ? this.constructor.name : 'AppError', cause } = opt;
259
246
  Object.defineProperties(this, {
260
247
  name: {
261
248
  value: name,
@@ -295,7 +282,6 @@ class AppError extends Error {
295
282
  // }
296
283
  }
297
284
  }
298
- exports.AppError = AppError;
299
285
  /**
300
286
  * Error that is thrown when Http Request was made and returned an error.
301
287
  * Thrown by, for example, Fetcher.
@@ -313,7 +299,7 @@ exports.AppError = AppError;
313
299
  * E.g 3rd-party call may return 401, but our Backend will still wrap it into an 500 error
314
300
  * (by default).
315
301
  */
316
- class HttpRequestError extends AppError {
302
+ export class HttpRequestError extends AppError {
317
303
  constructor(message, data, opt) {
318
304
  if (data.response) {
319
305
  Object.defineProperty(data, 'response', {
@@ -323,38 +309,33 @@ class HttpRequestError extends AppError {
323
309
  super(message, data, { ...opt, name: 'HttpRequestError' });
324
310
  }
325
311
  }
326
- exports.HttpRequestError = HttpRequestError;
327
- class AssertionError extends AppError {
312
+ export class AssertionError extends AppError {
328
313
  constructor(message, data) {
329
314
  super(message, data, { name: 'AssertionError' });
330
315
  }
331
316
  }
332
- exports.AssertionError = AssertionError;
333
- class JsonParseError extends AppError {
317
+ export class JsonParseError extends AppError {
334
318
  constructor(data) {
335
- const message = ['Failed to parse', data.text && (0, string_util_1._truncateMiddle)(data.text, 200)]
319
+ const message = ['Failed to parse', data.text && _truncateMiddle(data.text, 200)]
336
320
  .filter(Boolean)
337
321
  .join(': ');
338
322
  super(message, data, { name: 'JsonParseError' });
339
323
  }
340
324
  }
341
- exports.JsonParseError = JsonParseError;
342
- class TimeoutError extends AppError {
325
+ export class TimeoutError extends AppError {
343
326
  constructor(message, data, opt) {
344
327
  super(message, data, { ...opt, name: 'TimeoutError' });
345
328
  }
346
329
  }
347
- exports.TimeoutError = TimeoutError;
348
330
  /**
349
331
  * It is thrown when Error was expected, but didn't happen
350
332
  * ("pass" happened instead).
351
333
  * "Pass" means "no error".
352
334
  */
353
- class UnexpectedPassError extends AppError {
335
+ export class UnexpectedPassError extends AppError {
354
336
  constructor(message) {
355
337
  super(message || 'expected error was not thrown', {}, {
356
338
  name: 'UnexpectedPassError',
357
339
  });
358
340
  }
359
341
  }
360
- exports.UnexpectedPassError = UnexpectedPassError;
@@ -1,12 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ErrorMode = void 0;
4
1
  /**
5
2
  * Allows to define error-controlling behaviour for batch operations.
6
3
  *
7
4
  * @default is THROW_IMMEDIATELY in most cases
8
5
  */
9
- var ErrorMode;
6
+ export var ErrorMode;
10
7
  (function (ErrorMode) {
11
8
  /**
12
9
  * Usually a default behaviour, similar as "exit early".
@@ -20,4 +17,4 @@ var ErrorMode;
20
17
  * Completely suppress errors, do not aggregate nor throw anything. Resilient mode.
21
18
  */
22
19
  ErrorMode["SUPPRESS"] = "SUPPRESS";
23
- })(ErrorMode || (exports.ErrorMode = ErrorMode = {}));
20
+ })(ErrorMode || (ErrorMode = {}));
@@ -1,5 +1,5 @@
1
- import type { Class } from '../typeFest';
2
- import type { AnyFunction, ErrorDataTuple } from '../types';
1
+ import type { Class } from '../typeFest.js';
2
+ import type { AnyFunction, ErrorDataTuple } from '../types.js';
3
3
  /**
4
4
  * Calls a function, returns a Tuple of [error, value].
5
5
  * Allows to write shorter code that avoids `try/catch`.