@pithos/core 2.0.1 → 2.1.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.
- package/dist/.tsbuildinfo +1 -1
- package/dist/arkhe/array/to-array.d.ts +1 -1
- package/dist/arkhe/async/parallel.js +1 -1
- package/dist/arkhe/async/retry.js +1 -1
- package/dist/arkhe/number/parsers/parse-float-def.d.ts +1 -1
- package/dist/arkhe/number/parsers/parse-float-def.js +1 -1
- package/dist/arkhe/number/parsers/parse-int-def.d.ts +1 -1
- package/dist/arkhe/object/defaults-deep.js +1 -1
- package/dist/arkhe/object/get.js +1 -1
- package/dist/arkhe/object/merge-with.js +1 -1
- package/dist/arkhe/object/set.js +2 -2
- package/dist/arkhe/string/pascal-case.js +1 -1
- package/dist/arkhe/test/console.js +1 -1
- package/dist/autocompletion.d.ts +719 -699
- package/dist/bridges/ensure.d.ts +28 -0
- package/dist/bridges/ensure.d.ts.map +1 -0
- package/dist/bridges/ensure.js +31 -0
- package/dist/bridges/ensure.js.map +1 -0
- package/dist/bridges/ensureAsync.d.ts +27 -0
- package/dist/bridges/ensureAsync.d.ts.map +1 -0
- package/dist/bridges/ensureAsync.js +30 -0
- package/dist/bridges/ensureAsync.js.map +1 -0
- package/dist/bridges/ensurePromise.d.ts +28 -0
- package/dist/bridges/ensurePromise.d.ts.map +1 -0
- package/dist/bridges/ensurePromise.js +33 -0
- package/dist/bridges/ensurePromise.js.map +1 -0
- package/dist/kanon/core/parser.d.ts +1 -1
- package/dist/kanon/core/parser.js +1 -1
- package/dist/kanon/helpers/as-zod.d.ts +1 -1
- package/dist/kanon/helpers/as-zod.js +2 -2
- package/dist/kanon/helpers/as-zod.shim.d.ts +1 -1
- package/dist/kanon/helpers/as-zod.shim.js +3 -3
- package/dist/kanon/helpers/k.d.ts +42 -42
- package/dist/kanon/helpers/k.js +41 -41
- package/dist/kanon/index.d.ts +56 -56
- package/dist/kanon/index.js +46 -46
- package/dist/kanon/jit/builders/coerce.d.ts +2 -2
- package/dist/kanon/jit/builders/coerce.js +2 -2
- package/dist/kanon/jit/builders/composites/array.d.ts +2 -2
- package/dist/kanon/jit/builders/composites/array.js +2 -2
- package/dist/kanon/jit/builders/composites/object.d.ts +3 -3
- package/dist/kanon/jit/builders/composites/object.js +2 -2
- package/dist/kanon/jit/builders/operators/union.d.ts +1 -1
- package/dist/kanon/jit/builders/operators/union.js +3 -3
- package/dist/kanon/jit/builders/primitives/boolean.d.ts +2 -2
- package/dist/kanon/jit/builders/primitives/boolean.js +3 -3
- package/dist/kanon/jit/builders/primitives/number.d.ts +2 -2
- package/dist/kanon/jit/builders/primitives/number.js +3 -3
- package/dist/kanon/jit/builders/primitives/others.d.ts +2 -2
- package/dist/kanon/jit/builders/primitives/others.js +3 -3
- package/dist/kanon/jit/builders/primitives/string.d.ts +2 -2
- package/dist/kanon/jit/builders/primitives/string.js +4 -4
- package/dist/kanon/jit/builders/refinements.d.ts +2 -2
- package/dist/kanon/jit/builders/refinements.js +2 -2
- package/dist/kanon/jit/cache.d.ts +1 -1
- package/dist/kanon/jit/compiler.d.ts +4 -4
- package/dist/kanon/jit/compiler.js +14 -14
- package/dist/kanon/jit/context.d.ts +1 -1
- package/dist/kanon/jit/utils/arbitraries.d.ts +1 -1
- package/dist/kanon/jit/utils/arbitraries.js +6 -6
- package/dist/kanon/jit/utils/code.d.ts +1 -1
- package/dist/kanon/jit/utils/code.js +1 -1
- package/dist/kanon/schemas/coerce/bigint.d.ts +1 -1
- package/dist/kanon/schemas/coerce/bigint.js +2 -2
- package/dist/kanon/schemas/coerce/boolean.d.ts +1 -1
- package/dist/kanon/schemas/coerce/date.d.ts +1 -1
- package/dist/kanon/schemas/coerce/date.js +2 -2
- package/dist/kanon/schemas/coerce/number.d.ts +1 -1
- package/dist/kanon/schemas/coerce/number.js +2 -2
- package/dist/kanon/schemas/coerce/string.d.ts +1 -1
- package/dist/kanon/schemas/coerce/string.js +2 -2
- package/dist/kanon/schemas/composites/array.d.ts +2 -2
- package/dist/kanon/schemas/composites/array.js +3 -3
- package/dist/kanon/schemas/composites/map.d.ts +2 -2
- package/dist/kanon/schemas/composites/map.js +3 -3
- package/dist/kanon/schemas/composites/object.d.ts +2 -2
- package/dist/kanon/schemas/composites/object.js +3 -3
- package/dist/kanon/schemas/composites/record.d.ts +2 -2
- package/dist/kanon/schemas/composites/record.js +2 -2
- package/dist/kanon/schemas/composites/set.d.ts +2 -2
- package/dist/kanon/schemas/composites/set.js +3 -3
- package/dist/kanon/schemas/composites/tuple.d.ts +2 -2
- package/dist/kanon/schemas/composites/tuple.js +2 -2
- package/dist/kanon/schemas/constraints/array.d.ts +3 -3
- package/dist/kanon/schemas/constraints/array.js +2 -2
- package/dist/kanon/schemas/constraints/bigint.d.ts +2 -2
- package/dist/kanon/schemas/constraints/bigint.js +2 -2
- package/dist/kanon/schemas/constraints/date.d.ts +2 -2
- package/dist/kanon/schemas/constraints/date.js +2 -2
- package/dist/kanon/schemas/constraints/map.d.ts +3 -3
- package/dist/kanon/schemas/constraints/map.js +2 -2
- package/dist/kanon/schemas/constraints/number.d.ts +2 -2
- package/dist/kanon/schemas/constraints/number.js +2 -2
- package/dist/kanon/schemas/constraints/object.d.ts +3 -3
- package/dist/kanon/schemas/constraints/object.js +2 -2
- package/dist/kanon/schemas/constraints/refine/array.d.ts +3 -3
- package/dist/kanon/schemas/constraints/refine/array.js +2 -2
- package/dist/kanon/schemas/constraints/refine/bigint.d.ts +2 -2
- package/dist/kanon/schemas/constraints/refine/date.d.ts +2 -2
- package/dist/kanon/schemas/constraints/refine/map.d.ts +3 -3
- package/dist/kanon/schemas/constraints/refine/map.js +2 -2
- package/dist/kanon/schemas/constraints/refine/number.d.ts +2 -2
- package/dist/kanon/schemas/constraints/refine/object.d.ts +3 -3
- package/dist/kanon/schemas/constraints/refine/object.js +2 -2
- package/dist/kanon/schemas/constraints/refine/set.d.ts +3 -3
- package/dist/kanon/schemas/constraints/refine/set.js +2 -2
- package/dist/kanon/schemas/constraints/refine/string.d.ts +2 -2
- package/dist/kanon/schemas/constraints/set.d.ts +3 -3
- package/dist/kanon/schemas/constraints/set.js +2 -2
- package/dist/kanon/schemas/constraints/string.d.ts +2 -2
- package/dist/kanon/schemas/constraints/string.js +3 -3
- package/dist/kanon/schemas/operators/intersection.d.ts +2 -2
- package/dist/kanon/schemas/operators/union.d.ts +2 -2
- package/dist/kanon/schemas/operators/union.js +1 -1
- package/dist/kanon/schemas/primitives/any.d.ts +1 -1
- package/dist/kanon/schemas/primitives/bigint.d.ts +1 -1
- package/dist/kanon/schemas/primitives/bigint.js +2 -2
- package/dist/kanon/schemas/primitives/boolean.d.ts +1 -1
- package/dist/kanon/schemas/primitives/boolean.js +1 -1
- package/dist/kanon/schemas/primitives/date.d.ts +1 -1
- package/dist/kanon/schemas/primitives/date.js +2 -2
- package/dist/kanon/schemas/primitives/enum.d.ts +1 -1
- package/dist/kanon/schemas/primitives/enum.js +1 -1
- package/dist/kanon/schemas/primitives/int.d.ts +1 -1
- package/dist/kanon/schemas/primitives/int.js +1 -1
- package/dist/kanon/schemas/primitives/literal.d.ts +1 -1
- package/dist/kanon/schemas/primitives/literal.js +1 -1
- package/dist/kanon/schemas/primitives/nativeEnum.d.ts +1 -1
- package/dist/kanon/schemas/primitives/nativeEnum.js +1 -1
- package/dist/kanon/schemas/primitives/never.d.ts +1 -1
- package/dist/kanon/schemas/primitives/never.js +1 -1
- package/dist/kanon/schemas/primitives/null.d.ts +1 -1
- package/dist/kanon/schemas/primitives/null.js +1 -1
- package/dist/kanon/schemas/primitives/number.d.ts +1 -1
- package/dist/kanon/schemas/primitives/number.js +2 -2
- package/dist/kanon/schemas/primitives/string.d.ts +1 -1
- package/dist/kanon/schemas/primitives/string.js +2 -2
- package/dist/kanon/schemas/primitives/symbol.d.ts +1 -1
- package/dist/kanon/schemas/primitives/symbol.js +1 -1
- package/dist/kanon/schemas/primitives/undefined.d.ts +1 -1
- package/dist/kanon/schemas/primitives/undefined.js +1 -1
- package/dist/kanon/schemas/primitives/unknown.d.ts +1 -1
- package/dist/kanon/schemas/primitives/void.d.ts +1 -1
- package/dist/kanon/schemas/primitives/void.js +1 -1
- package/dist/kanon/schemas/transforms/keyof.d.ts +4 -4
- package/dist/kanon/schemas/transforms/keyof.js +1 -1
- package/dist/kanon/schemas/transforms/omit.d.ts +4 -4
- package/dist/kanon/schemas/transforms/omit.js +1 -1
- package/dist/kanon/schemas/transforms/partial.d.ts +4 -4
- package/dist/kanon/schemas/transforms/partial.js +1 -1
- package/dist/kanon/schemas/transforms/pick.d.ts +4 -4
- package/dist/kanon/schemas/transforms/pick.js +1 -1
- package/dist/kanon/schemas/transforms/required.d.ts +4 -4
- package/dist/kanon/schemas/transforms/required.js +1 -1
- package/dist/kanon/schemas/wrappers/default.d.ts +2 -2
- package/dist/kanon/schemas/wrappers/lazy.d.ts +2 -2
- package/dist/kanon/schemas/wrappers/nullable.d.ts +2 -2
- package/dist/kanon/schemas/wrappers/nullish.d.ts +2 -2
- package/dist/kanon/schemas/wrappers/optional.d.ts +2 -2
- package/dist/kanon/schemas/wrappers/readonly.d.ts +2 -2
- package/dist/kanon/types/composites.d.ts +1 -1
- package/dist/kanon/types/constraints.d.ts +1 -1
- package/dist/kanon/types/guards.d.ts +7 -7
- package/dist/kanon/types/operators.d.ts +2 -2
- package/dist/kanon/types/primitives.d.ts +1 -1
- package/dist/kanon/types/transforms.d.ts +1 -1
- package/dist/kanon/types/wrappers.d.ts +1 -1
- package/dist/kanon/validation.d.ts +1 -1
- package/dist/kanon/validation.js +1 -1
- package/dist/taphos/array/nth.js +1 -1
- package/dist/taphos/array/pull-all.js +1 -1
- package/dist/taphos/array/pullAllBy.js +1 -1
- package/dist/taphos/array/pullAllWith.js +1 -1
- package/dist/taphos/array/without.js +1 -1
- package/dist/taphos/object/at.js +1 -1
- package/dist/taphos/object/extend.js +1 -1
- package/dist/taphos/object/invoke.js +1 -1
- package/dist/taphos/object/unset.js +2 -2
- package/dist/taphos/object/update.js +2 -2
- package/dist/taphos/util/rangeRight.js +1 -1
- package/dist/zygos/either.d.ts +1 -1
- package/dist/zygos/either.js +1 -1
- package/dist/zygos/option.d.ts +1 -1
- package/dist/zygos/result/result-async.d.ts +5 -5
- package/dist/zygos/result/result-async.js +5 -5
- package/dist/zygos/result/result.d.ts +3 -3
- package/dist/zygos/result/result.js +4 -4
- package/dist/zygos/safe.d.ts +1 -1
- package/dist/zygos/safe.js +1 -1
- package/dist/zygos/task-either.d.ts +3 -3
- package/dist/zygos/task-either.js +3 -3
- package/package.json +7 -2
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Schema } from "../kanon/types/base.js";
|
|
2
|
+
import type { Result } from "../zygos/result/result.js";
|
|
3
|
+
/**
|
|
4
|
+
* Parses a value against a Kanon schema and returns a Zygos `Result`.
|
|
5
|
+
*
|
|
6
|
+
* Bridge between Kanon validation and Zygos error handling:
|
|
7
|
+
* instead of checking `result.success`, you get a chainable `Result<T, string>`.
|
|
8
|
+
*
|
|
9
|
+
* @template T - The expected output type of the schema.
|
|
10
|
+
* @param schema - Kanon schema to validate against.
|
|
11
|
+
* @param input - Value to validate.
|
|
12
|
+
* @returns `Ok<T>` if validation succeeds, `Err<string>` otherwise.
|
|
13
|
+
* @since 2.1.0
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import { ensure } from "pithos/bridges/ensure";
|
|
18
|
+
* import { object, string, number } from "pithos/kanon";
|
|
19
|
+
*
|
|
20
|
+
* const schema = object({ name: string(), age: number() });
|
|
21
|
+
*
|
|
22
|
+
* ensure(schema, data)
|
|
23
|
+
* .map(user => user.name.toUpperCase())
|
|
24
|
+
* .mapErr(error => `Validation failed: ${error}`);
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function ensure<T>(schema: Schema<T>, input: unknown): Result<T, string>;
|
|
28
|
+
//# sourceMappingURL=ensure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensure.d.ts","sourceRoot":"","sources":["../../src/bridges/ensure.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEnD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,MAAM,CAAC,CAAC,EACtB,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EACjB,KAAK,EAAE,OAAO,GACb,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAGnB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { parse } from "../kanon/core/parser.js";
|
|
2
|
+
import { ok, err } from "../zygos/result/result.js";
|
|
3
|
+
/**
|
|
4
|
+
* Parses a value against a Kanon schema and returns a Zygos `Result`.
|
|
5
|
+
*
|
|
6
|
+
* Bridge between Kanon validation and Zygos error handling:
|
|
7
|
+
* instead of checking `result.success`, you get a chainable `Result<T, string>`.
|
|
8
|
+
*
|
|
9
|
+
* @template T - The expected output type of the schema.
|
|
10
|
+
* @param schema - Kanon schema to validate against.
|
|
11
|
+
* @param input - Value to validate.
|
|
12
|
+
* @returns `Ok<T>` if validation succeeds, `Err<string>` otherwise.
|
|
13
|
+
* @since 2.1.0
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import { ensure } from "pithos/bridges/ensure";
|
|
18
|
+
* import { object, string, number } from "pithos/kanon";
|
|
19
|
+
*
|
|
20
|
+
* const schema = object({ name: string(), age: number() });
|
|
21
|
+
*
|
|
22
|
+
* ensure(schema, data)
|
|
23
|
+
* .map(user => user.name.toUpperCase())
|
|
24
|
+
* .mapErr(error => `Validation failed: ${error}`);
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export function ensure(schema, input) {
|
|
28
|
+
const result = parse(schema, input);
|
|
29
|
+
return result.success ? ok(result.data) : err(result.error);
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=ensure.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensure.js","sourceRoot":"","sources":["../../src/bridges/ensure.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,sBAAsB,CAAC;AAI/C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,MAAM,CACpB,MAAiB,EACjB,KAAc;IAEd,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACpC,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Schema } from "../kanon/types/base.js";
|
|
2
|
+
import type { ResultAsync } from "../zygos/result/result-async.js";
|
|
3
|
+
/**
|
|
4
|
+
* Parses a value against a Kanon schema and returns a Zygos `ResultAsync`.
|
|
5
|
+
*
|
|
6
|
+
* Async variant of `ensure` — designed for `ResultAsync` chains
|
|
7
|
+
* where validation is one step in an async pipeline.
|
|
8
|
+
*
|
|
9
|
+
* @template T - The expected output type of the schema.
|
|
10
|
+
* @param schema - Kanon schema to validate against.
|
|
11
|
+
* @param input - Value to validate.
|
|
12
|
+
* @returns `OkAsync<T>` if validation succeeds, `ErrAsync<string>` otherwise.
|
|
13
|
+
* @since 2.1.0
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import { ensureAsync } from "pithos/bridges/ensureAsync";
|
|
18
|
+
* import { object, string, number } from "pithos/kanon";
|
|
19
|
+
*
|
|
20
|
+
* safeFetch("/api/user")
|
|
21
|
+
* .andThen(res => safeJson(res))
|
|
22
|
+
* .andThen(data => ensureAsync(UserSchema, data))
|
|
23
|
+
* .map(user => user.name);
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function ensureAsync<T>(schema: Schema<T>, input: unknown): ResultAsync<T, string>;
|
|
27
|
+
//# sourceMappingURL=ensureAsync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensureAsync.d.ts","sourceRoot":"","sources":["../../src/bridges/ensureAsync.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAC3B,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EACjB,KAAK,EAAE,OAAO,GACb,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC,CAGxB"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { parse } from "../kanon/core/parser.js";
|
|
2
|
+
import { okAsync, errAsync } from "../zygos/result/result-async.js";
|
|
3
|
+
/**
|
|
4
|
+
* Parses a value against a Kanon schema and returns a Zygos `ResultAsync`.
|
|
5
|
+
*
|
|
6
|
+
* Async variant of `ensure` — designed for `ResultAsync` chains
|
|
7
|
+
* where validation is one step in an async pipeline.
|
|
8
|
+
*
|
|
9
|
+
* @template T - The expected output type of the schema.
|
|
10
|
+
* @param schema - Kanon schema to validate against.
|
|
11
|
+
* @param input - Value to validate.
|
|
12
|
+
* @returns `OkAsync<T>` if validation succeeds, `ErrAsync<string>` otherwise.
|
|
13
|
+
* @since 2.1.0
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import { ensureAsync } from "pithos/bridges/ensureAsync";
|
|
18
|
+
* import { object, string, number } from "pithos/kanon";
|
|
19
|
+
*
|
|
20
|
+
* safeFetch("/api/user")
|
|
21
|
+
* .andThen(res => safeJson(res))
|
|
22
|
+
* .andThen(data => ensureAsync(UserSchema, data))
|
|
23
|
+
* .map(user => user.name);
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export function ensureAsync(schema, input) {
|
|
27
|
+
const result = parse(schema, input);
|
|
28
|
+
return result.success ? okAsync(result.data) : errAsync(result.error);
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=ensureAsync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensureAsync.js","sourceRoot":"","sources":["../../src/bridges/ensureAsync.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAI/D;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,WAAW,CACzB,MAAiB,EACjB,KAAc;IAEd,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IACpC,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AACxE,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { ResultAsync } from "../zygos/result/result-async.js";
|
|
2
|
+
import type { Schema } from "../kanon/types/base.js";
|
|
3
|
+
/**
|
|
4
|
+
* Resolves a Promise, validates the result against a Kanon schema,
|
|
5
|
+
* and returns a `ResultAsync`.
|
|
6
|
+
*
|
|
7
|
+
* Eliminates the `ResultAsync.fromPromise(...).andThen(...)` boilerplate
|
|
8
|
+
* when you need to fetch data and validate it in one step.
|
|
9
|
+
*
|
|
10
|
+
* @template T - The expected output type of the schema.
|
|
11
|
+
* @param schema - Kanon schema to validate against.
|
|
12
|
+
* @param promise - Promise that resolves to the value to validate.
|
|
13
|
+
* @returns `ResultAsync<T, string>` — `Ok<T>` if the promise resolves and validation succeeds, `Err<string>` otherwise.
|
|
14
|
+
* @since 2.1.0
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { ensurePromise } from "pithos/bridges/ensurePromise";
|
|
19
|
+
* import { object, string, number } from "pithos/kanon";
|
|
20
|
+
*
|
|
21
|
+
* const UserSchema = object({ name: string(), age: number() });
|
|
22
|
+
*
|
|
23
|
+
* ensurePromise(UserSchema, fetch("/api/user").then(r => r.json()))
|
|
24
|
+
* .map(user => user.name.toUpperCase());
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function ensurePromise<T>(schema: Schema<T>, promise: Promise<unknown>): ResultAsync<T, string>;
|
|
28
|
+
//# sourceMappingURL=ensurePromise.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensurePromise.d.ts","sourceRoot":"","sources":["../../src/bridges/ensurePromise.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAqB,MAAM,4BAA4B,CAAC;AAC5E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEhD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAC7B,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,EACjB,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,GACxB,WAAW,CAAC,CAAC,EAAE,MAAM,CAAC,CAQxB"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { parse } from "../kanon/core/parser.js";
|
|
2
|
+
import { ResultAsync, okAsync, errAsync } from "../zygos/result/result-async.js";
|
|
3
|
+
/**
|
|
4
|
+
* Resolves a Promise, validates the result against a Kanon schema,
|
|
5
|
+
* and returns a `ResultAsync`.
|
|
6
|
+
*
|
|
7
|
+
* Eliminates the `ResultAsync.fromPromise(...).andThen(...)` boilerplate
|
|
8
|
+
* when you need to fetch data and validate it in one step.
|
|
9
|
+
*
|
|
10
|
+
* @template T - The expected output type of the schema.
|
|
11
|
+
* @param schema - Kanon schema to validate against.
|
|
12
|
+
* @param promise - Promise that resolves to the value to validate.
|
|
13
|
+
* @returns `ResultAsync<T, string>` — `Ok<T>` if the promise resolves and validation succeeds, `Err<string>` otherwise.
|
|
14
|
+
* @since 2.1.0
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* import { ensurePromise } from "pithos/bridges/ensurePromise";
|
|
19
|
+
* import { object, string, number } from "pithos/kanon";
|
|
20
|
+
*
|
|
21
|
+
* const UserSchema = object({ name: string(), age: number() });
|
|
22
|
+
*
|
|
23
|
+
* ensurePromise(UserSchema, fetch("/api/user").then(r => r.json()))
|
|
24
|
+
* .map(user => user.name.toUpperCase());
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export function ensurePromise(schema, promise) {
|
|
28
|
+
return ResultAsync.fromPromise(promise, (e) => e instanceof Error ? e.message : String(e)).andThen((data) => {
|
|
29
|
+
const result = parse(schema, data);
|
|
30
|
+
return result.success ? okAsync(result.data) : errAsync(result.error);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=ensurePromise.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensurePromise.js","sourceRoot":"","sources":["../../src/bridges/ensurePromise.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAG5E;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,aAAa,CAC3B,MAAiB,EACjB,OAAyB;IAEzB,OAAO,WAAW,CAAC,WAAW,CAC5B,OAAO,EACP,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAClD,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QACjB,MAAM,MAAM,GAAG,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;QACnC,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACxE,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { array, intersection, nullable, nullish, optional, readonly as readonlyWrapper, unionOf, parse, } from "../index";
|
|
2
|
-
import { isCoerced } from "../types/base";
|
|
1
|
+
import { array, intersection, nullable, nullish, optional, readonly as readonlyWrapper, unionOf, parse, } from "../index.js";
|
|
2
|
+
import { isCoerced } from "../types/base.js";
|
|
3
3
|
/**
|
|
4
4
|
* Creates a Zod-compatible error object from a message string.
|
|
5
5
|
*
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { asZod } from "./as-zod";
|
|
2
|
-
import { any as anySchema, array, bigint, boolean, coerceBigInt, coerceBoolean, coerceDate, coerceNumber, coerceString, date, discriminatedUnion as kanonDiscriminatedUnion, enum_ as enumSchema, int, lazy, intersection, literal, looseObject, map, nativeEnum, never, null_ as nullSchema, number, object, record, set, strictObject, string, symbol as symbolSchema, tuple, tupleWithRest, undefined_ as undefinedSchema, unknown, void_ as voidSchema, partial as kanonPartial, required as kanonRequired, pick as kanonPick, omit as kanonOmit, keyof as kanonKeyof, } from "../index";
|
|
3
|
-
import { ERROR_MESSAGES_COMPOSITION } from "../core/consts/messages";
|
|
1
|
+
import { asZod } from "./as-zod.js";
|
|
2
|
+
import { any as anySchema, array, bigint, boolean, coerceBigInt, coerceBoolean, coerceDate, coerceNumber, coerceString, date, discriminatedUnion as kanonDiscriminatedUnion, enum_ as enumSchema, int, lazy, intersection, literal, looseObject, map, nativeEnum, never, null_ as nullSchema, number, object, record, set, strictObject, string, symbol as symbolSchema, tuple, tupleWithRest, undefined_ as undefinedSchema, unknown, void_ as voidSchema, partial as kanonPartial, required as kanonRequired, pick as kanonPick, omit as kanonOmit, keyof as kanonKeyof, } from "../index.js";
|
|
3
|
+
import { ERROR_MESSAGES_COMPOSITION } from "../core/consts/messages.js";
|
|
4
4
|
/**
|
|
5
5
|
* Zod-compatible API shim for Kanon V3.
|
|
6
6
|
*
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import { string } from "../schemas/primitives/string";
|
|
2
|
-
import { number } from "../schemas/primitives/number";
|
|
3
|
-
import { boolean } from "../schemas/primitives/boolean";
|
|
4
|
-
import { date } from "../schemas/primitives/date";
|
|
5
|
-
import { bigint } from "../schemas/primitives/bigint";
|
|
6
|
-
import { symbol } from "../schemas/primitives/symbol";
|
|
7
|
-
import { int } from "../schemas/primitives/int";
|
|
8
|
-
import { null_ } from "../schemas/primitives/null";
|
|
9
|
-
import { undefined_ } from "../schemas/primitives/undefined";
|
|
10
|
-
import { void_ } from "../schemas/primitives/void";
|
|
11
|
-
import { never } from "../schemas/primitives/never";
|
|
12
|
-
import { any } from "../schemas/primitives/any";
|
|
13
|
-
import { unknown } from "../schemas/primitives/unknown";
|
|
14
|
-
import { literal } from "../schemas/primitives/literal";
|
|
15
|
-
import { enum_, numberEnum, booleanEnum, mixedEnum } from "../schemas/primitives/enum";
|
|
16
|
-
import { nativeEnum } from "../schemas/primitives/nativeEnum";
|
|
17
|
-
import { object, strictObject } from "../schemas/composites/object";
|
|
18
|
-
import { array } from "../schemas/composites/array";
|
|
19
|
-
import { tuple, tupleOf, tupleOf3, tupleOf4, tupleWithRest } from "../schemas/composites/tuple";
|
|
20
|
-
import { record } from "../schemas/composites/record";
|
|
21
|
-
import { map } from "../schemas/composites/map";
|
|
22
|
-
import { set } from "../schemas/composites/set";
|
|
23
|
-
import { unionOf, unionOf3, unionOf4 } from "../schemas/operators/union";
|
|
24
|
-
import { intersection, intersection3 } from "../schemas/operators/intersection";
|
|
25
|
-
import { partial } from "../schemas/transforms/partial";
|
|
26
|
-
import { required } from "../schemas/transforms/required";
|
|
27
|
-
import { pick } from "../schemas/transforms/pick";
|
|
28
|
-
import { omit } from "../schemas/transforms/omit";
|
|
29
|
-
import { keyof } from "../schemas/transforms/keyof";
|
|
30
|
-
import { optional } from "../schemas/wrappers/optional";
|
|
31
|
-
import { nullable } from "../schemas/wrappers/nullable";
|
|
32
|
-
import { default_ } from "../schemas/wrappers/default";
|
|
33
|
-
import { readonly } from "../schemas/wrappers/readonly";
|
|
34
|
-
import { lazy } from "../schemas/wrappers/lazy";
|
|
35
|
-
import { coerceString } from "../schemas/coerce/string";
|
|
36
|
-
import { coerceNumber } from "../schemas/coerce/number";
|
|
37
|
-
import { coerceBoolean } from "../schemas/coerce/boolean";
|
|
38
|
-
import { coerceDate } from "../schemas/coerce/date";
|
|
39
|
-
import { coerceBigInt } from "../schemas/coerce/bigint";
|
|
40
|
-
import { parse, parseBulk } from "../core/parser";
|
|
1
|
+
import { string } from "../schemas/primitives/string.js";
|
|
2
|
+
import { number } from "../schemas/primitives/number.js";
|
|
3
|
+
import { boolean } from "../schemas/primitives/boolean.js";
|
|
4
|
+
import { date } from "../schemas/primitives/date.js";
|
|
5
|
+
import { bigint } from "../schemas/primitives/bigint.js";
|
|
6
|
+
import { symbol } from "../schemas/primitives/symbol.js";
|
|
7
|
+
import { int } from "../schemas/primitives/int.js";
|
|
8
|
+
import { null_ } from "../schemas/primitives/null.js";
|
|
9
|
+
import { undefined_ } from "../schemas/primitives/undefined.js";
|
|
10
|
+
import { void_ } from "../schemas/primitives/void.js";
|
|
11
|
+
import { never } from "../schemas/primitives/never.js";
|
|
12
|
+
import { any } from "../schemas/primitives/any.js";
|
|
13
|
+
import { unknown } from "../schemas/primitives/unknown.js";
|
|
14
|
+
import { literal } from "../schemas/primitives/literal.js";
|
|
15
|
+
import { enum_, numberEnum, booleanEnum, mixedEnum } from "../schemas/primitives/enum.js";
|
|
16
|
+
import { nativeEnum } from "../schemas/primitives/nativeEnum.js";
|
|
17
|
+
import { object, strictObject } from "../schemas/composites/object.js";
|
|
18
|
+
import { array } from "../schemas/composites/array.js";
|
|
19
|
+
import { tuple, tupleOf, tupleOf3, tupleOf4, tupleWithRest } from "../schemas/composites/tuple.js";
|
|
20
|
+
import { record } from "../schemas/composites/record.js";
|
|
21
|
+
import { map } from "../schemas/composites/map.js";
|
|
22
|
+
import { set } from "../schemas/composites/set.js";
|
|
23
|
+
import { unionOf, unionOf3, unionOf4 } from "../schemas/operators/union.js";
|
|
24
|
+
import { intersection, intersection3 } from "../schemas/operators/intersection.js";
|
|
25
|
+
import { partial } from "../schemas/transforms/partial.js";
|
|
26
|
+
import { required } from "../schemas/transforms/required.js";
|
|
27
|
+
import { pick } from "../schemas/transforms/pick.js";
|
|
28
|
+
import { omit } from "../schemas/transforms/omit.js";
|
|
29
|
+
import { keyof } from "../schemas/transforms/keyof.js";
|
|
30
|
+
import { optional } from "../schemas/wrappers/optional.js";
|
|
31
|
+
import { nullable } from "../schemas/wrappers/nullable.js";
|
|
32
|
+
import { default_ } from "../schemas/wrappers/default.js";
|
|
33
|
+
import { readonly } from "../schemas/wrappers/readonly.js";
|
|
34
|
+
import { lazy } from "../schemas/wrappers/lazy.js";
|
|
35
|
+
import { coerceString } from "../schemas/coerce/string.js";
|
|
36
|
+
import { coerceNumber } from "../schemas/coerce/number.js";
|
|
37
|
+
import { coerceBoolean } from "../schemas/coerce/boolean.js";
|
|
38
|
+
import { coerceDate } from "../schemas/coerce/date.js";
|
|
39
|
+
import { coerceBigInt } from "../schemas/coerce/bigint.js";
|
|
40
|
+
import { parse, parseBulk } from "../core/parser.js";
|
|
41
41
|
/**
|
|
42
42
|
* Kanon namespace object providing a single entry point for all schemas.
|
|
43
43
|
*
|
|
@@ -51,7 +51,7 @@ import { parse, parseBulk } from "../core/parser";
|
|
|
51
51
|
*
|
|
52
52
|
* @example
|
|
53
53
|
* ```typescript
|
|
54
|
-
* import { k } from '../helpers/k';
|
|
54
|
+
* import { k } from '../helpers/k.js';
|
|
55
55
|
*
|
|
56
56
|
* const userSchema = k.object({
|
|
57
57
|
* name: k.string().minLength(1),
|
|
@@ -175,5 +175,5 @@ export declare const k: {
|
|
|
175
175
|
/** Validates an array of values against a schema. */
|
|
176
176
|
readonly parseBulk: typeof parseBulk;
|
|
177
177
|
};
|
|
178
|
-
export type { Infer, Schema, GenericSchema } from "../types/base";
|
|
178
|
+
export type { Infer, Schema, GenericSchema } from "../types/base.js";
|
|
179
179
|
//# sourceMappingURL=k.d.ts.map
|
package/dist/kanon/helpers/k.js
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
1
|
// Primitives
|
|
2
|
-
import { string } from "../schemas/primitives/string";
|
|
3
|
-
import { number } from "../schemas/primitives/number";
|
|
4
|
-
import { boolean } from "../schemas/primitives/boolean";
|
|
5
|
-
import { date } from "../schemas/primitives/date";
|
|
6
|
-
import { bigint } from "../schemas/primitives/bigint";
|
|
7
|
-
import { symbol } from "../schemas/primitives/symbol";
|
|
8
|
-
import { int } from "../schemas/primitives/int";
|
|
9
|
-
import { null_ } from "../schemas/primitives/null";
|
|
10
|
-
import { undefined_ } from "../schemas/primitives/undefined";
|
|
11
|
-
import { void_ } from "../schemas/primitives/void";
|
|
12
|
-
import { never } from "../schemas/primitives/never";
|
|
13
|
-
import { any } from "../schemas/primitives/any";
|
|
14
|
-
import { unknown } from "../schemas/primitives/unknown";
|
|
15
|
-
import { literal } from "../schemas/primitives/literal";
|
|
16
|
-
import { enum_, numberEnum, booleanEnum, mixedEnum } from "../schemas/primitives/enum";
|
|
17
|
-
import { nativeEnum } from "../schemas/primitives/nativeEnum";
|
|
2
|
+
import { string } from "../schemas/primitives/string.js";
|
|
3
|
+
import { number } from "../schemas/primitives/number.js";
|
|
4
|
+
import { boolean } from "../schemas/primitives/boolean.js";
|
|
5
|
+
import { date } from "../schemas/primitives/date.js";
|
|
6
|
+
import { bigint } from "../schemas/primitives/bigint.js";
|
|
7
|
+
import { symbol } from "../schemas/primitives/symbol.js";
|
|
8
|
+
import { int } from "../schemas/primitives/int.js";
|
|
9
|
+
import { null_ } from "../schemas/primitives/null.js";
|
|
10
|
+
import { undefined_ } from "../schemas/primitives/undefined.js";
|
|
11
|
+
import { void_ } from "../schemas/primitives/void.js";
|
|
12
|
+
import { never } from "../schemas/primitives/never.js";
|
|
13
|
+
import { any } from "../schemas/primitives/any.js";
|
|
14
|
+
import { unknown } from "../schemas/primitives/unknown.js";
|
|
15
|
+
import { literal } from "../schemas/primitives/literal.js";
|
|
16
|
+
import { enum_, numberEnum, booleanEnum, mixedEnum } from "../schemas/primitives/enum.js";
|
|
17
|
+
import { nativeEnum } from "../schemas/primitives/nativeEnum.js";
|
|
18
18
|
// Composites
|
|
19
|
-
import { object, strictObject, looseObject } from "../schemas/composites/object";
|
|
20
|
-
import { array } from "../schemas/composites/array";
|
|
21
|
-
import { tuple, tupleOf, tupleOf3, tupleOf4, tupleWithRest } from "../schemas/composites/tuple";
|
|
22
|
-
import { record } from "../schemas/composites/record";
|
|
23
|
-
import { map } from "../schemas/composites/map";
|
|
24
|
-
import { set } from "../schemas/composites/set";
|
|
19
|
+
import { object, strictObject, looseObject } from "../schemas/composites/object.js";
|
|
20
|
+
import { array } from "../schemas/composites/array.js";
|
|
21
|
+
import { tuple, tupleOf, tupleOf3, tupleOf4, tupleWithRest } from "../schemas/composites/tuple.js";
|
|
22
|
+
import { record } from "../schemas/composites/record.js";
|
|
23
|
+
import { map } from "../schemas/composites/map.js";
|
|
24
|
+
import { set } from "../schemas/composites/set.js";
|
|
25
25
|
// Operators
|
|
26
|
-
import { unionOf, unionOf3, unionOf4 } from "../schemas/operators/union";
|
|
27
|
-
import { intersection, intersection3 } from "../schemas/operators/intersection";
|
|
26
|
+
import { unionOf, unionOf3, unionOf4 } from "../schemas/operators/union.js";
|
|
27
|
+
import { intersection, intersection3 } from "../schemas/operators/intersection.js";
|
|
28
28
|
// Transforms
|
|
29
|
-
import { partial } from "../schemas/transforms/partial";
|
|
30
|
-
import { required } from "../schemas/transforms/required";
|
|
31
|
-
import { pick } from "../schemas/transforms/pick";
|
|
32
|
-
import { omit } from "../schemas/transforms/omit";
|
|
33
|
-
import { keyof } from "../schemas/transforms/keyof";
|
|
29
|
+
import { partial } from "../schemas/transforms/partial.js";
|
|
30
|
+
import { required } from "../schemas/transforms/required.js";
|
|
31
|
+
import { pick } from "../schemas/transforms/pick.js";
|
|
32
|
+
import { omit } from "../schemas/transforms/omit.js";
|
|
33
|
+
import { keyof } from "../schemas/transforms/keyof.js";
|
|
34
34
|
// Wrappers
|
|
35
|
-
import { optional } from "../schemas/wrappers/optional";
|
|
36
|
-
import { nullable } from "../schemas/wrappers/nullable";
|
|
37
|
-
import { default_ } from "../schemas/wrappers/default";
|
|
38
|
-
import { readonly } from "../schemas/wrappers/readonly";
|
|
39
|
-
import { lazy } from "../schemas/wrappers/lazy";
|
|
35
|
+
import { optional } from "../schemas/wrappers/optional.js";
|
|
36
|
+
import { nullable } from "../schemas/wrappers/nullable.js";
|
|
37
|
+
import { default_ } from "../schemas/wrappers/default.js";
|
|
38
|
+
import { readonly } from "../schemas/wrappers/readonly.js";
|
|
39
|
+
import { lazy } from "../schemas/wrappers/lazy.js";
|
|
40
40
|
// Coerce
|
|
41
|
-
import { coerceString } from "../schemas/coerce/string";
|
|
42
|
-
import { coerceNumber } from "../schemas/coerce/number";
|
|
43
|
-
import { coerceBoolean } from "../schemas/coerce/boolean";
|
|
44
|
-
import { coerceDate } from "../schemas/coerce/date";
|
|
45
|
-
import { coerceBigInt } from "../schemas/coerce/bigint";
|
|
41
|
+
import { coerceString } from "../schemas/coerce/string.js";
|
|
42
|
+
import { coerceNumber } from "../schemas/coerce/number.js";
|
|
43
|
+
import { coerceBoolean } from "../schemas/coerce/boolean.js";
|
|
44
|
+
import { coerceDate } from "../schemas/coerce/date.js";
|
|
45
|
+
import { coerceBigInt } from "../schemas/coerce/bigint.js";
|
|
46
46
|
// Core
|
|
47
|
-
import { parse, parseBulk } from "../core/parser";
|
|
47
|
+
import { parse, parseBulk } from "../core/parser.js";
|
|
48
48
|
/**
|
|
49
49
|
* Kanon namespace object providing a single entry point for all schemas.
|
|
50
50
|
*
|
|
@@ -58,7 +58,7 @@ import { parse, parseBulk } from "../core/parser";
|
|
|
58
58
|
*
|
|
59
59
|
* @example
|
|
60
60
|
* ```typescript
|
|
61
|
-
* import { k } from '../helpers/k';
|
|
61
|
+
* import { k } from '../helpers/k.js';
|
|
62
62
|
*
|
|
63
63
|
* const userSchema = k.object({
|
|
64
64
|
* name: k.string().minLength(1),
|
package/dist/kanon/index.d.ts
CHANGED
|
@@ -3,60 +3,60 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @since 2.0.0
|
|
5
5
|
*/
|
|
6
|
-
export { parse, parseBulk, type ParseBulkOptions } from "./core/parser";
|
|
7
|
-
export { any } from "./schemas/primitives/any";
|
|
8
|
-
export { bigint } from "./schemas/primitives/bigint";
|
|
9
|
-
export { boolean } from "./schemas/primitives/boolean";
|
|
10
|
-
export { date } from "./schemas/primitives/date";
|
|
11
|
-
export { int } from "./schemas/primitives/int";
|
|
12
|
-
export { never } from "./schemas/primitives/never";
|
|
13
|
-
export { null_ } from "./schemas/primitives/null";
|
|
14
|
-
export { number } from "./schemas/primitives/number";
|
|
15
|
-
export { string } from "./schemas/primitives/string";
|
|
16
|
-
export { symbol } from "./schemas/primitives/symbol";
|
|
17
|
-
export { undefined_ } from "./schemas/primitives/undefined";
|
|
18
|
-
export { unknown } from "./schemas/primitives/unknown";
|
|
19
|
-
export { void_ } from "./schemas/primitives/void";
|
|
20
|
-
export { literal } from "./schemas/primitives/literal";
|
|
21
|
-
export { enum_, numberEnum, booleanEnum, mixedEnum, } from "./schemas/primitives/enum";
|
|
22
|
-
export { nativeEnum } from "./schemas/primitives/nativeEnum";
|
|
23
|
-
export { object, strictObject, looseObject } from "./schemas/composites/object";
|
|
24
|
-
export { array } from "./schemas/composites/array";
|
|
25
|
-
export { record } from "./schemas/composites/record";
|
|
26
|
-
export { tuple, tupleOf, tupleOf3, tupleOf4, tupleWithRest, } from "./schemas/composites/tuple";
|
|
27
|
-
export { map } from "./schemas/composites/map";
|
|
28
|
-
export { set } from "./schemas/composites/set";
|
|
29
|
-
export { unionOf, unionOf3, unionOf4, discriminatedUnion, } from "./schemas/operators/union";
|
|
30
|
-
export { intersection, intersection3 } from "./schemas/operators/intersection";
|
|
31
|
-
export { optional } from "./schemas/wrappers/optional";
|
|
32
|
-
export { nullable } from "./schemas/wrappers/nullable";
|
|
33
|
-
export { nullish } from "./schemas/wrappers/nullish";
|
|
34
|
-
export { default_, DefaultValues } from "./schemas/wrappers/default";
|
|
35
|
-
export { readonly } from "./schemas/wrappers/readonly";
|
|
36
|
-
export { lazy } from "./schemas/wrappers/lazy";
|
|
37
|
-
export { partial } from "./schemas/transforms/partial";
|
|
38
|
-
export { required } from "./schemas/transforms/required";
|
|
39
|
-
export { pick } from "./schemas/transforms/pick";
|
|
40
|
-
export { omit } from "./schemas/transforms/omit";
|
|
41
|
-
export { keyof } from "./schemas/transforms/keyof";
|
|
42
|
-
export { coerceString } from "./schemas/coerce/string";
|
|
43
|
-
export { coerceNumber } from "./schemas/coerce/number";
|
|
44
|
-
export { coerceBoolean } from "./schemas/coerce/boolean";
|
|
45
|
-
export { coerceBigInt } from "./schemas/coerce/bigint";
|
|
46
|
-
export { coerceDate } from "./schemas/coerce/date";
|
|
47
|
-
export type { Schema, GenericSchema, Infer, ValidatorResult, CoercedResult } from "./types/base";
|
|
48
|
-
export type { StringConstraint, NumberConstraint, ArrayConstraint, ObjectConstraint, DateConstraint, BigIntConstraint, } from "./types/constraints";
|
|
49
|
-
export type { StringSchema, NumberSchema, IntSchema, BooleanSchema, DateSchema, BigIntSchema, EnumSchema, NativeEnumSchema, LiteralSchema, AnySchema, UnknownSchema, NeverSchema, NullSchema, UndefinedSchema, SymbolSchema, VoidSchema, } from "./types/primitives";
|
|
50
|
-
export type { IntersectionSchema, UnionSchema, DiscriminatedUnionSchema, DiscriminableSchema, DiscriminableObjectBase, } from "./types/operators";
|
|
51
|
-
export type { ObjectSchema, ArraySchema, RecordSchema, MapSchema, SetSchema, TupleSchema, TupleWithRestSchema, } from "./types/composites";
|
|
52
|
-
export { hasTupleRest } from "./types/composites";
|
|
53
|
-
export type { SetConstraint, MapConstraint, } from "./types/constraints";
|
|
54
|
-
export type { DefaultSchema, NullishSchema, ReadonlySchema, LazySchema, UnwrapSchema, IsWrapper, } from "./types/wrappers";
|
|
55
|
-
export type { KeyofSchema, PartialSchema, RequiredSchema, PickSchema, OmitSchema, } from "./types/transforms";
|
|
56
|
-
export { isSchemaType, schemaGuards, isStringConstraint, isNumberConstraint, isArrayConstraint, isObjectConstraint, isDateConstraint, isBigIntConstraint, isSetConstraint, isMapConstraint } from "./types/guards";
|
|
57
|
-
export type { SchemaOfType } from "./types/guards";
|
|
58
|
-
export { k } from "./helpers/k";
|
|
59
|
-
export { validation } from "./validation";
|
|
60
|
-
export { compile, isJITAvailable, clearCache } from "./jit/compiler";
|
|
61
|
-
export type { CompileOptions, CompiledValidator } from "./jit/compiler";
|
|
6
|
+
export { parse, parseBulk, type ParseBulkOptions } from "./core/parser.js";
|
|
7
|
+
export { any } from "./schemas/primitives/any.js";
|
|
8
|
+
export { bigint } from "./schemas/primitives/bigint.js";
|
|
9
|
+
export { boolean } from "./schemas/primitives/boolean.js";
|
|
10
|
+
export { date } from "./schemas/primitives/date.js";
|
|
11
|
+
export { int } from "./schemas/primitives/int.js";
|
|
12
|
+
export { never } from "./schemas/primitives/never.js";
|
|
13
|
+
export { null_ } from "./schemas/primitives/null.js";
|
|
14
|
+
export { number } from "./schemas/primitives/number.js";
|
|
15
|
+
export { string } from "./schemas/primitives/string.js";
|
|
16
|
+
export { symbol } from "./schemas/primitives/symbol.js";
|
|
17
|
+
export { undefined_ } from "./schemas/primitives/undefined.js";
|
|
18
|
+
export { unknown } from "./schemas/primitives/unknown.js";
|
|
19
|
+
export { void_ } from "./schemas/primitives/void.js";
|
|
20
|
+
export { literal } from "./schemas/primitives/literal.js";
|
|
21
|
+
export { enum_, numberEnum, booleanEnum, mixedEnum, } from "./schemas/primitives/enum.js";
|
|
22
|
+
export { nativeEnum } from "./schemas/primitives/nativeEnum.js";
|
|
23
|
+
export { object, strictObject, looseObject } from "./schemas/composites/object.js";
|
|
24
|
+
export { array } from "./schemas/composites/array.js";
|
|
25
|
+
export { record } from "./schemas/composites/record.js";
|
|
26
|
+
export { tuple, tupleOf, tupleOf3, tupleOf4, tupleWithRest, } from "./schemas/composites/tuple.js";
|
|
27
|
+
export { map } from "./schemas/composites/map.js";
|
|
28
|
+
export { set } from "./schemas/composites/set.js";
|
|
29
|
+
export { unionOf, unionOf3, unionOf4, discriminatedUnion, } from "./schemas/operators/union.js";
|
|
30
|
+
export { intersection, intersection3 } from "./schemas/operators/intersection.js";
|
|
31
|
+
export { optional } from "./schemas/wrappers/optional.js";
|
|
32
|
+
export { nullable } from "./schemas/wrappers/nullable.js";
|
|
33
|
+
export { nullish } from "./schemas/wrappers/nullish.js";
|
|
34
|
+
export { default_, DefaultValues } from "./schemas/wrappers/default.js";
|
|
35
|
+
export { readonly } from "./schemas/wrappers/readonly.js";
|
|
36
|
+
export { lazy } from "./schemas/wrappers/lazy.js";
|
|
37
|
+
export { partial } from "./schemas/transforms/partial.js";
|
|
38
|
+
export { required } from "./schemas/transforms/required.js";
|
|
39
|
+
export { pick } from "./schemas/transforms/pick.js";
|
|
40
|
+
export { omit } from "./schemas/transforms/omit.js";
|
|
41
|
+
export { keyof } from "./schemas/transforms/keyof.js";
|
|
42
|
+
export { coerceString } from "./schemas/coerce/string.js";
|
|
43
|
+
export { coerceNumber } from "./schemas/coerce/number.js";
|
|
44
|
+
export { coerceBoolean } from "./schemas/coerce/boolean.js";
|
|
45
|
+
export { coerceBigInt } from "./schemas/coerce/bigint.js";
|
|
46
|
+
export { coerceDate } from "./schemas/coerce/date.js";
|
|
47
|
+
export type { Schema, GenericSchema, Infer, ValidatorResult, CoercedResult } from "./types/base.js";
|
|
48
|
+
export type { StringConstraint, NumberConstraint, ArrayConstraint, ObjectConstraint, DateConstraint, BigIntConstraint, } from "./types/constraints.js";
|
|
49
|
+
export type { StringSchema, NumberSchema, IntSchema, BooleanSchema, DateSchema, BigIntSchema, EnumSchema, NativeEnumSchema, LiteralSchema, AnySchema, UnknownSchema, NeverSchema, NullSchema, UndefinedSchema, SymbolSchema, VoidSchema, } from "./types/primitives.js";
|
|
50
|
+
export type { IntersectionSchema, UnionSchema, DiscriminatedUnionSchema, DiscriminableSchema, DiscriminableObjectBase, } from "./types/operators.js";
|
|
51
|
+
export type { ObjectSchema, ArraySchema, RecordSchema, MapSchema, SetSchema, TupleSchema, TupleWithRestSchema, } from "./types/composites.js";
|
|
52
|
+
export { hasTupleRest } from "./types/composites.js";
|
|
53
|
+
export type { SetConstraint, MapConstraint, } from "./types/constraints.js";
|
|
54
|
+
export type { DefaultSchema, NullishSchema, ReadonlySchema, LazySchema, UnwrapSchema, IsWrapper, } from "./types/wrappers.js";
|
|
55
|
+
export type { KeyofSchema, PartialSchema, RequiredSchema, PickSchema, OmitSchema, } from "./types/transforms.js";
|
|
56
|
+
export { isSchemaType, schemaGuards, isStringConstraint, isNumberConstraint, isArrayConstraint, isObjectConstraint, isDateConstraint, isBigIntConstraint, isSetConstraint, isMapConstraint } from "./types/guards.js";
|
|
57
|
+
export type { SchemaOfType } from "./types/guards.js";
|
|
58
|
+
export { k } from "./helpers/k.js";
|
|
59
|
+
export { validation } from "./validation.js";
|
|
60
|
+
export { compile, isJITAvailable, clearCache } from "./jit/compiler.js";
|
|
61
|
+
export type { CompileOptions, CompiledValidator } from "./jit/compiler.js";
|
|
62
62
|
//# sourceMappingURL=index.d.ts.map
|