@naturalcycles/js-lib 14.109.1 → 14.109.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.
- package/dist/error/error.util.d.ts +2 -2
- package/dist/json-schema/from-data/generateJsonSchemaFromData.d.ts +1 -1
- package/dist/json-schema/jsonSchema.model.d.ts +1 -1
- package/dist/json-schema/jsonSchema.util.d.ts +2 -1
- package/package.json +2 -2
- package/src/error/error.util.ts +4 -2
- package/src/json-schema/from-data/generateJsonSchemaFromData.ts +3 -1
- package/src/json-schema/jsonSchema.model.ts +1 -1
- package/src/json-schema/jsonSchema.util.ts +2 -2
|
@@ -17,8 +17,8 @@ export declare function _anyToError<ERROR_TYPE extends Error = Error>(o: any, er
|
|
|
17
17
|
*/
|
|
18
18
|
export declare function _anyToErrorObject<DATA_TYPE extends ErrorData = ErrorData>(o: any, opt?: StringifyAnyOptions): ErrorObject<DATA_TYPE>;
|
|
19
19
|
export declare function _errorToErrorObject<DATA_TYPE extends ErrorData = ErrorData>(e: AppError<DATA_TYPE> | Error, includeErrorStack?: boolean): ErrorObject<DATA_TYPE>;
|
|
20
|
-
export declare function _errorObjectToAppError<DATA_TYPE>(o: ErrorObject<DATA_TYPE>): AppError<DATA_TYPE>;
|
|
21
|
-
export declare function _errorObjectToError<DATA_TYPE, ERROR_TYPE extends Error>(o: ErrorObject<DATA_TYPE>, errorClass?: Class<ERROR_TYPE>): ERROR_TYPE;
|
|
20
|
+
export declare function _errorObjectToAppError<DATA_TYPE extends ErrorData>(o: ErrorObject<DATA_TYPE>): AppError<DATA_TYPE>;
|
|
21
|
+
export declare function _errorObjectToError<DATA_TYPE extends ErrorData, ERROR_TYPE extends Error>(o: ErrorObject<DATA_TYPE>, errorClass?: Class<ERROR_TYPE>): ERROR_TYPE;
|
|
22
22
|
export declare function _isHttpErrorResponse(o: any): o is HttpErrorResponse;
|
|
23
23
|
export declare function _isHttpErrorObject(o: any): o is ErrorObject<HttpErrorData>;
|
|
24
24
|
/**
|
|
@@ -4,4 +4,4 @@ import type { JsonSchemaObject, AnyObject } from '../..';
|
|
|
4
4
|
*
|
|
5
5
|
* `additionalProperties` is set to `true`, cause it's safer.
|
|
6
6
|
*/
|
|
7
|
-
export declare function generateJsonSchemaFromData<T =
|
|
7
|
+
export declare function generateJsonSchemaFromData<T extends AnyObject = AnyObject>(rows: AnyObject[]): JsonSchemaObject<T>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AnyObject, StringMap } from '../types';
|
|
2
|
-
export declare type JsonSchema<T = unknown> = JsonSchemaAny<T> | JsonSchemaOneOf<T> | JsonSchemaAllOf<T> | JsonSchemaAnyOf<T> | JsonSchemaNot<T> | JsonSchemaRef<T> | JsonSchemaConst<T> | JsonSchemaEnum<T> | JsonSchemaString | JsonSchemaNumber | JsonSchemaBoolean | JsonSchemaNull | JsonSchemaObject
|
|
2
|
+
export declare type JsonSchema<T = unknown> = JsonSchemaAny<T> | JsonSchemaOneOf<T> | JsonSchemaAllOf<T> | JsonSchemaAnyOf<T> | JsonSchemaNot<T> | JsonSchemaRef<T> | JsonSchemaConst<T> | JsonSchemaEnum<T> | JsonSchemaString | JsonSchemaNumber | JsonSchemaBoolean | JsonSchemaNull | JsonSchemaObject | JsonSchemaArray<T> | JsonSchemaTuple<T>;
|
|
3
3
|
export interface JsonSchemaAny<T = unknown> {
|
|
4
4
|
$schema?: string;
|
|
5
5
|
$id?: string;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { AnyObject } from '../index';
|
|
1
2
|
import type { JsonSchemaObject } from './jsonSchema.model';
|
|
2
3
|
/**
|
|
3
4
|
* Merges s2 into s1 (mutates s1) and returns s1.
|
|
4
5
|
* Does not mutate s2.
|
|
5
6
|
* API similar to Object.assign(s1, s2)
|
|
6
7
|
*/
|
|
7
|
-
export declare function mergeJsonSchemaObjects<T1, T2>(s1: JsonSchemaObject<T1>, s2: JsonSchemaObject<T2>): JsonSchemaObject<T1 & T2>;
|
|
8
|
+
export declare function mergeJsonSchemaObjects<T1 extends AnyObject, T2 extends AnyObject>(s1: JsonSchemaObject<T1>, s2: JsonSchemaObject<T2>): JsonSchemaObject<T1 & T2>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/js-lib",
|
|
3
|
-
"version": "14.109.
|
|
3
|
+
"version": "14.109.2",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"prepare": "husky install",
|
|
6
6
|
"build-prod": "build-prod-esm-cjs",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"@naturalcycles/time-lib": "^3.5.1",
|
|
18
18
|
"@types/node": "^18.0.0",
|
|
19
19
|
"expect-type": "^0.13.0",
|
|
20
|
-
"jest": "^
|
|
20
|
+
"jest": "^29.0.0",
|
|
21
21
|
"prettier": "^2.1.2",
|
|
22
22
|
"rxjs": "^7.0.1",
|
|
23
23
|
"vuepress": "^1.7.1",
|
package/src/error/error.util.ts
CHANGED
|
@@ -87,11 +87,13 @@ export function _errorToErrorObject<DATA_TYPE extends ErrorData = ErrorData>(
|
|
|
87
87
|
return obj
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
export function _errorObjectToAppError<DATA_TYPE
|
|
90
|
+
export function _errorObjectToAppError<DATA_TYPE extends ErrorData>(
|
|
91
|
+
o: ErrorObject<DATA_TYPE>,
|
|
92
|
+
): AppError<DATA_TYPE> {
|
|
91
93
|
return _errorObjectToError(o, AppError)
|
|
92
94
|
}
|
|
93
95
|
|
|
94
|
-
export function _errorObjectToError<DATA_TYPE, ERROR_TYPE extends Error>(
|
|
96
|
+
export function _errorObjectToError<DATA_TYPE extends ErrorData, ERROR_TYPE extends Error>(
|
|
95
97
|
o: ErrorObject<DATA_TYPE>,
|
|
96
98
|
errorClass: Class<ERROR_TYPE> = Error as any,
|
|
97
99
|
): ERROR_TYPE {
|
|
@@ -20,7 +20,9 @@ type Type = PrimitiveType | 'array' | 'object'
|
|
|
20
20
|
*
|
|
21
21
|
* `additionalProperties` is set to `true`, cause it's safer.
|
|
22
22
|
*/
|
|
23
|
-
export function generateJsonSchemaFromData<T =
|
|
23
|
+
export function generateJsonSchemaFromData<T extends AnyObject = AnyObject>(
|
|
24
|
+
rows: AnyObject[],
|
|
25
|
+
): JsonSchemaObject<T> {
|
|
24
26
|
return objectToJsonSchema(rows as any) as JsonSchemaObject<T>
|
|
25
27
|
}
|
|
26
28
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _uniq } from '../index'
|
|
1
|
+
import { _uniq, AnyObject } from '../index'
|
|
2
2
|
import { _filterNullishValues } from '../object/object.util'
|
|
3
3
|
import type { JsonSchemaObject } from './jsonSchema.model'
|
|
4
4
|
|
|
@@ -7,7 +7,7 @@ import type { JsonSchemaObject } from './jsonSchema.model'
|
|
|
7
7
|
* Does not mutate s2.
|
|
8
8
|
* API similar to Object.assign(s1, s2)
|
|
9
9
|
*/
|
|
10
|
-
export function mergeJsonSchemaObjects<T1, T2>(
|
|
10
|
+
export function mergeJsonSchemaObjects<T1 extends AnyObject, T2 extends AnyObject>(
|
|
11
11
|
s1: JsonSchemaObject<T1>,
|
|
12
12
|
s2: JsonSchemaObject<T2>,
|
|
13
13
|
): JsonSchemaObject<T1 & T2> {
|