@naturalcycles/js-lib 14.84.0 → 14.84.1

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.
@@ -1,4 +1,4 @@
1
- import { ErrorData, HttpErrorData } from '..';
1
+ import { ErrorData } from '..';
2
2
  import { AppError } from './app.error';
3
3
  /**
4
4
  * Evaluates the `condition` (casts it to Boolean).
@@ -16,21 +16,21 @@ import { AppError } from './app.error';
16
16
  * 3. Sets `userFriendly` flag to true, cause it's always better to have at least SOME clue, rather than fully generic "Oops" error.
17
17
  */
18
18
  export declare function _assert(condition: any, // will be evaluated as Boolean
19
- message?: string, errorData?: Partial<HttpErrorData>): asserts condition;
19
+ message?: string, errorData?: ErrorData): asserts condition;
20
20
  /**
21
21
  * Like _assert(), but prints more helpful error message.
22
22
  * API is similar to Node's assert.equals().
23
23
  *
24
24
  * Does SHALLOW, but strict equality (===), use _assertDeepEquals() for deep equality.
25
25
  */
26
- export declare function _assertEquals<T>(actual: any, expected: T, message?: string, errorData?: Partial<HttpErrorData>): asserts actual is T;
26
+ export declare function _assertEquals<T>(actual: any, expected: T, message?: string, errorData?: ErrorData): asserts actual is T;
27
27
  /**
28
28
  * Like _assert(), but prints more helpful error message.
29
29
  * API is similar to Node's assert.deepEquals().
30
30
  *
31
31
  * Does DEEP equality via _deepEquals()
32
32
  */
33
- export declare function _assertDeepEquals<T>(actual: any, expected: T, message?: string, errorData?: Partial<HttpErrorData>): asserts actual is T;
33
+ export declare function _assertDeepEquals<T>(actual: any, expected: T, message?: string, errorData?: ErrorData): asserts actual is T;
34
34
  export declare function _assertIsError<ERR extends Error = Error>(err: any, message?: string): asserts err is ERR;
35
35
  export declare function _assertIsString(v: any, message?: string): asserts v is string;
36
36
  export declare function _assertIsNumber(v: any, message?: string): asserts v is number;
@@ -32,6 +32,7 @@ export interface ErrorData {
32
32
  * Can be used to force-group errors that are NOT needed to be split by endpoint or calling function.
33
33
  */
34
34
  fingerprint?: string[];
35
+ httpStatusCode?: number;
35
36
  /**
36
37
  * Open-ended.
37
38
  */
@@ -1,4 +1,4 @@
1
- import { AnyFunction, AnyObject, CommonLogger } from '..';
1
+ import { AnyFunction, CommonLogger, ErrorData } from '..';
2
2
  export interface PRetryOptions {
3
3
  /**
4
4
  * If set - will be included in the error message.
@@ -79,7 +79,7 @@ export interface PRetryOptions {
79
79
  /**
80
80
  * Will be merged with `err.data` object.
81
81
  */
82
- errorData?: AnyObject;
82
+ errorData?: ErrorData;
83
83
  }
84
84
  /**
85
85
  * Returns a Function (!), enhanced with retry capabilities.
@@ -1,5 +1,6 @@
1
1
  import { AppError } from '../error/app.error';
2
- import { AnyFunction, AnyObject } from '../types';
2
+ import { ErrorData } from '../error/error.model';
3
+ import { AnyFunction } from '../types';
3
4
  export declare class TimeoutError extends AppError {
4
5
  }
5
6
  export interface PTimeoutOptions {
@@ -28,7 +29,7 @@ export interface PTimeoutOptions {
28
29
  /**
29
30
  * Will be merged with `err.data` object.
30
31
  */
31
- errorData?: AnyObject;
32
+ errorData?: ErrorData;
32
33
  }
33
34
  /**
34
35
  * Decorates a Function with a timeout.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/js-lib",
3
- "version": "14.84.0",
3
+ "version": "14.84.1",
4
4
  "scripts": {
5
5
  "prepare": "husky install",
6
6
  "build-prod": "build-prod-esm-cjs",
@@ -1,4 +1,4 @@
1
- import { ErrorData, HttpErrorData, _deepEquals, _stringifyAny } from '..'
1
+ import { ErrorData, _deepEquals, _stringifyAny } from '..'
2
2
  import { AppError } from './app.error'
3
3
 
4
4
  /**
@@ -19,7 +19,7 @@ import { AppError } from './app.error'
19
19
  export function _assert(
20
20
  condition: any, // will be evaluated as Boolean
21
21
  message?: string,
22
- errorData?: Partial<HttpErrorData>,
22
+ errorData?: ErrorData,
23
23
  ): asserts condition {
24
24
  if (!condition) {
25
25
  throw new AssertionError(message || 'see stacktrace', {
@@ -39,7 +39,7 @@ export function _assertEquals<T>(
39
39
  actual: any,
40
40
  expected: T,
41
41
  message?: string,
42
- errorData?: Partial<HttpErrorData>,
42
+ errorData?: ErrorData,
43
43
  ): asserts actual is T {
44
44
  if (actual !== expected) {
45
45
  const msg = [
@@ -67,7 +67,7 @@ export function _assertDeepEquals<T>(
67
67
  actual: any,
68
68
  expected: T,
69
69
  message?: string,
70
- errorData?: Partial<HttpErrorData>,
70
+ errorData?: ErrorData,
71
71
  ): asserts actual is T {
72
72
  if (!_deepEquals(actual, expected)) {
73
73
  const msg = [
@@ -38,6 +38,8 @@ export interface ErrorData {
38
38
  */
39
39
  fingerprint?: string[]
40
40
 
41
+ httpStatusCode?: number
42
+
41
43
  /**
42
44
  * Open-ended.
43
45
  */
@@ -1,4 +1,4 @@
1
- import { _since, _stringifyAny, AnyFunction, AnyObject, AppError, CommonLogger } from '..'
1
+ import { _since, _stringifyAny, AnyFunction, AppError, CommonLogger, ErrorData } from '..'
2
2
  import { TimeoutError } from './pTimeout'
3
3
 
4
4
  export interface PRetryOptions {
@@ -95,7 +95,7 @@ export interface PRetryOptions {
95
95
  /**
96
96
  * Will be merged with `err.data` object.
97
97
  */
98
- errorData?: AnyObject
98
+ errorData?: ErrorData
99
99
  }
100
100
 
101
101
  /**
@@ -1,5 +1,6 @@
1
1
  import { AppError } from '../error/app.error'
2
- import { AnyFunction, AnyObject } from '../types'
2
+ import { ErrorData } from '../error/error.model'
3
+ import { AnyFunction } from '../types'
3
4
 
4
5
  export class TimeoutError extends AppError {}
5
6
 
@@ -33,7 +34,7 @@ export interface PTimeoutOptions {
33
34
  /**
34
35
  * Will be merged with `err.data` object.
35
36
  */
36
- errorData?: AnyObject
37
+ errorData?: ErrorData
37
38
  }
38
39
 
39
40
  /**