typedriver 0.8.9 → 0.8.10
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/build/compile.d.mts +3 -9
- package/build/compile.mjs +14 -16
- package/build/static.d.mts +4 -4
- package/package.json +1 -1
package/build/compile.d.mts
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { type StandardSchemaV1, type StandardJSONSchemaV1 } from '@standard-schema/spec';
|
|
1
|
+
import { type Static } from './static.mjs';
|
|
3
2
|
import { Validator } from './validator.mjs';
|
|
4
|
-
type TFromStandardSchema<Input extends StandardSchemaV1, Output extends unknown = StandardSchemaV1.InferInput<Input>, Result extends Validator = Validator<Input, Output>> = Result;
|
|
5
|
-
type TFromStandardJsonSchema<Input extends StandardSchemaV1 & StandardJSONSchemaV1, Output extends unknown = StandardSchemaV1.InferInput<Input>, Result extends Validator = Validator<Input, Output>> = Result;
|
|
6
|
-
type TFromJsonSchema<Input extends Type.TSchema, Output extends unknown = Type.Static<Input>, Result extends Validator = Validator<Input, Output>> = Result;
|
|
7
|
-
type TFromTypeScript<Input extends string, Schema extends Type.TSchema = Type.TScript<{}, Input>, Output extends unknown = Type.Static<Schema>, Result extends Validator = Validator<Input, Output>> = Result;
|
|
8
3
|
/** Compiles a schema into a typed Validator */
|
|
9
|
-
export type TCompile<
|
|
4
|
+
export type TCompile<Input, Output extends unknown = Static<Input>, Result extends Validator<Input, Output> = Validator<Input, Output>> = Result;
|
|
10
5
|
/** Compiles a schema into a typed Validator */
|
|
11
|
-
export declare function compile<const
|
|
12
|
-
export {};
|
|
6
|
+
export declare function compile<const Input, Output extends Validator = TCompile<Input>>(input: Input): Output;
|
package/build/compile.mjs
CHANGED
|
@@ -4,24 +4,22 @@ import { JsonSchemaValidator } from './validators/json-schema/validator.mjs';
|
|
|
4
4
|
import { StandardJsonSchemaValidator } from './validators/standard-json-schema/validator.mjs';
|
|
5
5
|
import { StandardSchemaValidator } from './validators/standard-schema/validator.mjs';
|
|
6
6
|
import { TypeScriptValidator } from './validators/typescript/validator.mjs';
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
// ------------------------------------------------------------------
|
|
8
|
+
// Validators
|
|
9
|
+
// ------------------------------------------------------------------
|
|
10
|
+
function CreateStandardSchemaV1Validator(input) {
|
|
11
|
+
return IsStandardJsonSchemaV1(input) ? new StandardJsonSchemaValidator(input) : new StandardSchemaValidator(input);
|
|
9
12
|
}
|
|
10
|
-
function
|
|
11
|
-
return new
|
|
13
|
+
function CreateJsonSchemaValidator(input) {
|
|
14
|
+
return new JsonSchemaValidator(input);
|
|
12
15
|
}
|
|
13
|
-
function
|
|
14
|
-
return new
|
|
15
|
-
}
|
|
16
|
-
function FromTypeScript(script) {
|
|
17
|
-
return new TypeScriptValidator(script);
|
|
16
|
+
function CreateTypeScriptValidator(input) {
|
|
17
|
+
return new TypeScriptValidator(input);
|
|
18
18
|
}
|
|
19
19
|
/** Compiles a schema into a typed Validator */
|
|
20
|
-
export function compile(
|
|
21
|
-
return (IsTypeScript(
|
|
22
|
-
IsStandardSchemaV1(
|
|
23
|
-
?
|
|
24
|
-
|
|
25
|
-
IsJsonSchema(schema) ? FromJsonSchema(schema) :
|
|
26
|
-
FromJsonSchema({}));
|
|
20
|
+
export function compile(input) {
|
|
21
|
+
return (IsTypeScript(input) ? CreateTypeScriptValidator(input) :
|
|
22
|
+
IsStandardSchemaV1(input) ? CreateStandardSchemaV1Validator(input) :
|
|
23
|
+
IsJsonSchema(input) ? CreateJsonSchemaValidator(input) :
|
|
24
|
+
CreateJsonSchemaValidator({}));
|
|
27
25
|
}
|
package/build/static.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { type TSchema, type TScript, type Static as TStatic } from 'typebox';
|
|
1
2
|
import { type StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
3
|
import { type Validator } from './validator.mjs';
|
|
3
|
-
import Type from 'typebox';
|
|
4
4
|
type StaticValidator<_Input extends unknown, Output extends unknown> = (Output);
|
|
5
|
-
type StaticTypeScript<Input extends string, Schema extends
|
|
5
|
+
type StaticTypeScript<Input extends string, Schema extends TSchema = TScript<{}, Input>, Output extends unknown = TStatic<Schema>> = Output;
|
|
6
6
|
type StaticStandardSchema<Input extends StandardSchemaV1, Output extends unknown = StandardSchemaV1.InferOutput<Input>> = Output;
|
|
7
|
-
type StaticJsonSchema<Input extends
|
|
8
|
-
type StaticInput<Input extends unknown> = (Input extends Validator<infer Input extends unknown, infer Output extends unknown> ? StaticValidator<Input, Output> : Input extends string ? StaticTypeScript<Input> : Input extends StandardSchemaV1 ? StaticStandardSchema<Input> : Input extends
|
|
7
|
+
type StaticJsonSchema<Input extends TSchema, Output extends unknown = TStatic<Input>> = Output;
|
|
8
|
+
type StaticInput<Input extends unknown> = (Input extends Validator<infer Input extends unknown, infer Output extends unknown> ? StaticValidator<Input, Output> : Input extends string ? StaticTypeScript<Input> : Input extends StandardSchemaV1 ? StaticStandardSchema<Input> : Input extends TSchema ? StaticJsonSchema<Input> : unknown);
|
|
9
9
|
export type Static<Input, Output = StaticInput<Input>> = Output;
|
|
10
10
|
export {};
|