14
package-lock.json
generated
14
package-lock.json
generated
@@ -18,7 +18,7 @@
|
||||
"typescript": "^5.7.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@sinclair/typebox": "^0.34.15",
|
||||
"@sinclair/typebox": "^0.34.16",
|
||||
"valibot": "^1.0.0-beta.15",
|
||||
"zod": "^3.24.1"
|
||||
}
|
||||
@@ -170,9 +170,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@sinclair/typebox": {
|
||||
"version": "0.34.15",
|
||||
"resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.34.15.tgz",
|
||||
"integrity": "sha512-xeIzl3h1Znn9w/LTITqpiwag0gXjA+ldi2ZkXIBxGEppGCW211Tza+eL6D4pKqs10bj5z2umBWk5WL6spQ2OCQ==",
|
||||
"version": "0.34.16",
|
||||
"resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.34.16.tgz",
|
||||
"integrity": "sha512-rIljj8VPYAfn26ANY+5pCNVBPiv6hSufuKGe46y65cJZpvx8vHvPXlU0Q/Le4OGtlNaL8Jg2FuhtvQX18lSIqA==",
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/@sindresorhus/is": {
|
||||
@@ -2264,9 +2264,9 @@
|
||||
}
|
||||
},
|
||||
"@sinclair/typebox": {
|
||||
"version": "0.34.15",
|
||||
"resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.34.15.tgz",
|
||||
"integrity": "sha512-xeIzl3h1Znn9w/LTITqpiwag0gXjA+ldi2ZkXIBxGEppGCW211Tza+eL6D4pKqs10bj5z2umBWk5WL6spQ2OCQ==",
|
||||
"version": "0.34.16",
|
||||
"resolved": "https://registry.npmjs.org/@sinclair/typebox/-/typebox-0.34.16.tgz",
|
||||
"integrity": "sha512-rIljj8VPYAfn26ANY+5pCNVBPiv6hSufuKGe46y65cJZpvx8vHvPXlU0Q/Le4OGtlNaL8Jg2FuhtvQX18lSIqA==",
|
||||
"peer": true
|
||||
},
|
||||
"@sindresorhus/is": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@sinclair/typemap",
|
||||
"version": "0.8.13",
|
||||
"version": "0.8.14",
|
||||
"description": "Syntax Compiler and Translation System for Runtime Types",
|
||||
"author": "sinclairzx81",
|
||||
"license": "MIT",
|
||||
@@ -18,7 +18,7 @@
|
||||
"publish": "hammer task publish"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@sinclair/typebox": "^0.34.15",
|
||||
"@sinclair/typebox": "^0.34.16",
|
||||
"valibot": "^1.0.0-beta.15",
|
||||
"zod": "^3.24.1"
|
||||
},
|
||||
|
||||
@@ -37,7 +37,7 @@ type BaseSchema = v.BaseSchema<unknown, unknown, v.BaseIssue<unknown>>
|
||||
/** Statically infers a type */
|
||||
// prettier-ignore
|
||||
export type Static<Type extends object | string> = (
|
||||
Type extends string ? s.StaticParseAsType<{}, Type> :
|
||||
Type extends string ? s.TSyntax<{}, Type> :
|
||||
Type extends Validator<infer Type extends t.TSchema> ? t.Static<Type> :
|
||||
Type extends t.TSchema ? t.Static<Type> :
|
||||
Type extends BaseSchema ? v.InferInput<Type> :
|
||||
|
||||
@@ -26,7 +26,7 @@ THE SOFTWARE.
|
||||
|
||||
---------------------------------------------------------------------------*/
|
||||
|
||||
import { StaticParseAsSchema, Parse } from '@sinclair/typebox/syntax'
|
||||
import { TSyntax, Syntax } from '@sinclair/typebox/syntax'
|
||||
import * as t from '@sinclair/typebox'
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
@@ -35,13 +35,10 @@ import * as t from '@sinclair/typebox'
|
||||
|
||||
// prettier-ignore
|
||||
export type TTypeBoxFromSyntax<Context extends t.TProperties, Type extends string,
|
||||
TypeBox = StaticParseAsSchema<Context, Type>,
|
||||
Result extends t.TSchema = TypeBox extends t.TSchema ? TypeBox : t.TNever
|
||||
Result extends t.TSchema = TSyntax<Context, Type>
|
||||
> = Result
|
||||
|
||||
/** Creates a TypeBox Type From Syntax */
|
||||
export function TypeBoxFromSyntax<Context extends t.TProperties, Type extends string>(context: Context, type: Type, options?: t.SchemaOptions): TTypeBoxFromSyntax<Context, Type> {
|
||||
const typebox = t.ValueGuard.IsString(type) ? Parse(context, type, options) : t.Never()
|
||||
const result = t.KindGuard.IsSchema(typebox) ? typebox : t.Never()
|
||||
return result as never
|
||||
return Syntax(context, type, options)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user