@forklaunch/validator 0.7.7 → 0.8.0
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/lib/__test__/utils/mockSchemaValidator.d.mts +3 -2
- package/lib/__test__/utils/mockSchemaValidator.d.ts +3 -2
- package/lib/__test__/utils/mockSchemaValidator.js +3 -0
- package/lib/__test__/utils/mockSchemaValidator.mjs +3 -0
- package/lib/index.d.mts +2 -2
- package/lib/index.d.ts +2 -2
- package/lib/{schema.types-C3S1yoja.d.mts → schema.types-BmSJeE9l.d.mts} +11 -7
- package/lib/{schema.types-C3S1yoja.d.ts → schema.types-BmSJeE9l.d.ts} +11 -7
- package/lib/src/typebox/index.d.mts +2 -2
- package/lib/src/typebox/index.d.ts +2 -2
- package/lib/src/typebox/index.js +3 -3
- package/lib/src/typebox/index.mjs +3 -3
- package/lib/src/zod/index.d.mts +2 -2
- package/lib/src/zod/index.d.ts +2 -2
- package/package.json +12 -12
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SchemaObject } from 'openapi3-ts/oas31';
|
|
2
|
-
import { S as SchemaValidator, L as LiteralSchema, a as ParseResult } from '../../schema.types-
|
|
2
|
+
import { S as SchemaValidator, L as LiteralSchema, a as ParseResult } from '../../schema.types-BmSJeE9l.mjs';
|
|
3
3
|
import '@forklaunch/common';
|
|
4
4
|
import '@sinclair/typebox';
|
|
5
5
|
import '@sinclair/typebox/compiler';
|
|
@@ -24,7 +24,7 @@ type SerializeStringArray<T extends string[]> = T extends [
|
|
|
24
24
|
* A mock implementation of SchemaValidator for testing purposes.
|
|
25
25
|
* This validator represents schemas as strings and provides simple string-based operations.
|
|
26
26
|
*/
|
|
27
|
-
declare class MockSchemaValidator implements SchemaValidator<(<T extends string>(schema: T) => T
|
|
27
|
+
declare class MockSchemaValidator implements SchemaValidator<(<T>() => T), <T extends string>(schema: T) => T, <T extends string>(schema: T) => T, <T extends string>(schema: T) => `optional ${T}`, <T extends string>(schema: T) => `array ${T}`, <T extends readonly string[]>(schemas: T) => RecursiveUnion<T>, <T extends LiteralSchema>(schema: T) => `literal ${T}`, <T extends LiteralSchema>(schemaEnum: Record<string, T>) => `enum ${T}`, <Args extends string[], ReturnType extends string>(args: Args, returnType: ReturnType) => `function(${SerializeStringArray<Args>}) => ${ReturnType}`, <Key extends string, Value extends string>(key: Key, value: Value) => `{${Key}: ${Value}}`, <T extends string>(schema: T) => `Promise<${T}>`, (value: unknown) => value is string, <T extends string>(value: unknown, type: T) => value is T, <T extends string>(schema: T, value: string) => boolean, <T extends string>(schema: T, value: string) => ParseResult<T>, <T extends string>(schema: T) => SchemaObject> {
|
|
28
28
|
_Type: "Mock";
|
|
29
29
|
_SchemaCatchall: string;
|
|
30
30
|
_ValidSchemaObject: string;
|
|
@@ -43,6 +43,7 @@ declare class MockSchemaValidator implements SchemaValidator<(<T extends string>
|
|
|
43
43
|
never: string;
|
|
44
44
|
binary: string;
|
|
45
45
|
file: string;
|
|
46
|
+
type<T>(): T;
|
|
46
47
|
/**
|
|
47
48
|
* Compiles a schema string.
|
|
48
49
|
*
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { SchemaObject } from 'openapi3-ts/oas31';
|
|
2
|
-
import { S as SchemaValidator, L as LiteralSchema, a as ParseResult } from '../../schema.types-
|
|
2
|
+
import { S as SchemaValidator, L as LiteralSchema, a as ParseResult } from '../../schema.types-BmSJeE9l.js';
|
|
3
3
|
import '@forklaunch/common';
|
|
4
4
|
import '@sinclair/typebox';
|
|
5
5
|
import '@sinclair/typebox/compiler';
|
|
@@ -24,7 +24,7 @@ type SerializeStringArray<T extends string[]> = T extends [
|
|
|
24
24
|
* A mock implementation of SchemaValidator for testing purposes.
|
|
25
25
|
* This validator represents schemas as strings and provides simple string-based operations.
|
|
26
26
|
*/
|
|
27
|
-
declare class MockSchemaValidator implements SchemaValidator<(<T extends string>(schema: T) => T
|
|
27
|
+
declare class MockSchemaValidator implements SchemaValidator<(<T>() => T), <T extends string>(schema: T) => T, <T extends string>(schema: T) => T, <T extends string>(schema: T) => `optional ${T}`, <T extends string>(schema: T) => `array ${T}`, <T extends readonly string[]>(schemas: T) => RecursiveUnion<T>, <T extends LiteralSchema>(schema: T) => `literal ${T}`, <T extends LiteralSchema>(schemaEnum: Record<string, T>) => `enum ${T}`, <Args extends string[], ReturnType extends string>(args: Args, returnType: ReturnType) => `function(${SerializeStringArray<Args>}) => ${ReturnType}`, <Key extends string, Value extends string>(key: Key, value: Value) => `{${Key}: ${Value}}`, <T extends string>(schema: T) => `Promise<${T}>`, (value: unknown) => value is string, <T extends string>(value: unknown, type: T) => value is T, <T extends string>(schema: T, value: string) => boolean, <T extends string>(schema: T, value: string) => ParseResult<T>, <T extends string>(schema: T) => SchemaObject> {
|
|
28
28
|
_Type: "Mock";
|
|
29
29
|
_SchemaCatchall: string;
|
|
30
30
|
_ValidSchemaObject: string;
|
|
@@ -43,6 +43,7 @@ declare class MockSchemaValidator implements SchemaValidator<(<T extends string>
|
|
|
43
43
|
never: string;
|
|
44
44
|
binary: string;
|
|
45
45
|
file: string;
|
|
46
|
+
type<T>(): T;
|
|
46
47
|
/**
|
|
47
48
|
* Compiles a schema string.
|
|
48
49
|
*
|
package/lib/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as ParseError } from './schema.types-
|
|
2
|
-
export { A as AnySchemaValidator, I as IdiomaticSchema, e as Increment, K as KeyTypes, L as LiteralSchema, a as ParseResult, d as Schema, b as SchemaResolve, c as SchemaTranslate, S as SchemaValidator, U as UnboxedObjectSchema } from './schema.types-
|
|
1
|
+
import { P as ParseError } from './schema.types-BmSJeE9l.mjs';
|
|
2
|
+
export { A as AnySchemaValidator, I as IdiomaticSchema, e as Increment, K as KeyTypes, L as LiteralSchema, a as ParseResult, d as Schema, b as SchemaResolve, c as SchemaTranslate, S as SchemaValidator, U as UnboxedObjectSchema } from './schema.types-BmSJeE9l.mjs';
|
|
3
3
|
import '@forklaunch/common';
|
|
4
4
|
import 'openapi3-ts/oas31';
|
|
5
5
|
import '@sinclair/typebox';
|
package/lib/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { P as ParseError } from './schema.types-
|
|
2
|
-
export { A as AnySchemaValidator, I as IdiomaticSchema, e as Increment, K as KeyTypes, L as LiteralSchema, a as ParseResult, d as Schema, b as SchemaResolve, c as SchemaTranslate, S as SchemaValidator, U as UnboxedObjectSchema } from './schema.types-
|
|
1
|
+
import { P as ParseError } from './schema.types-BmSJeE9l.js';
|
|
2
|
+
export { A as AnySchemaValidator, I as IdiomaticSchema, e as Increment, K as KeyTypes, L as LiteralSchema, a as ParseResult, d as Schema, b as SchemaResolve, c as SchemaTranslate, S as SchemaValidator, U as UnboxedObjectSchema } from './schema.types-BmSJeE9l.js';
|
|
3
3
|
import '@forklaunch/common';
|
|
4
4
|
import 'openapi3-ts/oas31';
|
|
5
5
|
import '@sinclair/typebox';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Prettify } from '@forklaunch/common';
|
|
2
2
|
import { SchemaObject } from 'openapi3-ts/oas31';
|
|
3
|
-
import { TProperties, TOptional, TArray, TUnion, TLiteral, TFunction, TRecord, TPromise, TSchema, TString,
|
|
3
|
+
import { TTransform, TAny, TProperties, TOptional, TArray, TUnion, TLiteral, TFunction, TRecord, TPromise, TSchema, TString, TNumber, TBoolean, TNull, TBigInt, TDate, TSymbol, TVoid, TUndefined, TUnknown, TNever, TKind, TObject, StaticDecode } from '@sinclair/typebox';
|
|
4
4
|
import { TypeCheck } from '@sinclair/typebox/compiler';
|
|
5
|
-
import { ZodObject as ZodObject$1, ZodRawShape, ZodOptional, ZodArray, ZodUnion, ZodLiteral, ZodFunction, ZodTuple, ZodRecord, ZodPromise,
|
|
5
|
+
import { ZodType, ZodObject as ZodObject$1, ZodRawShape, ZodOptional, ZodArray, ZodUnion, ZodLiteral, ZodFunction, ZodTuple, ZodRecord, ZodPromise, z, ZodUnknown, ZodPipeline, ZodTypeAny, ZodEffects, ZodNever } from 'zod/v3';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* This module provides a TypeScript-based schema definition using the TypeBox library.
|
|
@@ -15,7 +15,7 @@ import { ZodObject as ZodObject$1, ZodRawShape, ZodOptional, ZodArray, ZodUnion,
|
|
|
15
15
|
* Class representing a TypeBox schema definition.
|
|
16
16
|
* @implements {SchemaValidator}
|
|
17
17
|
*/
|
|
18
|
-
declare class TypeboxSchemaValidator implements SchemaValidator<(<T extends SafeTObject<TProperties>>(schema: T) => TypeCheck<T
|
|
18
|
+
declare class TypeboxSchemaValidator implements SchemaValidator<(<T>() => TTransform<TAny, T>), <T extends SafeTObject<TProperties>>(schema: T) => TypeCheck<T>, <T extends TIdiomaticSchema>(schema: T) => TResolve<T>, <T extends TIdiomaticSchema>(schema: T) => TOptional<TResolve<T>>, <T extends TIdiomaticSchema>(schema: T) => TArray<TResolve<T>>, <T extends TUnionTupleContainer>(schemas: [...T]) => TUnion<UnionTupleTResolve<T>>, <T extends LiteralSchema>(value: T) => TLiteral<T>, <T extends Record<string, LiteralSchema>>(schemaEnum: T) => TUnion<[
|
|
19
19
|
{
|
|
20
20
|
[K in keyof T]: TLiteral<T[K]>;
|
|
21
21
|
}[keyof T]
|
|
@@ -226,7 +226,7 @@ type TResolve<T, Depth extends number = 0> = Depth extends 12 ? TUnknown : T ext
|
|
|
226
226
|
* Class representing a Zod schema definition.
|
|
227
227
|
* @implements {StaticSchemaValidator}
|
|
228
228
|
*/
|
|
229
|
-
declare class ZodSchemaValidator implements SchemaValidator<(<T extends ZodObject$1<ZodRawShape>>(schema: T) => ZodResolve<T
|
|
229
|
+
declare class ZodSchemaValidator implements SchemaValidator<(<T>() => ZodType<T>), <T extends ZodObject$1<ZodRawShape>>(schema: T) => ZodResolve<T>, <T extends ZodIdiomaticSchema>(schema: T) => ZodResolve<T>, <T extends ZodIdiomaticSchema>(schema: T) => ZodOptional<ZodResolve<T>>, <T extends ZodIdiomaticSchema>(schema: T) => ZodArray<ZodResolve<T>>, <T extends ZodUnionContainer>(schemas: T) => ZodUnion<UnionZodResolve<T>>, <T extends LiteralSchema>(value: T) => ZodLiteral<T>, <T extends Record<string, LiteralSchema>>(schemaEnum: T) => ZodUnion<[
|
|
230
230
|
{
|
|
231
231
|
[K in keyof T]: ZodLiteral<T[K]>;
|
|
232
232
|
}[keyof T]
|
|
@@ -250,7 +250,7 @@ declare class ZodSchemaValidator implements SchemaValidator<(<T extends ZodObjec
|
|
|
250
250
|
any: z.ZodAny;
|
|
251
251
|
unknown: z.ZodUnknown;
|
|
252
252
|
never: z.ZodNever;
|
|
253
|
-
binary: z.ZodEffects<z.ZodString, Uint8Array<
|
|
253
|
+
binary: z.ZodEffects<z.ZodString, Uint8Array<ArrayBuffer>, string>;
|
|
254
254
|
file: z.ZodEffects<z.ZodString, Blob, string>;
|
|
255
255
|
type: <T>() => ZodType<T>;
|
|
256
256
|
/**
|
|
@@ -478,7 +478,7 @@ type ParseResult<T> = {
|
|
|
478
478
|
* @template ParseFunction - The function type for parsing a value against a schema.
|
|
479
479
|
* @template OpenAPIFunction - The function type for converting a schema into an OpenAPI schema object.
|
|
480
480
|
*/
|
|
481
|
-
interface SchemaValidator<CompilationFunction = <T>(schema: T) => unknown, SchematicFunction = <T>(schema: T) => unknown, OptionalFunction = <T>(schema: T) => unknown, ArrayFunction = <T>(schema: T) => unknown, UnionFunction = <T>(schemas: T[]) => unknown, LiteralFunction = <T extends LiteralSchema>(schema: T) => unknown, EnumFunction = <T extends LiteralSchema>(schemaEnum: Record<string, T>) => unknown, FunctionFunction = <Args, ReturnType>(args: Args, returnType: ReturnType) => unknown, RecordFunction = <Key, Value>(key: Key, value: Value) => unknown, PromiseFunction = <T>(schema: T) => unknown, SchemaGuardFunction = <T>(value: unknown) => value is T, InstanceOfFunction = <T>(value: unknown, type: T) => value is T, ValidationFunction = <T>(schema: T, value: unknown) => boolean, ParseFunction = <T>(schema: T, value: unknown) => ParseResult<SchemaResolve<T>>, OpenAPIFunction = <T>(schema: T) => SchemaObject> {
|
|
481
|
+
interface SchemaValidator<TypeFunction = <T>() => T, CompilationFunction = <T>(schema: T) => unknown, SchematicFunction = <T>(schema: T) => unknown, OptionalFunction = <T>(schema: T) => unknown, ArrayFunction = <T>(schema: T) => unknown, UnionFunction = <T>(schemas: T[]) => unknown, LiteralFunction = <T extends LiteralSchema>(schema: T) => unknown, EnumFunction = <T extends LiteralSchema>(schemaEnum: Record<string, T>) => unknown, FunctionFunction = <Args, ReturnType>(args: Args, returnType: ReturnType) => unknown, RecordFunction = <Key, Value>(key: Key, value: Value) => unknown, PromiseFunction = <T>(schema: T) => unknown, SchemaGuardFunction = <T>(value: unknown) => value is T, InstanceOfFunction = <T>(value: unknown, type: T) => value is T, ValidationFunction = <T>(schema: T, value: unknown) => boolean, ParseFunction = <T>(schema: T, value: unknown) => ParseResult<SchemaResolve<T>>, OpenAPIFunction = <T>(schema: T) => SchemaObject> {
|
|
482
482
|
/**
|
|
483
483
|
* The type of the schema validator.
|
|
484
484
|
*/
|
|
@@ -551,6 +551,10 @@ interface SchemaValidator<CompilationFunction = <T>(schema: T) => unknown, Schem
|
|
|
551
551
|
* Validator for file type
|
|
552
552
|
*/
|
|
553
553
|
file: unknown;
|
|
554
|
+
/**
|
|
555
|
+
* Validator for type type
|
|
556
|
+
*/
|
|
557
|
+
type: TypeFunction;
|
|
554
558
|
/**
|
|
555
559
|
* Compiles schema if this exists, for optimal performance.
|
|
556
560
|
*
|
|
@@ -665,7 +669,7 @@ interface SchemaValidator<CompilationFunction = <T>(schema: T) => unknown, Schem
|
|
|
665
669
|
/**
|
|
666
670
|
* Type representing any schema validator.
|
|
667
671
|
*/
|
|
668
|
-
type AnySchemaValidator = SchemaValidator<unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown> & {
|
|
672
|
+
type AnySchemaValidator = SchemaValidator<unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown> & {
|
|
669
673
|
/**
|
|
670
674
|
* The type of the schema resolver.
|
|
671
675
|
*/
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Prettify } from '@forklaunch/common';
|
|
2
2
|
import { SchemaObject } from 'openapi3-ts/oas31';
|
|
3
|
-
import { TProperties, TOptional, TArray, TUnion, TLiteral, TFunction, TRecord, TPromise, TSchema, TString,
|
|
3
|
+
import { TTransform, TAny, TProperties, TOptional, TArray, TUnion, TLiteral, TFunction, TRecord, TPromise, TSchema, TString, TNumber, TBoolean, TNull, TBigInt, TDate, TSymbol, TVoid, TUndefined, TUnknown, TNever, TKind, TObject, StaticDecode } from '@sinclair/typebox';
|
|
4
4
|
import { TypeCheck } from '@sinclair/typebox/compiler';
|
|
5
|
-
import { ZodObject as ZodObject$1, ZodRawShape, ZodOptional, ZodArray, ZodUnion, ZodLiteral, ZodFunction, ZodTuple, ZodRecord, ZodPromise,
|
|
5
|
+
import { ZodType, ZodObject as ZodObject$1, ZodRawShape, ZodOptional, ZodArray, ZodUnion, ZodLiteral, ZodFunction, ZodTuple, ZodRecord, ZodPromise, z, ZodUnknown, ZodPipeline, ZodTypeAny, ZodEffects, ZodNever } from 'zod/v3';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* This module provides a TypeScript-based schema definition using the TypeBox library.
|
|
@@ -15,7 +15,7 @@ import { ZodObject as ZodObject$1, ZodRawShape, ZodOptional, ZodArray, ZodUnion,
|
|
|
15
15
|
* Class representing a TypeBox schema definition.
|
|
16
16
|
* @implements {SchemaValidator}
|
|
17
17
|
*/
|
|
18
|
-
declare class TypeboxSchemaValidator implements SchemaValidator<(<T extends SafeTObject<TProperties>>(schema: T) => TypeCheck<T
|
|
18
|
+
declare class TypeboxSchemaValidator implements SchemaValidator<(<T>() => TTransform<TAny, T>), <T extends SafeTObject<TProperties>>(schema: T) => TypeCheck<T>, <T extends TIdiomaticSchema>(schema: T) => TResolve<T>, <T extends TIdiomaticSchema>(schema: T) => TOptional<TResolve<T>>, <T extends TIdiomaticSchema>(schema: T) => TArray<TResolve<T>>, <T extends TUnionTupleContainer>(schemas: [...T]) => TUnion<UnionTupleTResolve<T>>, <T extends LiteralSchema>(value: T) => TLiteral<T>, <T extends Record<string, LiteralSchema>>(schemaEnum: T) => TUnion<[
|
|
19
19
|
{
|
|
20
20
|
[K in keyof T]: TLiteral<T[K]>;
|
|
21
21
|
}[keyof T]
|
|
@@ -226,7 +226,7 @@ type TResolve<T, Depth extends number = 0> = Depth extends 12 ? TUnknown : T ext
|
|
|
226
226
|
* Class representing a Zod schema definition.
|
|
227
227
|
* @implements {StaticSchemaValidator}
|
|
228
228
|
*/
|
|
229
|
-
declare class ZodSchemaValidator implements SchemaValidator<(<T extends ZodObject$1<ZodRawShape>>(schema: T) => ZodResolve<T
|
|
229
|
+
declare class ZodSchemaValidator implements SchemaValidator<(<T>() => ZodType<T>), <T extends ZodObject$1<ZodRawShape>>(schema: T) => ZodResolve<T>, <T extends ZodIdiomaticSchema>(schema: T) => ZodResolve<T>, <T extends ZodIdiomaticSchema>(schema: T) => ZodOptional<ZodResolve<T>>, <T extends ZodIdiomaticSchema>(schema: T) => ZodArray<ZodResolve<T>>, <T extends ZodUnionContainer>(schemas: T) => ZodUnion<UnionZodResolve<T>>, <T extends LiteralSchema>(value: T) => ZodLiteral<T>, <T extends Record<string, LiteralSchema>>(schemaEnum: T) => ZodUnion<[
|
|
230
230
|
{
|
|
231
231
|
[K in keyof T]: ZodLiteral<T[K]>;
|
|
232
232
|
}[keyof T]
|
|
@@ -250,7 +250,7 @@ declare class ZodSchemaValidator implements SchemaValidator<(<T extends ZodObjec
|
|
|
250
250
|
any: z.ZodAny;
|
|
251
251
|
unknown: z.ZodUnknown;
|
|
252
252
|
never: z.ZodNever;
|
|
253
|
-
binary: z.ZodEffects<z.ZodString, Uint8Array<
|
|
253
|
+
binary: z.ZodEffects<z.ZodString, Uint8Array<ArrayBuffer>, string>;
|
|
254
254
|
file: z.ZodEffects<z.ZodString, Blob, string>;
|
|
255
255
|
type: <T>() => ZodType<T>;
|
|
256
256
|
/**
|
|
@@ -478,7 +478,7 @@ type ParseResult<T> = {
|
|
|
478
478
|
* @template ParseFunction - The function type for parsing a value against a schema.
|
|
479
479
|
* @template OpenAPIFunction - The function type for converting a schema into an OpenAPI schema object.
|
|
480
480
|
*/
|
|
481
|
-
interface SchemaValidator<CompilationFunction = <T>(schema: T) => unknown, SchematicFunction = <T>(schema: T) => unknown, OptionalFunction = <T>(schema: T) => unknown, ArrayFunction = <T>(schema: T) => unknown, UnionFunction = <T>(schemas: T[]) => unknown, LiteralFunction = <T extends LiteralSchema>(schema: T) => unknown, EnumFunction = <T extends LiteralSchema>(schemaEnum: Record<string, T>) => unknown, FunctionFunction = <Args, ReturnType>(args: Args, returnType: ReturnType) => unknown, RecordFunction = <Key, Value>(key: Key, value: Value) => unknown, PromiseFunction = <T>(schema: T) => unknown, SchemaGuardFunction = <T>(value: unknown) => value is T, InstanceOfFunction = <T>(value: unknown, type: T) => value is T, ValidationFunction = <T>(schema: T, value: unknown) => boolean, ParseFunction = <T>(schema: T, value: unknown) => ParseResult<SchemaResolve<T>>, OpenAPIFunction = <T>(schema: T) => SchemaObject> {
|
|
481
|
+
interface SchemaValidator<TypeFunction = <T>() => T, CompilationFunction = <T>(schema: T) => unknown, SchematicFunction = <T>(schema: T) => unknown, OptionalFunction = <T>(schema: T) => unknown, ArrayFunction = <T>(schema: T) => unknown, UnionFunction = <T>(schemas: T[]) => unknown, LiteralFunction = <T extends LiteralSchema>(schema: T) => unknown, EnumFunction = <T extends LiteralSchema>(schemaEnum: Record<string, T>) => unknown, FunctionFunction = <Args, ReturnType>(args: Args, returnType: ReturnType) => unknown, RecordFunction = <Key, Value>(key: Key, value: Value) => unknown, PromiseFunction = <T>(schema: T) => unknown, SchemaGuardFunction = <T>(value: unknown) => value is T, InstanceOfFunction = <T>(value: unknown, type: T) => value is T, ValidationFunction = <T>(schema: T, value: unknown) => boolean, ParseFunction = <T>(schema: T, value: unknown) => ParseResult<SchemaResolve<T>>, OpenAPIFunction = <T>(schema: T) => SchemaObject> {
|
|
482
482
|
/**
|
|
483
483
|
* The type of the schema validator.
|
|
484
484
|
*/
|
|
@@ -551,6 +551,10 @@ interface SchemaValidator<CompilationFunction = <T>(schema: T) => unknown, Schem
|
|
|
551
551
|
* Validator for file type
|
|
552
552
|
*/
|
|
553
553
|
file: unknown;
|
|
554
|
+
/**
|
|
555
|
+
* Validator for type type
|
|
556
|
+
*/
|
|
557
|
+
type: TypeFunction;
|
|
554
558
|
/**
|
|
555
559
|
* Compiles schema if this exists, for optimal performance.
|
|
556
560
|
*
|
|
@@ -665,7 +669,7 @@ interface SchemaValidator<CompilationFunction = <T>(schema: T) => unknown, Schem
|
|
|
665
669
|
/**
|
|
666
670
|
* Type representing any schema validator.
|
|
667
671
|
*/
|
|
668
|
-
type AnySchemaValidator = SchemaValidator<unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown> & {
|
|
672
|
+
type AnySchemaValidator = SchemaValidator<unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown> & {
|
|
669
673
|
/**
|
|
670
674
|
* The type of the schema resolver.
|
|
671
675
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from '@sinclair/typebox';
|
|
2
|
-
import { T as TypeboxSchemaValidator } from '../../schema.types-
|
|
3
|
-
export { i as SafeTObject, f as TCatchall, l as TIdiomaticSchema, h as TObjectShape, g as TOuterArray, o as TResolve, j as TSchemaTranslate, m as TUnionTupleContainer, k as UnboxedTObjectSchema, n as UnionTupleTResolve } from '../../schema.types-
|
|
2
|
+
import { T as TypeboxSchemaValidator } from '../../schema.types-BmSJeE9l.mjs';
|
|
3
|
+
export { i as SafeTObject, f as TCatchall, l as TIdiomaticSchema, h as TObjectShape, g as TOuterArray, o as TResolve, j as TSchemaTranslate, m as TUnionTupleContainer, k as UnboxedTObjectSchema, n as UnionTupleTResolve } from '../../schema.types-BmSJeE9l.mjs';
|
|
4
4
|
import '@forklaunch/common';
|
|
5
5
|
import 'openapi3-ts/oas31';
|
|
6
6
|
import '@sinclair/typebox/compiler';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from '@sinclair/typebox';
|
|
2
|
-
import { T as TypeboxSchemaValidator } from '../../schema.types-
|
|
3
|
-
export { i as SafeTObject, f as TCatchall, l as TIdiomaticSchema, h as TObjectShape, g as TOuterArray, o as TResolve, j as TSchemaTranslate, m as TUnionTupleContainer, k as UnboxedTObjectSchema, n as UnionTupleTResolve } from '../../schema.types-
|
|
2
|
+
import { T as TypeboxSchemaValidator } from '../../schema.types-BmSJeE9l.js';
|
|
3
|
+
export { i as SafeTObject, f as TCatchall, l as TIdiomaticSchema, h as TObjectShape, g as TOuterArray, o as TResolve, j as TSchemaTranslate, m as TUnionTupleContainer, k as UnboxedTObjectSchema, n as UnionTupleTResolve } from '../../schema.types-BmSJeE9l.js';
|
|
4
4
|
import '@forklaunch/common';
|
|
5
5
|
import 'openapi3-ts/oas31';
|
|
6
6
|
import '@sinclair/typebox/compiler';
|
package/lib/src/typebox/index.js
CHANGED
|
@@ -294,12 +294,12 @@ var TypeboxSchemaValidator = class {
|
|
|
294
294
|
* @returns {TResolve<T>} The resolved schema.
|
|
295
295
|
*/
|
|
296
296
|
schemify(schema) {
|
|
297
|
-
if (import_typebox.KindGuard.IsSchema(schema) || schema instanceof import_compiler.TypeCheck) {
|
|
298
|
-
return schema;
|
|
299
|
-
}
|
|
300
297
|
if (typeof schema === "string" || typeof schema === "number" || typeof schema === "boolean") {
|
|
301
298
|
return import_typebox.Type.Literal(schema);
|
|
302
299
|
}
|
|
300
|
+
if (import_typebox.KindGuard.IsSchema(schema) || schema instanceof import_compiler.TypeCheck) {
|
|
301
|
+
return schema;
|
|
302
|
+
}
|
|
303
303
|
const newSchema = {};
|
|
304
304
|
Object.getOwnPropertyNames(schema).forEach((key) => {
|
|
305
305
|
if (import_typebox.KindGuard.IsSchema(schema[key])) {
|
|
@@ -245,12 +245,12 @@ var TypeboxSchemaValidator = class {
|
|
|
245
245
|
* @returns {TResolve<T>} The resolved schema.
|
|
246
246
|
*/
|
|
247
247
|
schemify(schema) {
|
|
248
|
-
if (KindGuard.IsSchema(schema) || schema instanceof TypeCheck) {
|
|
249
|
-
return schema;
|
|
250
|
-
}
|
|
251
248
|
if (typeof schema === "string" || typeof schema === "number" || typeof schema === "boolean") {
|
|
252
249
|
return Type.Literal(schema);
|
|
253
250
|
}
|
|
251
|
+
if (KindGuard.IsSchema(schema) || schema instanceof TypeCheck) {
|
|
252
|
+
return schema;
|
|
253
|
+
}
|
|
254
254
|
const newSchema = {};
|
|
255
255
|
Object.getOwnPropertyNames(schema).forEach((key) => {
|
|
256
256
|
if (KindGuard.IsSchema(schema[key])) {
|
package/lib/src/zod/index.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { ZodAny, ZodArray, ZodBigInt, ZodBoolean, ZodDate, ZodEffects, ZodEnum, ZodFunction, ZodLiteral, ZodNever, ZodNull, ZodNumber, ZodObject, ZodOptional, ZodPipeline, ZodPromise, ZodRawShape, ZodRecord, ZodString, ZodSymbol, ZodTuple, ZodType, ZodTypeAny, ZodUndefined, ZodUnion, ZodUnknown, ZodVoid } from 'zod/v3';
|
|
2
|
-
import { Z as ZodSchemaValidator } from '../../schema.types-
|
|
3
|
-
export { w as TupleZodResolve, t as UnboxedZodObjectSchema, y as UnionZodResolve, p as ZodCatchall, u as ZodIdiomaticSchema, r as ZodObjectShape, q as ZodOuterArray, B as ZodRecordKey, z as ZodResolve, s as ZodSchemaTranslate, v as ZodTupleContainer, x as ZodUnionContainer } from '../../schema.types-
|
|
2
|
+
import { Z as ZodSchemaValidator } from '../../schema.types-BmSJeE9l.mjs';
|
|
3
|
+
export { w as TupleZodResolve, t as UnboxedZodObjectSchema, y as UnionZodResolve, p as ZodCatchall, u as ZodIdiomaticSchema, r as ZodObjectShape, q as ZodOuterArray, B as ZodRecordKey, z as ZodResolve, s as ZodSchemaTranslate, v as ZodTupleContainer, x as ZodUnionContainer } from '../../schema.types-BmSJeE9l.mjs';
|
|
4
4
|
import '@forklaunch/common';
|
|
5
5
|
import 'openapi3-ts/oas31';
|
|
6
6
|
import '@sinclair/typebox';
|
package/lib/src/zod/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { ZodAny, ZodArray, ZodBigInt, ZodBoolean, ZodDate, ZodEffects, ZodEnum, ZodFunction, ZodLiteral, ZodNever, ZodNull, ZodNumber, ZodObject, ZodOptional, ZodPipeline, ZodPromise, ZodRawShape, ZodRecord, ZodString, ZodSymbol, ZodTuple, ZodType, ZodTypeAny, ZodUndefined, ZodUnion, ZodUnknown, ZodVoid } from 'zod/v3';
|
|
2
|
-
import { Z as ZodSchemaValidator } from '../../schema.types-
|
|
3
|
-
export { w as TupleZodResolve, t as UnboxedZodObjectSchema, y as UnionZodResolve, p as ZodCatchall, u as ZodIdiomaticSchema, r as ZodObjectShape, q as ZodOuterArray, B as ZodRecordKey, z as ZodResolve, s as ZodSchemaTranslate, v as ZodTupleContainer, x as ZodUnionContainer } from '../../schema.types-
|
|
2
|
+
import { Z as ZodSchemaValidator } from '../../schema.types-BmSJeE9l.js';
|
|
3
|
+
export { w as TupleZodResolve, t as UnboxedZodObjectSchema, y as UnionZodResolve, p as ZodCatchall, u as ZodIdiomaticSchema, r as ZodObjectShape, q as ZodOuterArray, B as ZodRecordKey, z as ZodResolve, s as ZodSchemaTranslate, v as ZodTupleContainer, x as ZodUnionContainer } from '../../schema.types-BmSJeE9l.js';
|
|
4
4
|
import '@forklaunch/common';
|
|
5
5
|
import 'openapi3-ts/oas31';
|
|
6
6
|
import '@sinclair/typebox';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forklaunch/validator",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Schema validator for ForkLaunch components.",
|
|
5
5
|
"homepage": "https://github.com/forklaunch/forklaunch-js#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -58,27 +58,27 @@
|
|
|
58
58
|
"lib/**"
|
|
59
59
|
],
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@sinclair/typebox": "^0.34.
|
|
61
|
+
"@sinclair/typebox": "^0.34.38",
|
|
62
62
|
"ts-deepmerge": "^7.0.3",
|
|
63
|
-
"zod": "^4.0.
|
|
64
|
-
"@forklaunch/common": "0.4.
|
|
63
|
+
"zod": "^4.0.14",
|
|
64
|
+
"@forklaunch/common": "0.4.6"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
|
-
"@eslint/js": "^9.
|
|
67
|
+
"@eslint/js": "^9.32.0",
|
|
68
68
|
"@types/jest": "^30.0.0",
|
|
69
|
-
"@types/node": "^24.0
|
|
70
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
69
|
+
"@types/node": "^24.1.0",
|
|
70
|
+
"@typescript/native-preview": "7.0.0-dev.20250802.1",
|
|
71
71
|
"@vitest/coverage-v8": "^3.2.4",
|
|
72
|
-
"eslint-config-prettier": "^10.1.
|
|
73
|
-
"eslint-plugin-prettier": "^5.5.
|
|
72
|
+
"eslint-config-prettier": "^10.1.8",
|
|
73
|
+
"eslint-plugin-prettier": "^5.5.3",
|
|
74
74
|
"globals": "^16.3.0",
|
|
75
|
-
"jest": "^30.0.
|
|
75
|
+
"jest": "^30.0.5",
|
|
76
76
|
"openapi3-ts": "^4.5.0",
|
|
77
77
|
"ts-jest": "^29.4.0",
|
|
78
78
|
"ts-node": "^10.9.2",
|
|
79
79
|
"tsup": "^8.5.0",
|
|
80
|
-
"typedoc": "^0.28.
|
|
81
|
-
"typescript-eslint": "^8.
|
|
80
|
+
"typedoc": "^0.28.9",
|
|
81
|
+
"typescript-eslint": "^8.38.0"
|
|
82
82
|
},
|
|
83
83
|
"scripts": {
|
|
84
84
|
"build": "tsgo --noEmit && tsup index.ts src/typebox/index.ts src/zod/index.ts __test__/utils/mockSchemaValidator.ts shims/zod-v3-openapi/zod-extensions.ts --format cjs,esm --no-splitting --tsconfig tsconfig.json --outDir lib --dts --clean",
|