@hkdigital/lib-core 0.4.11 → 0.4.13
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/README.md +4 -1
- package/dist/auth/errors.d.ts +1 -1
- package/dist/auth/errors.js +1 -1
- package/dist/auth/jwt/constants.d.ts +6 -0
- package/dist/auth/jwt/constants.js +13 -0
- package/dist/auth/jwt/core.d.ts +38 -0
- package/dist/auth/jwt/core.js +114 -0
- package/dist/auth/jwt/errors.d.ts +39 -0
- package/dist/auth/jwt/errors.js +74 -0
- package/dist/auth/jwt/generators.d.ts +29 -0
- package/dist/auth/jwt/generators.js +53 -0
- package/dist/auth/jwt/typedef.d.ts +159 -0
- package/dist/auth/jwt/typedef.js +72 -0
- package/dist/auth/jwt/util.d.ts +6 -0
- package/dist/auth/jwt/util.js +43 -0
- package/dist/auth/jwt.d.ts +4 -0
- package/dist/auth/jwt.js +12 -0
- package/dist/config/README.md +28 -0
- package/dist/design/README.md +12 -0
- package/dist/generic/data/classes/IterableTree.js +1 -1
- package/dist/generic/data/classes/Selector.js +1 -1
- package/dist/generic/promises/classes/HkPromise.js +1 -1
- package/dist/generic/streaming/classes/ServerEventsStore.js +1 -1
- package/dist/generic/typedef.d.ts +2 -0
- package/dist/generic/typedef.js +2 -0
- package/dist/logging/internal/adapters/console.js +3 -3
- package/dist/logging/internal/adapters/pino.js +17 -3
- package/dist/logging/internal/adapters/pino.js__ +260 -0
- package/dist/logging/internal/test-errors.js +3 -2
- package/dist/network/http/errors.js +10 -4
- package/dist/network/http/headers.js +1 -1
- package/dist/network/http/http-request.js +1 -1
- package/dist/network/http/json-request.js +1 -1
- package/dist/network/http/response.js +1 -1
- package/dist/network/loaders/audio/AudioScene.svelte.js +1 -1
- package/dist/network/loaders/image/ImageScene.svelte.js +1 -1
- package/dist/network/loaders/image/utils/index.js +1 -1
- package/dist/network/states/NetworkLoader.svelte.js +1 -1
- package/dist/network/typedef.d.ts +2 -0
- package/dist/network/typedef.js +3 -1
- package/dist/services/service-base/ServiceBase.js +1 -3
- package/dist/services/typedef.d.ts +2 -0
- package/dist/services/typedef.js +2 -0
- package/dist/state/typedef.d.ts +3 -0
- package/dist/state/typedef.js +3 -0
- package/dist/ui/components/drag-drop/drag-state.svelte.d.ts +3 -3
- package/dist/ui/components/hk-app-layout/HkAppLayout.state.svelte.d.ts +3 -3
- package/dist/ui/components/presenter/util.js +1 -1
- package/dist/ui/components/tab-bar/HkTabBar.state.svelte.d.ts +3 -3
- package/dist/ui/components/tab-bar/HkTabBarSelector.state.svelte.d.ts +3 -3
- package/dist/util/array/index.d.ts +0 -4
- package/dist/util/array/index.js +1 -5
- package/dist/util/array.d.ts +1 -0
- package/dist/util/array.js +9 -0
- package/dist/util/bases/base64.d.ts +8 -0
- package/dist/util/bases/base64.js +23 -0
- package/dist/util/bases/index.d.ts +0 -1
- package/dist/util/bases/index.js +0 -1
- package/dist/util/bases.d.ts +2 -0
- package/dist/util/bases.js +10 -0
- package/dist/util/compare.d.ts +1 -0
- package/dist/util/compare.js +9 -0
- package/dist/util/css/index.d.ts +0 -1
- package/dist/util/css/index.js +0 -1
- package/dist/util/css.d.ts +1 -0
- package/dist/util/css.js +8 -0
- package/dist/util/env.d.ts +1 -0
- package/dist/util/env.js +8 -0
- package/dist/util/exceptions.d.ts +1 -0
- package/dist/util/exceptions.js +8 -0
- package/dist/util/expect/arrays.js +2 -0
- package/dist/util/expect/compounds.d.ts +20 -0
- package/dist/util/expect/compounds.js +48 -0
- package/dist/util/expect/objects.d.ts +28 -0
- package/dist/util/expect/objects.js +70 -0
- package/dist/util/expect/primitives.d.ts +31 -1
- package/dist/util/expect/primitives.js +56 -0
- package/dist/util/expect/values.d.ts +26 -0
- package/dist/util/expect/values.js +48 -0
- package/dist/util/expect.d.ts +6 -0
- package/dist/util/expect.js +31 -0
- package/dist/util/function/index.js +1 -1
- package/dist/util/function.d.ts +1 -0
- package/dist/util/function.js +8 -0
- package/dist/util/geometry.d.ts +1 -0
- package/dist/util/geometry.js +9 -0
- package/dist/util/is.d.ts +1 -0
- package/dist/util/is.js +8 -0
- package/dist/util/iterate/index.js +1 -1
- package/dist/util/iterate.d.ts +1 -0
- package/dist/util/iterate.js +8 -0
- package/dist/util/object/index.js +2 -2
- package/dist/util/object.d.ts +1 -0
- package/dist/util/object.js +8 -0
- package/dist/util/random/bytes.d.ts +28 -0
- package/dist/util/random/bytes.js +72 -0
- package/dist/util/random.d.ts +1 -0
- package/dist/util/random.js +9 -0
- package/dist/util/singleton/index.js +1 -1
- package/dist/util/singleton.d.ts +1 -0
- package/dist/util/singleton.js +8 -0
- package/dist/util/ssr.d.ts +1 -0
- package/dist/util/ssr.js +8 -0
- package/dist/util/string/convert.js +1 -1
- package/dist/util/string/index.d.ts +0 -5
- package/dist/util/string/index.js +0 -5
- package/dist/util/string/interpolate.js +1 -1
- package/dist/util/string.d.ts +5 -0
- package/dist/util/string.js +12 -0
- package/dist/util/svelte/index.d.ts +0 -3
- package/dist/util/svelte/index.js +0 -4
- package/dist/util/svelte.d.ts +3 -0
- package/dist/util/svelte.js +11 -0
- package/dist/util/sveltekit/index.d.ts +0 -1
- package/dist/util/sveltekit/index.js +0 -1
- package/dist/util/sveltekit/route-folders/index.js +1 -1
- package/dist/util/sveltekit.d.ts +1 -0
- package/dist/util/sveltekit.js +8 -0
- package/dist/util/time/index.d.ts +7 -0
- package/dist/util/time/index.js +12 -1
- package/dist/util/time.d.ts +1 -0
- package/dist/util/time.js +1 -0
- package/dist/util/unique.d.ts +1 -0
- package/dist/util/unique.js +8 -0
- package/dist/valibot/{index.d.ts → valibot.d.ts} +1 -2
- package/dist/valibot/{index.js → valibot.js} +1 -6
- package/package.json +3 -1
- package/dist/auth/errors/jwt.d.ts +0 -8
- package/dist/auth/errors/jwt.js +0 -5
- package/dist/util/expect/index.d.ts +0 -103
- package/dist/util/expect/index.js +0 -259
- package/dist/util/index.d.ts +0 -10
- /package/dist/util/{geo → geometry}/index.d.ts +0 -0
- /package/dist/util/{geo → geometry}/index.js +0 -0
- /package/dist/util/{index.js → index.js__} +0 -0
|
@@ -48,7 +48,7 @@ export class HkTabBarState {
|
|
|
48
48
|
*/
|
|
49
49
|
linkTab(index: number, tabElement: HTMLElement): void;
|
|
50
50
|
}
|
|
51
|
-
export const createOrGetState: (contextKey?: import("../../../state/
|
|
52
|
-
export const createState: (contextKey?: import("../../../state/
|
|
53
|
-
export const getState: (contextKey?: import("../../../state/
|
|
51
|
+
export const createOrGetState: (contextKey?: import("../../../state/typedef.js").ContextKey) => HkTabBarState;
|
|
52
|
+
export const createState: (contextKey?: import("../../../state/typedef.js").ContextKey) => HkTabBarState;
|
|
53
|
+
export const getState: (contextKey?: import("../../../state/typedef.js").ContextKey) => HkTabBarState;
|
|
54
54
|
export type Tab = import("./typedef.js").Tab;
|
|
@@ -14,6 +14,6 @@ export class HkTabBarSelectorState {
|
|
|
14
14
|
tabBarState: import("./HkTabBar.state.svelte.js").HkTabBarState;
|
|
15
15
|
#private;
|
|
16
16
|
}
|
|
17
|
-
export const createOrGetState: (contextKey?: import("../../../state/
|
|
18
|
-
export const createState: (contextKey?: import("../../../state/
|
|
19
|
-
export const getState: (contextKey?: import("../../../state/
|
|
17
|
+
export const createOrGetState: (contextKey?: import("../../../state/typedef.js").ContextKey) => HkTabBarSelectorState;
|
|
18
|
+
export const createState: (contextKey?: import("../../../state/typedef.js").ContextKey) => HkTabBarSelectorState;
|
|
19
|
+
export const getState: (contextKey?: import("../../../state/typedef.js").ContextKey) => HkTabBarSelectorState;
|
|
@@ -172,12 +172,8 @@ export function findAll<T extends unknown>(arr: T[], selector: object | null): T
|
|
|
172
172
|
* @returns {object}
|
|
173
173
|
*/
|
|
174
174
|
export function arrayToObject(arr: any[], keys: string[]): object;
|
|
175
|
-
export { PATH_SEPARATOR } from "../object/index.js";
|
|
176
|
-
import { smallestFirst } from '../compare/index.js';
|
|
177
|
-
import { largestFirst } from '../compare/index.js';
|
|
178
175
|
export const arraySlice: (start?: number, end?: number) => any[];
|
|
179
176
|
export const arrayConcat: {
|
|
180
177
|
(...items: ConcatArray<any>[]): any[];
|
|
181
178
|
(...items: any[]): any[];
|
|
182
179
|
};
|
|
183
|
-
export { smallestFirst, largestFirst };
|
package/dist/util/array/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* ------------------------------------------------------------------ Imports */
|
|
2
2
|
|
|
3
|
-
import * as expect from '../expect
|
|
3
|
+
import * as expect from '../expect.js';
|
|
4
4
|
|
|
5
5
|
import { smallestFirst, largestFirst } from '../compare/index.js';
|
|
6
6
|
|
|
@@ -15,10 +15,6 @@ const arrayConcat = Array.prototype.concat;
|
|
|
15
15
|
|
|
16
16
|
/* ------------------------------------------------------------------ Exports */
|
|
17
17
|
|
|
18
|
-
export { PATH_SEPARATOR } from '../object/index.js';
|
|
19
|
-
|
|
20
|
-
export { smallestFirst, largestFirst };
|
|
21
|
-
|
|
22
18
|
export { arraySlice, arrayConcat };
|
|
23
19
|
|
|
24
20
|
/**
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./array/index.js";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* base64.js
|
|
3
|
+
*
|
|
4
|
+
* @description
|
|
5
|
+
* This file contains utilities for working with base64 encoding/decoding
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import * as expect from '../expect.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Decode a base64 encoded string into a Uint8Array
|
|
12
|
+
*
|
|
13
|
+
* @param {string} str64 - Base64 encoded string
|
|
14
|
+
*
|
|
15
|
+
* @returns {Uint8Array} byte array that contains the decoded contents
|
|
16
|
+
*/
|
|
17
|
+
export function base64ToUint8Array( str64 )
|
|
18
|
+
{
|
|
19
|
+
expect.string( str64 );
|
|
20
|
+
|
|
21
|
+
const binaryString = atob(str64);
|
|
22
|
+
return Uint8Array.from(binaryString, char => char.charCodeAt(0));
|
|
23
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./base58.js";
|
package/dist/util/bases/index.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './base58.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./compare/index.js";
|
package/dist/util/css/index.d.ts
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./css-vars.js";
|
package/dist/util/css/index.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './css-vars.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./css/css-vars.js";
|
package/dist/util/css.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./env/index.js";
|
package/dist/util/env.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./exceptions/index.js";
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Compound validators - combinations and unions of basic validators */
|
|
2
|
+
/**
|
|
3
|
+
* Throws a validation error if value is not iterable
|
|
4
|
+
*
|
|
5
|
+
* @param {any} value
|
|
6
|
+
*/
|
|
7
|
+
export function expect_iterable(value: any): void;
|
|
8
|
+
/**
|
|
9
|
+
* Throws a validation error if value is not a store (has no subscribe method)
|
|
10
|
+
*
|
|
11
|
+
* @param {any} value
|
|
12
|
+
*/
|
|
13
|
+
export function expect_store(value: any): void;
|
|
14
|
+
/**
|
|
15
|
+
* Throws a validation error if value is not an array or Set
|
|
16
|
+
*
|
|
17
|
+
* @param {any} value
|
|
18
|
+
*/
|
|
19
|
+
export function expect_arrayOrSet(value: any): void;
|
|
20
|
+
export { expect_iterable as iterable, expect_store as store, expect_arrayOrSet as arrayOrSet };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
import * as is from '../is/index.js';
|
|
3
|
+
|
|
4
|
+
/** Compound validators - combinations and unions of basic validators */
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Throws a validation error if value is not iterable
|
|
8
|
+
*
|
|
9
|
+
* @param {any} value
|
|
10
|
+
*/
|
|
11
|
+
export function expect_iterable(value) {
|
|
12
|
+
const schema = v.pipe(v.looseObject({ [Symbol.iterator]: v.function() }));
|
|
13
|
+
|
|
14
|
+
v.parse(schema, value);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { expect_iterable as iterable };
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Throws a validation error if value is not a store (has no subscribe method)
|
|
21
|
+
*
|
|
22
|
+
* @param {any} value
|
|
23
|
+
*/
|
|
24
|
+
export function expect_store(value) {
|
|
25
|
+
v.parse(
|
|
26
|
+
v.custom((value) => {
|
|
27
|
+
if (!is.object(value) || typeof value?.subscribe !== 'function') {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return true;
|
|
32
|
+
}),
|
|
33
|
+
value
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export { expect_store as store };
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Throws a validation error if value is not an array or Set
|
|
41
|
+
*
|
|
42
|
+
* @param {any} value
|
|
43
|
+
*/
|
|
44
|
+
export function expect_arrayOrSet(value) {
|
|
45
|
+
v.parse(v.union([v.instance(Array), v.instance(Set)]), value);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export { expect_arrayOrSet as arrayOrSet };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Throws a validation error if value is not an object or the value
|
|
3
|
+
* is an array
|
|
4
|
+
*
|
|
5
|
+
* @param {any} value
|
|
6
|
+
*/
|
|
7
|
+
export function expect_objectNoArray(value: any): void;
|
|
8
|
+
/**
|
|
9
|
+
* Throws a validation error if value is not an object or the value
|
|
10
|
+
* is a function
|
|
11
|
+
*
|
|
12
|
+
* @param {any} value
|
|
13
|
+
*/
|
|
14
|
+
export function expect_objectNoFunction(value: any): void;
|
|
15
|
+
/**
|
|
16
|
+
* Throws a validation error if value is not an object or null
|
|
17
|
+
*
|
|
18
|
+
* @param {any} value
|
|
19
|
+
*/
|
|
20
|
+
export function expect_objectOrNull(value: any): void;
|
|
21
|
+
/** Object-related validators */
|
|
22
|
+
/**
|
|
23
|
+
* Throws a validation error if value is not an object
|
|
24
|
+
*
|
|
25
|
+
* @param {any} value
|
|
26
|
+
*/
|
|
27
|
+
declare function expect_object(value: any): void;
|
|
28
|
+
export { expect_object as object, expect_objectNoArray as objectNoArray, expect_objectNoFunction as objectNoFunction, expect_objectOrNull as objectOrNull };
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
import * as is from '../is/index.js';
|
|
3
|
+
|
|
4
|
+
/** Internals */
|
|
5
|
+
|
|
6
|
+
const ObjectSchema = v.custom(is.object, `Invalid type: Expected object`);
|
|
7
|
+
|
|
8
|
+
/** Object-related validators */
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Throws a validation error if value is not an object
|
|
12
|
+
*
|
|
13
|
+
* @param {any} value
|
|
14
|
+
*/
|
|
15
|
+
function expect_object(value) {
|
|
16
|
+
v.parse(ObjectSchema, value);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { expect_object as object };
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Throws a validation error if value is not an object or the value
|
|
23
|
+
* is an array
|
|
24
|
+
*
|
|
25
|
+
* @param {any} value
|
|
26
|
+
*/
|
|
27
|
+
export function expect_objectNoArray(value) {
|
|
28
|
+
v.parse(
|
|
29
|
+
v.custom((value) => {
|
|
30
|
+
if (!is.object(value) || value instanceof Array) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return true;
|
|
35
|
+
}),
|
|
36
|
+
value
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Throws a validation error if value is not an object or the value
|
|
42
|
+
* is a function
|
|
43
|
+
*
|
|
44
|
+
* @param {any} value
|
|
45
|
+
*/
|
|
46
|
+
export function expect_objectNoFunction(value) {
|
|
47
|
+
v.parse(
|
|
48
|
+
v.custom((value) => {
|
|
49
|
+
if (!is.object(value) || typeof value === 'function') {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return true;
|
|
54
|
+
}),
|
|
55
|
+
value
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Throws a validation error if value is not an object or null
|
|
61
|
+
*
|
|
62
|
+
* @param {any} value
|
|
63
|
+
*/
|
|
64
|
+
export function expect_objectOrNull(value) {
|
|
65
|
+
v.parse(v.union([v.literal(null), v.looseObject({})]), value);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export { expect_objectNoArray as objectNoArray };
|
|
69
|
+
export { expect_objectNoFunction as objectNoFunction };
|
|
70
|
+
export { expect_objectOrNull as objectOrNull };
|
|
@@ -28,4 +28,34 @@ export function expect_symbol(value: any): void;
|
|
|
28
28
|
* @param {any} value
|
|
29
29
|
*/
|
|
30
30
|
export function expect_defined(value: any): void;
|
|
31
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Throws a validation error if value is not a function
|
|
33
|
+
*
|
|
34
|
+
* @param {any} value
|
|
35
|
+
*/
|
|
36
|
+
export function expect_function(value: any): void;
|
|
37
|
+
/**
|
|
38
|
+
* Throws a validation error if value is not a Promise
|
|
39
|
+
*
|
|
40
|
+
* @param {any} value
|
|
41
|
+
*/
|
|
42
|
+
export function expect_promise(value: any): void;
|
|
43
|
+
/**
|
|
44
|
+
* Throws a validation error if value is not a Map
|
|
45
|
+
*
|
|
46
|
+
* @param {any} value
|
|
47
|
+
*/
|
|
48
|
+
export function expect_map(value: any): void;
|
|
49
|
+
/**
|
|
50
|
+
* Throws a validation error if value is not a Set
|
|
51
|
+
*
|
|
52
|
+
* @param {any} value
|
|
53
|
+
*/
|
|
54
|
+
export function expect_set(value: any): void;
|
|
55
|
+
/**
|
|
56
|
+
* Throws a validation error if value is not an Error instance
|
|
57
|
+
*
|
|
58
|
+
* @param {any} value
|
|
59
|
+
*/
|
|
60
|
+
export function expect_error(value: any): void;
|
|
61
|
+
export { expect_string as string, expect_boolean as boolean, expect_number as number, expect_symbol as symbol, expect_defined as defined, expect_function as function, _function as function, expect_function as class, _class as class, expect_promise as promise, expect_map as map, expect_set as set, expect_error as error };
|
|
@@ -63,3 +63,59 @@ export function expect_defined(value) {
|
|
|
63
63
|
}
|
|
64
64
|
|
|
65
65
|
export { expect_defined as defined };
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Throws a validation error if value is not a function
|
|
69
|
+
*
|
|
70
|
+
* @param {any} value
|
|
71
|
+
*/
|
|
72
|
+
export function expect_function(value) {
|
|
73
|
+
v.parse(v.function(), value);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export { expect_function as function };
|
|
77
|
+
export { expect_function as class };
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Throws a validation error if value is not a Promise
|
|
81
|
+
*
|
|
82
|
+
* @param {any} value
|
|
83
|
+
*/
|
|
84
|
+
export function expect_promise(value) {
|
|
85
|
+
v.parse(v.instance(Promise), value);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export { expect_promise as promise };
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Throws a validation error if value is not a Map
|
|
92
|
+
*
|
|
93
|
+
* @param {any} value
|
|
94
|
+
*/
|
|
95
|
+
export function expect_map(value) {
|
|
96
|
+
v.parse(v.instance(Map), value);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export { expect_map as map };
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Throws a validation error if value is not a Set
|
|
103
|
+
*
|
|
104
|
+
* @param {any} value
|
|
105
|
+
*/
|
|
106
|
+
export function expect_set(value) {
|
|
107
|
+
v.parse(v.instance(Set), value);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export { expect_set as set };
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Throws a validation error if value is not an Error instance
|
|
114
|
+
*
|
|
115
|
+
* @param {any} value
|
|
116
|
+
*/
|
|
117
|
+
export function expect_error(value) {
|
|
118
|
+
v.parse(v.instance(Error), value);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export { expect_error as error };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Value/constraint validators */
|
|
2
|
+
/**
|
|
3
|
+
* Expect a value not to be null
|
|
4
|
+
*
|
|
5
|
+
* @param {any} value
|
|
6
|
+
*/
|
|
7
|
+
export function expect_notNull(value: any): void;
|
|
8
|
+
/**
|
|
9
|
+
* Expect a value to be a boolean and true
|
|
10
|
+
*
|
|
11
|
+
* @param {any} value
|
|
12
|
+
*/
|
|
13
|
+
export function expect_true(value: any): void;
|
|
14
|
+
/**
|
|
15
|
+
* Expect a positive number
|
|
16
|
+
*
|
|
17
|
+
* @param {any} value
|
|
18
|
+
*/
|
|
19
|
+
export function expect_positiveNumber(value: any): void;
|
|
20
|
+
/**
|
|
21
|
+
* Throws a validation error if value is not a string
|
|
22
|
+
*
|
|
23
|
+
* @param {any} value
|
|
24
|
+
*/
|
|
25
|
+
export function expect_notEmptyString(value: any): void;
|
|
26
|
+
export { expect_true as true, _true as true, expect_notNull as notNull, expect_positiveNumber as positiveNumber, expect_notEmptyString as notEmptyString };
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as v from 'valibot';
|
|
2
|
+
|
|
3
|
+
/** Value/constraint validators */
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Expect a value not to be null
|
|
7
|
+
*
|
|
8
|
+
* @param {any} value
|
|
9
|
+
*/
|
|
10
|
+
export function expect_notNull(value) {
|
|
11
|
+
v.notValue(null, value);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Expect a value to be a boolean and true
|
|
16
|
+
*
|
|
17
|
+
* @param {any} value
|
|
18
|
+
*/
|
|
19
|
+
export function expect_true(value) {
|
|
20
|
+
v.value(true, value);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export { expect_true as true };
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Expect a positive number
|
|
27
|
+
*
|
|
28
|
+
* @param {any} value
|
|
29
|
+
*/
|
|
30
|
+
export function expect_positiveNumber(value) {
|
|
31
|
+
const schema = v.pipe(v.number(), v.minValue(0));
|
|
32
|
+
v.parse(schema, value);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Throws a validation error if value is not a string
|
|
37
|
+
*
|
|
38
|
+
* @param {any} value
|
|
39
|
+
*/
|
|
40
|
+
export function expect_notEmptyString(value) {
|
|
41
|
+
const schema = v.pipe(v.string(), v.minLength(1));
|
|
42
|
+
|
|
43
|
+
v.parse(schema, value);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export { expect_notNull as notNull };
|
|
47
|
+
export { expect_positiveNumber as positiveNumber };
|
|
48
|
+
export { expect_notEmptyString as notEmptyString };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validation functions that can be used as safe guards in your code
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
*
|
|
6
|
+
* import * as expect from 'util/expect.js';
|
|
7
|
+
*
|
|
8
|
+
* function logText( text )
|
|
9
|
+
* {
|
|
10
|
+
* expect.string( text );
|
|
11
|
+
* expect.true( 1 > 0 );
|
|
12
|
+
*
|
|
13
|
+
* console.log( text );
|
|
14
|
+
* }
|
|
15
|
+
*
|
|
16
|
+
* logText( 'Hello' );
|
|
17
|
+
* logText( 123 ); // <- Will throw an exception
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
export * from './expect/arrays.js';
|
|
21
|
+
export * from './expect/primitives.js';
|
|
22
|
+
export * from './expect/url.js';
|
|
23
|
+
export * from './expect/objects.js';
|
|
24
|
+
export * from './expect/values.js';
|
|
25
|
+
export * from './expect/compounds.js';
|
|
26
|
+
|
|
27
|
+
// TODO: Implement these validators as needed
|
|
28
|
+
// notNegativeNumber, positiveInteger, notNegativeInteger
|
|
29
|
+
// stringOrNull, stringOrUndefined, notEmptyStringOrNull
|
|
30
|
+
// ArrayBuffer, arrayOrUndefined, arangoCollectionId, uriComponent
|
|
31
|
+
// objectOrUndefined, objectPath, asyncIterator
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
/* ------------------------------------------------------------------ Imports */
|
|
26
26
|
|
|
27
|
-
import * as expect from '../expect
|
|
27
|
+
import * as expect from '../expect.js';
|
|
28
28
|
|
|
29
29
|
/* ---------------------------------------------------------------- Internals */
|
|
30
30
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./function/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./geometry/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./is/index.js";
|
package/dist/util/is.js
ADDED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* ------------------------------------------------------------------ Imports */
|
|
2
2
|
|
|
3
|
-
import * as expect from '../expect
|
|
3
|
+
import * as expect from '../expect.js';
|
|
4
4
|
import { smallestFirst, largestFirst } from '../compare/index.js';
|
|
5
5
|
|
|
6
6
|
import { IterableTree } from '../../generic/data.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./iterate/index.js";
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/* ------------------------------------------------------------------ Imports */
|
|
2
2
|
|
|
3
|
-
import * as expect from '../expect
|
|
3
|
+
import * as expect from '../expect.js';
|
|
4
4
|
|
|
5
5
|
import { equals } from '../compare/index.js';
|
|
6
6
|
|
|
7
7
|
import { toArrayPath } from '../array/index.js';
|
|
8
8
|
|
|
9
|
-
import { toStringPath } from '../string
|
|
9
|
+
import { toStringPath } from '../string.js';
|
|
10
10
|
|
|
11
11
|
import * as is from '../is/index.js';
|
|
12
12
|
|