@balena/sbvr-types 4.0.1 → 4.0.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/.versionbot/CHANGELOG.yml +12 -1
- package/CHANGELOG.md +5 -0
- package/out/index.d.ts +40 -9
- package/out/type-utils.d.ts +5 -5
- package/out/type-utils.js.map +1 -1
- package/out/types/big-integer.d.ts +1 -1
- package/out/types/big-serial.d.ts +1 -1
- package/out/types/boolean.d.ts +1 -1
- package/out/types/case-insensitive-text.d.ts +1 -1
- package/out/types/color.d.ts +1 -1
- package/out/types/concept-type.d.ts +1 -1
- package/out/types/date-time.d.ts +1 -1
- package/out/types/date.d.ts +1 -1
- package/out/types/file.d.ts +1 -1
- package/out/types/foreign-key.d.ts +1 -1
- package/out/types/hashed.d.ts +1 -1
- package/out/types/integer.d.ts +1 -1
- package/out/types/interval.d.ts +1 -1
- package/out/types/json.d.ts +1 -1
- package/out/types/real.d.ts +1 -1
- package/out/types/serial.d.ts +1 -1
- package/out/types/sha.d.ts +1 -1
- package/out/types/short-text.d.ts +1 -1
- package/out/types/text.d.ts +1 -1
- package/package.json +2 -2
- package/src/index.ts +1 -1
- package/src/type-utils.ts +3 -3
|
@@ -1,3 +1,14 @@
|
|
|
1
|
+
- commits:
|
|
2
|
+
- subject: Improve typings
|
|
3
|
+
hash: a5fd4a319cd0336afc5a765af9e1a1eec851f2c3
|
|
4
|
+
body: ""
|
|
5
|
+
footer:
|
|
6
|
+
Change-type: patch
|
|
7
|
+
change-type: patch
|
|
8
|
+
author: Pagan Gazzard
|
|
9
|
+
version: 4.0.2
|
|
10
|
+
title: ""
|
|
11
|
+
date: 2023-05-03T11:37:17.650Z
|
|
1
12
|
- commits:
|
|
2
13
|
- subject: "boolean: Avoid unnecessary array creation to reduce GCs"
|
|
3
14
|
hash: 5ba948cd5f42844974d43dc19f1c371e56376fc8
|
|
@@ -8,7 +19,7 @@
|
|
|
8
19
|
author: Thodoris Greasidis
|
|
9
20
|
version: 4.0.1
|
|
10
21
|
title: ""
|
|
11
|
-
date: 2023-05-
|
|
22
|
+
date: 2023-05-02T13:39:37.722Z
|
|
12
23
|
- commits:
|
|
13
24
|
- subject: Add test cases for Objects in JSON validate
|
|
14
25
|
hash: be8fc31c3754186dd4c43ca8d4c056b0def7ffbd
|
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file
|
|
|
4
4
|
automatically by Versionist. DO NOT EDIT THIS FILE MANUALLY!
|
|
5
5
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
|
6
6
|
|
|
7
|
+
# v4.0.2
|
|
8
|
+
## (2023-05-03)
|
|
9
|
+
|
|
10
|
+
* Improve typings [Pagan Gazzard]
|
|
11
|
+
|
|
7
12
|
# v4.0.1
|
|
8
13
|
## (2023-05-02)
|
|
9
14
|
|
package/out/index.d.ts
CHANGED
|
@@ -1,12 +1,43 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as BigInteger from './types/big-integer';
|
|
2
|
+
import * as BigSerial from './types/big-serial';
|
|
3
|
+
import * as Boolean from './types/boolean';
|
|
4
|
+
import * as CaseInsensitiveText from './types/case-insensitive-text';
|
|
5
|
+
import * as Color from './types/color';
|
|
6
|
+
import * as ConceptType from './types/concept-type';
|
|
7
|
+
import * as Date from './types/date';
|
|
8
|
+
import * as DateTime from './types/date-time';
|
|
9
|
+
import * as File from './types/file';
|
|
10
|
+
import * as ForeignKey from './types/foreign-key';
|
|
11
|
+
import * as Hashed from './types/hashed';
|
|
12
|
+
import * as Integer from './types/integer';
|
|
13
|
+
import * as Interval from './types/interval';
|
|
14
|
+
import * as JSON from './types/json';
|
|
15
|
+
import * as Real from './types/real';
|
|
16
|
+
import * as Serial from './types/serial';
|
|
17
|
+
import * as SHA from './types/sha';
|
|
18
|
+
import * as ShortText from './types/short-text';
|
|
19
|
+
import * as Text from './types/text';
|
|
20
|
+
import * as Time from './types/time';
|
|
2
21
|
declare const _default: {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
22
|
+
'Big Integer': typeof BigInteger;
|
|
23
|
+
'Big Serial': typeof BigSerial;
|
|
24
|
+
Boolean: typeof Boolean;
|
|
25
|
+
'Case Insensitive Text': typeof CaseInsensitiveText;
|
|
26
|
+
Color: typeof Color;
|
|
27
|
+
ConceptType: typeof ConceptType;
|
|
28
|
+
'Date Time': typeof DateTime;
|
|
29
|
+
Date: typeof Date;
|
|
30
|
+
File: typeof File;
|
|
31
|
+
ForeignKey: typeof ForeignKey;
|
|
32
|
+
Hashed: typeof Hashed;
|
|
33
|
+
Integer: typeof Integer;
|
|
34
|
+
Interval: typeof Interval;
|
|
35
|
+
JSON: typeof JSON;
|
|
36
|
+
Real: typeof Real;
|
|
37
|
+
Serial: typeof Serial;
|
|
38
|
+
SHA: typeof SHA;
|
|
39
|
+
'Short Text': typeof ShortText;
|
|
40
|
+
Text: typeof Text;
|
|
41
|
+
Time: typeof Time;
|
|
11
42
|
};
|
|
12
43
|
export = _default;
|
package/out/type-utils.d.ts
CHANGED
|
@@ -14,7 +14,7 @@ export interface SbvrType {
|
|
|
14
14
|
websql: DatabaseType;
|
|
15
15
|
};
|
|
16
16
|
fetchProcessing?: (field: any) => any;
|
|
17
|
-
validate: (value: any, required
|
|
17
|
+
validate: (value: any, required: boolean) => Promise<any>;
|
|
18
18
|
}
|
|
19
19
|
export declare const nativeFactTypeTemplates: {
|
|
20
20
|
equality: {
|
|
@@ -30,21 +30,21 @@ export declare const validate: {
|
|
|
30
30
|
checkRequired: <T>(validateFn: (value: any) => T) => {
|
|
31
31
|
(value: any, required: true): Promise<T>;
|
|
32
32
|
(value: undefined | null, required: false): Promise<null>;
|
|
33
|
-
|
|
33
|
+
(value: any, required: boolean): Promise<T | null>;
|
|
34
34
|
};
|
|
35
35
|
integer: {
|
|
36
36
|
(value: any, required: true): Promise<number>;
|
|
37
37
|
(value: undefined | null, required: false): Promise<null>;
|
|
38
|
-
|
|
38
|
+
(value: any, required: boolean): Promise<number | null>;
|
|
39
39
|
};
|
|
40
40
|
text: (length?: number) => {
|
|
41
41
|
(value: any, required: true): Promise<string>;
|
|
42
42
|
(value: undefined | null, required: false): Promise<null>;
|
|
43
|
-
|
|
43
|
+
(value: any, required: boolean): Promise<string | null>;
|
|
44
44
|
};
|
|
45
45
|
date: {
|
|
46
46
|
(value: any, required: true): Promise<Date>;
|
|
47
47
|
(value: undefined | null, required: false): Promise<null>;
|
|
48
|
-
|
|
48
|
+
(value: any, required: boolean): Promise<Date | null>;
|
|
49
49
|
};
|
|
50
50
|
};
|
package/out/type-utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"type-utils.js","sourceRoot":"","sources":["../src/type-utils.ts"],"names":[],"mappings":";;;AAmBA,MAAM,aAAa,GAAG,CAAI,UAA6B,EAAE,EAAE;IAI1D,KAAK,UAAU,QAAQ,
|
|
1
|
+
{"version":3,"file":"type-utils.js","sourceRoot":"","sources":["../src/type-utils.ts"],"names":[],"mappings":";;;AAmBA,MAAM,aAAa,GAAG,CAAI,UAA6B,EAAE,EAAE;IAI1D,KAAK,UAAU,QAAQ,CAAC,KAAU,EAAE,QAAiB;QACpD,IAAI,KAAK,IAAI,IAAI,EAAE;YAClB,IAAI,QAAQ,EAAE;gBACb,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;aAClC;YACD,OAAO,IAAI,CAAC;SACZ;QACD,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC;IAC1B,CAAC;IACD,OAAO,QAAQ,CAAC;AACjB,CAAC,CAAC;AAEF,MAAM,QAAQ,GAAG;IAChB,aAAa,EAAE,CAAC,IAAY,EAAE,EAAU,EAAE,EAAE,CAAC,CAAC,QAAQ,EAAE,IAAI,EAAE,EAAE,CAAC;CACjE,CAAC;AACW,QAAA,uBAAuB,GAAG;IACtC,QAAQ;IACR,UAAU,EA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Ac,CAAC,CAAC;QAC/C,IAAI,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE,CAAC,EAAE;YAC1C,MAAM,IAAI,KAAK,CAAC,uBAAuB,GAAG,KAAK,CAAC,CAAC;SACjD;QACD,OAAO,aAAa,CAAC;IACtB,CAAC,CAAC;CACF,CAAC"}
|
|
@@ -21,5 +21,5 @@ export declare const nativeFactTypes: {
|
|
|
21
21
|
export declare const validate: {
|
|
22
22
|
(value: any, required: true): Promise<number>;
|
|
23
23
|
(value: null | undefined, required: false): Promise<null>;
|
|
24
|
-
|
|
24
|
+
(value: any, required: boolean): Promise<number | null>;
|
|
25
25
|
};
|
|
@@ -10,5 +10,5 @@ export declare const types: {
|
|
|
10
10
|
export declare const validate: {
|
|
11
11
|
(value: any, required: true): Promise<number>;
|
|
12
12
|
(value: null | undefined, required: false): Promise<null>;
|
|
13
|
-
|
|
13
|
+
(value: any, required: boolean): Promise<number | null>;
|
|
14
14
|
};
|
package/out/types/boolean.d.ts
CHANGED
|
@@ -11,5 +11,5 @@ export declare const fetchProcessing: (data: any) => boolean;
|
|
|
11
11
|
export declare const validate: {
|
|
12
12
|
(value: any, required: true): Promise<boolean>;
|
|
13
13
|
(value: null | undefined, required: false): Promise<null>;
|
|
14
|
-
|
|
14
|
+
(value: any, required: boolean): Promise<boolean | null>;
|
|
15
15
|
};
|
|
@@ -9,5 +9,5 @@ export declare const types: {
|
|
|
9
9
|
export declare const validate: {
|
|
10
10
|
(value: any, required: true): Promise<string>;
|
|
11
11
|
(value: null | undefined, required: false): Promise<null>;
|
|
12
|
-
|
|
12
|
+
(value: any, required: boolean): Promise<string | null>;
|
|
13
13
|
};
|
package/out/types/color.d.ts
CHANGED
|
@@ -24,5 +24,5 @@ export declare const fetchProcessing: (data: number) => {
|
|
|
24
24
|
export declare const validate: {
|
|
25
25
|
(value: any, required: true): Promise<number>;
|
|
26
26
|
(value: null | undefined, required: false): Promise<null>;
|
|
27
|
-
|
|
27
|
+
(value: any, required: boolean): Promise<number | null>;
|
|
28
28
|
};
|
|
@@ -21,5 +21,5 @@ export declare const nativeFactTypes: {
|
|
|
21
21
|
export declare const validate: {
|
|
22
22
|
(value: any, required: true): Promise<number>;
|
|
23
23
|
(value: null | undefined, required: false): Promise<null>;
|
|
24
|
-
|
|
24
|
+
(value: any, required: boolean): Promise<number | null>;
|
|
25
25
|
};
|
package/out/types/date-time.d.ts
CHANGED
|
@@ -19,5 +19,5 @@ export declare const nativeNames: {
|
|
|
19
19
|
export declare const validate: {
|
|
20
20
|
(value: any, required: true): Promise<Date>;
|
|
21
21
|
(value: null | undefined, required: false): Promise<null>;
|
|
22
|
-
|
|
22
|
+
(value: any, required: boolean): Promise<Date | null>;
|
|
23
23
|
};
|
package/out/types/date.d.ts
CHANGED
|
@@ -16,5 +16,5 @@ export declare const nativeFactTypes: {
|
|
|
16
16
|
export declare const validate: {
|
|
17
17
|
(value: any, required: true): Promise<Date>;
|
|
18
18
|
(value: null | undefined, required: false): Promise<null>;
|
|
19
|
-
|
|
19
|
+
(value: any, required: boolean): Promise<Date | null>;
|
|
20
20
|
};
|
package/out/types/file.d.ts
CHANGED
|
@@ -10,5 +10,5 @@ export declare const types: {
|
|
|
10
10
|
export declare const validate: {
|
|
11
11
|
(value: any, required: true): Promise<Buffer>;
|
|
12
12
|
(value: null | undefined, required: false): Promise<null>;
|
|
13
|
-
|
|
13
|
+
(value: any, required: boolean): Promise<Buffer | null>;
|
|
14
14
|
};
|
|
@@ -21,5 +21,5 @@ export declare const nativeFactTypes: {
|
|
|
21
21
|
export declare const validate: {
|
|
22
22
|
(value: any, required: true): Promise<number>;
|
|
23
23
|
(value: null | undefined, required: false): Promise<null>;
|
|
24
|
-
|
|
24
|
+
(value: any, required: boolean): Promise<number | null>;
|
|
25
25
|
};
|
package/out/types/hashed.d.ts
CHANGED
|
@@ -10,6 +10,6 @@ export declare const types: {
|
|
|
10
10
|
export declare const validate: {
|
|
11
11
|
(value: any, required: true): Promise<Promise<string>>;
|
|
12
12
|
(value: null | undefined, required: false): Promise<null>;
|
|
13
|
-
|
|
13
|
+
(value: any, required: boolean): Promise<Promise<string> | null>;
|
|
14
14
|
};
|
|
15
15
|
export declare const compare: typeof Bcrypt.compare;
|
package/out/types/integer.d.ts
CHANGED
|
@@ -21,5 +21,5 @@ export declare const nativeFactTypes: {
|
|
|
21
21
|
export declare const validate: {
|
|
22
22
|
(value: any, required: true): Promise<number>;
|
|
23
23
|
(value: null | undefined, required: false): Promise<null>;
|
|
24
|
-
|
|
24
|
+
(value: any, required: boolean): Promise<number | null>;
|
|
25
25
|
};
|
package/out/types/interval.d.ts
CHANGED
|
@@ -9,5 +9,5 @@ export declare const types: {
|
|
|
9
9
|
export declare const validate: {
|
|
10
10
|
(value: any, required: true): Promise<number>;
|
|
11
11
|
(value: null | undefined, required: false): Promise<null>;
|
|
12
|
-
|
|
12
|
+
(value: any, required: boolean): Promise<number | null>;
|
|
13
13
|
};
|
package/out/types/json.d.ts
CHANGED
|
@@ -10,5 +10,5 @@ export declare const fetchProcessing: (data: any) => any;
|
|
|
10
10
|
export declare const validate: {
|
|
11
11
|
(value: any, required: true): Promise<string>;
|
|
12
12
|
(value: null | undefined, required: false): Promise<null>;
|
|
13
|
-
|
|
13
|
+
(value: any, required: boolean): Promise<string | null>;
|
|
14
14
|
};
|
package/out/types/real.d.ts
CHANGED
|
@@ -21,5 +21,5 @@ export declare const nativeFactTypes: {
|
|
|
21
21
|
export declare const validate: {
|
|
22
22
|
(value: any, required: true): Promise<number>;
|
|
23
23
|
(value: null | undefined, required: false): Promise<null>;
|
|
24
|
-
|
|
24
|
+
(value: any, required: boolean): Promise<number | null>;
|
|
25
25
|
};
|
package/out/types/serial.d.ts
CHANGED
|
@@ -10,5 +10,5 @@ export declare const types: {
|
|
|
10
10
|
export declare const validate: {
|
|
11
11
|
(value: any, required: true): Promise<number>;
|
|
12
12
|
(value: null | undefined, required: false): Promise<null>;
|
|
13
|
-
|
|
13
|
+
(value: any, required: boolean): Promise<number | null>;
|
|
14
14
|
};
|
package/out/types/sha.d.ts
CHANGED
|
@@ -10,6 +10,6 @@ export declare const validateSync: (value: string) => string;
|
|
|
10
10
|
export declare const validate: {
|
|
11
11
|
(value: any, required: true): Promise<string>;
|
|
12
12
|
(value: null | undefined, required: false): Promise<null>;
|
|
13
|
-
|
|
13
|
+
(value: any, required: boolean): Promise<string | null>;
|
|
14
14
|
};
|
|
15
15
|
export declare const compare: (value: string, result: string) => Promise<boolean>;
|
|
@@ -9,5 +9,5 @@ export declare const types: {
|
|
|
9
9
|
export declare const validate: {
|
|
10
10
|
(value: any, required: true): Promise<string>;
|
|
11
11
|
(value: null | undefined, required: false): Promise<null>;
|
|
12
|
-
|
|
12
|
+
(value: any, required: boolean): Promise<string | null>;
|
|
13
13
|
};
|
package/out/types/text.d.ts
CHANGED
|
@@ -22,5 +22,5 @@ export declare const nativeFactTypes: {
|
|
|
22
22
|
export declare const validate: {
|
|
23
23
|
(value: any, required: true): Promise<string>;
|
|
24
24
|
(value: null | undefined, required: false): Promise<null>;
|
|
25
|
-
|
|
25
|
+
(value: any, required: boolean): Promise<string | null>;
|
|
26
26
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@balena/sbvr-types",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"description": "SBVR type definitions.",
|
|
5
5
|
"main": "out",
|
|
6
6
|
"scripts": {
|
|
@@ -54,6 +54,6 @@
|
|
|
54
54
|
"npm": ">=8.1.0"
|
|
55
55
|
},
|
|
56
56
|
"versionist": {
|
|
57
|
-
"publishedAt": "2023-05-
|
|
57
|
+
"publishedAt": "2023-05-03T11:37:17.824Z"
|
|
58
58
|
}
|
|
59
59
|
}
|
package/src/index.ts
CHANGED
package/src/type-utils.ts
CHANGED
|
@@ -14,14 +14,14 @@ export interface SbvrType {
|
|
|
14
14
|
websql: DatabaseType;
|
|
15
15
|
};
|
|
16
16
|
fetchProcessing?: (field: any) => any;
|
|
17
|
-
validate: (value: any, required
|
|
17
|
+
validate: (value: any, required: boolean) => Promise<any>;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
const checkRequired = <T>(validateFn: (value: any) => T) => {
|
|
21
21
|
function runCheck(value: any, required: true): Promise<T>;
|
|
22
22
|
function runCheck(value: undefined | null, required: false): Promise<null>;
|
|
23
|
-
function runCheck
|
|
24
|
-
async function runCheck
|
|
23
|
+
function runCheck(value: any, required: boolean): Promise<T | null>;
|
|
24
|
+
async function runCheck(value: any, required: boolean): Promise<T | null> {
|
|
25
25
|
if (value == null) {
|
|
26
26
|
if (required) {
|
|
27
27
|
throw new Error('cannot be null');
|