@@ -15,3 +15,3 @@ // deno-fmt-ignore-file | ||
| && Object.values(schema.dependencies).every(value => IsSchema(value) | ||
| || Guard.IsArray(value) && value.every(value => Guard.IsString(value))); | ||
| || (Guard.IsArray(value) && value.every(value => Guard.IsString(value)))); | ||
| } |
@@ -162,3 +162,3 @@ import { Memory } from '../../system/memory/index.mjs'; | ||
| export declare function BaseMapping(input: [unknown, unknown, unknown] | unknown): unknown; | ||
| export type TWithMapping<Input extends [unknown, unknown] | []> = (Input extends ['with', infer JsonObject extends Record<PropertyKey, unknown>] ? JsonObject : []); | ||
| export type TWithMapping<Input extends [unknown, unknown] | []> = (Input extends ['with', infer WithObject extends Record<PropertyKey, unknown>] ? WithObject : []); | ||
| export declare function WithMapping(input: [unknown, unknown] | []): unknown; | ||
@@ -280,27 +280,31 @@ type TFactorIndexArray<Type extends T.TSchema, IndexArray extends unknown[]> = (IndexArray extends [infer Left extends T.TSchema[], ...infer Right extends unknown[]] ? (Left extends [infer Indexer extends T.TSchema] ? TFactorIndexArray<S.TIndexDeferred<Type, Indexer>, Right> : Left extends [] ? TFactorIndexArray<T.TArray<Type>, Right> : T.TNever) : Type); | ||
| export declare function ReferenceMapping(input: string): unknown; | ||
| export type TJsonNumberMapping<Input extends string> = (Input extends `${infer Value extends number}` ? Value : never); | ||
| export declare function JsonNumberMapping(input: string): unknown; | ||
| export type TJsonBooleanMapping<Input extends 'true' | 'false'> = (Input extends 'true' ? true : false); | ||
| export declare function JsonBooleanMapping(input: 'true' | 'false'): unknown; | ||
| export type TJsonStringMapping<Input extends string> = (Input); | ||
| export declare function JsonStringMapping(input: string): unknown; | ||
| export type TJsonNullMapping<Input extends 'null'> = (null); | ||
| export declare function JsonNullMapping(input: 'null'): unknown; | ||
| export type TJsonPropertyMapping<Input extends [unknown, unknown, unknown]> = (Input extends [infer Key extends string, ':', infer Value extends unknown] ? { | ||
| export type TWithBigIntMapping<Input extends string> = (Input extends `${infer Value extends bigint}` ? Value : never); | ||
| export declare function WithBigIntMapping(input: string): unknown; | ||
| export type TWithNumberMapping<Input extends string> = (Input extends `${infer Value extends number}` ? Value : never); | ||
| export declare function WithNumberMapping(input: string): unknown; | ||
| export type TWithBooleanMapping<Input extends 'true' | 'false'> = (Input extends 'true' ? true : false); | ||
| export declare function WithBooleanMapping(input: 'true' | 'false'): unknown; | ||
| export type TWithStringMapping<Input extends string> = (Input); | ||
| export declare function WithStringMapping(input: string): unknown; | ||
| export type TWithNullMapping<Input extends 'null'> = (null); | ||
| export declare function WithNullMapping(input: 'null'): unknown; | ||
| export type TWithUndefinedMapping<Input extends 'undefined'> = undefined; | ||
| export declare function WithUndefinedMapping(input: 'undefined'): unknown; | ||
| export type TWithPropertyMapping<Input extends [unknown, unknown, unknown]> = (Input extends [infer Key extends string, ':', infer Value extends unknown] ? { | ||
| [_ in Key]: Value; | ||
| } : never); | ||
| export declare function JsonPropertyMapping(input: [unknown, unknown, unknown]): unknown; | ||
| export type TJsonPropertyListMapping<Input extends [unknown, unknown]> = (TDelimited<Input>); | ||
| export declare function JsonPropertyListMapping(input: [unknown, unknown]): unknown; | ||
| type TJsonObjectMappingReduce<PropertyList extends Record<PropertyKey, unknown>[], Result extends Record<PropertyKey, unknown> = {}> = (PropertyList extends [infer Left extends Record<PropertyKey, unknown>, ...infer Right extends Record<PropertyKey, unknown>[]] ? TJsonObjectMappingReduce<Right, Memory.TAssign<Result, Left>> : { | ||
| export declare function WithPropertyMapping(input: [unknown, unknown, unknown]): unknown; | ||
| export type TWithPropertyListMapping<Input extends [unknown, unknown]> = (TDelimited<Input>); | ||
| export declare function WithPropertyListMapping(input: [unknown, unknown]): unknown; | ||
| type TWithObjectMappingReduce<PropertyList extends Record<PropertyKey, unknown>[], Result extends Record<PropertyKey, unknown> = {}> = (PropertyList extends [infer Left extends Record<PropertyKey, unknown>, ...infer Right extends Record<PropertyKey, unknown>[]] ? TWithObjectMappingReduce<Right, Memory.TAssign<Result, Left>> : { | ||
| [Key in keyof Result]: Result[Key]; | ||
| }); | ||
| export type TJsonObjectMapping<Input extends [unknown, unknown, unknown]> = (Input extends ['{', infer PropertyList extends Record<PropertyKey, unknown>[], '}'] ? TJsonObjectMappingReduce<PropertyList> : {}); | ||
| export declare function JsonObjectMapping(input: [unknown, unknown, unknown]): unknown; | ||
| export type TJsonElementListMapping<Input extends [unknown, unknown]> = (TDelimited<Input>); | ||
| export declare function JsonElementListMapping(input: [unknown, unknown]): unknown; | ||
| export type TJsonArrayMapping<Input extends [unknown, unknown, unknown]> = (Input extends ['[', infer Elements extends unknown[], ']'] ? Elements : never); | ||
| export declare function JsonArrayMapping(input: [unknown, unknown, unknown]): unknown; | ||
| export type TJsonMapping<Input extends unknown> = (Input); | ||
| export declare function JsonMapping(input: unknown): unknown; | ||
| export type TWithObjectMapping<Input extends [unknown, unknown, unknown]> = (Input extends ['{', infer PropertyList extends Record<PropertyKey, unknown>[], '}'] ? TWithObjectMappingReduce<PropertyList> : {}); | ||
| export declare function WithObjectMapping(input: [unknown, unknown, unknown]): unknown; | ||
| export type TWithElementListMapping<Input extends [unknown, unknown]> = (TDelimited<Input>); | ||
| export declare function WithElementListMapping(input: [unknown, unknown]): unknown; | ||
| export type TWithArrayMapping<Input extends [unknown, unknown, unknown]> = (Input extends ['[', infer Elements extends unknown[], ']'] ? Elements : never); | ||
| export declare function WithArrayMapping(input: [unknown, unknown, unknown]): unknown; | ||
| export type TWithValueMapping<Input extends unknown> = (Input); | ||
| export declare function WithValueMapping(input: unknown): unknown; | ||
| export type TPatternBigIntMapping<Input extends '-?(?:0|[1-9][0-9]*)n'> = (T.TBigInt); | ||
@@ -307,0 +311,0 @@ export declare function PatternBigIntMapping(input: '-?(?:0|[1-9][0-9]*)n'): unknown; |
@@ -416,21 +416,27 @@ // deno-fmt-ignore-file | ||
| } | ||
| export function JsonNumberMapping(input) { | ||
| export function WithBigIntMapping(input) { | ||
| return BigInt(input); | ||
| } | ||
| export function WithNumberMapping(input) { | ||
| return parseFloat(input); | ||
| } | ||
| export function JsonBooleanMapping(input) { | ||
| export function WithBooleanMapping(input) { | ||
| return Guard.IsEqual(input, 'true'); | ||
| } | ||
| export function JsonStringMapping(input) { | ||
| export function WithStringMapping(input) { | ||
| return input; | ||
| } | ||
| export function JsonNullMapping(input) { | ||
| export function WithNullMapping(input) { | ||
| return null; | ||
| } | ||
| export function JsonPropertyMapping(input) { | ||
| export function WithUndefinedMapping(input) { | ||
| return undefined; | ||
| } | ||
| export function WithPropertyMapping(input) { | ||
| return { [input[0]]: input[2] }; | ||
| } | ||
| export function JsonPropertyListMapping(input) { | ||
| export function WithPropertyListMapping(input) { | ||
| return Delimited(input); | ||
| } | ||
| function JsonObjectMappingReduce(propertyList) { | ||
| function WithObjectMappingReduce(propertyList) { | ||
| return propertyList.reduce((result, left) => { | ||
@@ -440,12 +446,12 @@ return Memory.Assign(result, left); | ||
| } | ||
| export function JsonObjectMapping(input) { | ||
| return JsonObjectMappingReduce(input[1]); | ||
| export function WithObjectMapping(input) { | ||
| return WithObjectMappingReduce(input[1]); | ||
| } | ||
| export function JsonElementListMapping(input) { | ||
| export function WithElementListMapping(input) { | ||
| return Delimited(input); | ||
| } | ||
| export function JsonArrayMapping(input) { | ||
| export function WithArrayMapping(input) { | ||
| return input[1]; | ||
| } | ||
| export function JsonMapping(input) { | ||
| export function WithValueMapping(input) { | ||
| return input; | ||
@@ -452,0 +458,0 @@ } |
@@ -49,3 +49,3 @@ // deno-fmt-ignore-file | ||
| export const Base = (input) => If(If(If(Token.Const('(', input), ([_0, input]) => If(Type(input), ([_1, input]) => If(Token.Const(')', input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [_0, input], () => If(KeywordString(input), ([_0, input]) => [_0, input], () => If(KeywordNumber(input), ([_0, input]) => [_0, input], () => If(KeywordBoolean(input), ([_0, input]) => [_0, input], () => If(KeywordUndefined(input), ([_0, input]) => [_0, input], () => If(KeywordNull(input), ([_0, input]) => [_0, input], () => If(KeywordInteger(input), ([_0, input]) => [_0, input], () => If(KeywordBigInt(input), ([_0, input]) => [_0, input], () => If(KeywordUnknown(input), ([_0, input]) => [_0, input], () => If(KeywordAny(input), ([_0, input]) => [_0, input], () => If(KeywordObject(input), ([_0, input]) => [_0, input], () => If(KeywordNever(input), ([_0, input]) => [_0, input], () => If(KeywordSymbol(input), ([_0, input]) => [_0, input], () => If(KeywordVoid(input), ([_0, input]) => [_0, input], () => If(KeywordThis(input), ([_0, input]) => [_0, input], () => If(LiteralBigInt(input), ([_0, input]) => [_0, input], () => If(LiteralBoolean(input), ([_0, input]) => [_0, input], () => If(LiteralNumber(input), ([_0, input]) => [_0, input], () => If(LiteralString(input), ([_0, input]) => [_0, input], () => If(TemplateLiteral(input), ([_0, input]) => [_0, input], () => If(Dependent(input), ([_0, input]) => [_0, input], () => If(_Object_(input), ([_0, input]) => [_0, input], () => If(_Tuple_(input), ([_0, input]) => [_0, input], () => If(_Constructor_(input), ([_0, input]) => [_0, input], () => If(_Function_(input), ([_0, input]) => [_0, input], () => If(_Mapped_(input), ([_0, input]) => [_0, input], () => If(GenericCall(input), ([_0, input]) => [_0, input], () => If(Reference(input), ([_0, input]) => [_0, input], () => [])))))))))))))))))))))))))))), ([_0, input]) => [S.BaseMapping(_0), input]); | ||
| export const With = (input) => If(If(If(Token.Const('with', input), ([_0, input]) => If(JsonObject(input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.WithMapping(_0), input]); | ||
| export const With = (input) => If(If(If(Token.Const('with', input), ([_0, input]) => If(WithObject(input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.WithMapping(_0), input]); | ||
| export const Factor = (input) => If(If(KeyOf(input), ([_0, input]) => If(Base(input), ([_1, input]) => If(IndexArray(input), ([_2, input]) => If(Extends(input), ([_3, input]) => If(With(input), ([_4, input]) => [[_0, _1, _2, _3, _4], input]))))), ([_0, input]) => [S.FactorMapping(_0), input]); | ||
@@ -98,14 +98,16 @@ export const ExprTermTail = (input) => If(If(If(Token.Const('&', input), ([_0, input]) => If(Factor(input), ([_1, input]) => If(ExprTermTail(input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.ExprTermTailMapping(_0), input]); | ||
| export const Reference = (input) => If(Token.Ident(input), ([_0, input]) => [S.ReferenceMapping(_0), input]); | ||
| export const JsonNumber = (input) => If(Token.Number(input), ([_0, input]) => [S.JsonNumberMapping(_0), input]); | ||
| export const JsonBoolean = (input) => If(If(Token.Const('true', input), ([_0, input]) => [_0, input], () => If(Token.Const('false', input), ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.JsonBooleanMapping(_0), input]); | ||
| export const JsonString = (input) => If(Token.String(['\"', '\''], input), ([_0, input]) => [S.JsonStringMapping(_0), input]); | ||
| export const JsonNull = (input) => If(Token.Const('null', input), ([_0, input]) => [S.JsonNullMapping(_0), input]); | ||
| export const JsonProperty = (input) => If(If(PropertyKey(input), ([_0, input]) => If(Token.Const(':', input), ([_1, input]) => If(Json(input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [S.JsonPropertyMapping(_0), input]); | ||
| export const JsonPropertyList_0 = (input, result = []) => If(If(JsonProperty(input), ([_0, input]) => If(PropertyDelimiter(input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => JsonPropertyList_0(input, [...result, _0]), () => [result, input]); | ||
| export const JsonPropertyList = (input) => If(If(JsonPropertyList_0(input), ([_0, input]) => If(If(If(JsonProperty(input), ([_0, input]) => [[_0], input]), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => [S.JsonPropertyListMapping(_0), input]); | ||
| export const JsonObject = (input) => If(If(Token.Const('{', input), ([_0, input]) => If(JsonPropertyList(input), ([_1, input]) => If(Token.Const('}', input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [S.JsonObjectMapping(_0), input]); | ||
| export const JsonElementList_0 = (input, result = []) => If(If(Json(input), ([_0, input]) => If(Token.Const(',', input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => JsonElementList_0(input, [...result, _0]), () => [result, input]); | ||
| export const JsonElementList = (input) => If(If(JsonElementList_0(input), ([_0, input]) => If(If(If(Json(input), ([_0, input]) => [[_0], input]), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => [S.JsonElementListMapping(_0), input]); | ||
| export const JsonArray = (input) => If(If(Token.Const('[', input), ([_0, input]) => If(JsonElementList(input), ([_1, input]) => If(Token.Const(']', input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [S.JsonArrayMapping(_0), input]); | ||
| export const Json = (input) => If(If(JsonNumber(input), ([_0, input]) => [_0, input], () => If(JsonBoolean(input), ([_0, input]) => [_0, input], () => If(JsonString(input), ([_0, input]) => [_0, input], () => If(JsonNull(input), ([_0, input]) => [_0, input], () => If(JsonObject(input), ([_0, input]) => [_0, input], () => If(JsonArray(input), ([_0, input]) => [_0, input], () => [])))))), ([_0, input]) => [S.JsonMapping(_0), input]); | ||
| export const WithBigInt = (input) => If(Token.BigInt(input), ([_0, input]) => [S.WithBigIntMapping(_0), input]); | ||
| export const WithNumber = (input) => If(Token.Number(input), ([_0, input]) => [S.WithNumberMapping(_0), input]); | ||
| export const WithBoolean = (input) => If(If(Token.Const('true', input), ([_0, input]) => [_0, input], () => If(Token.Const('false', input), ([_0, input]) => [_0, input], () => [])), ([_0, input]) => [S.WithBooleanMapping(_0), input]); | ||
| export const WithString = (input) => If(Token.String(['\"', '\''], input), ([_0, input]) => [S.WithStringMapping(_0), input]); | ||
| export const WithNull = (input) => If(Token.Const('null', input), ([_0, input]) => [S.WithNullMapping(_0), input]); | ||
| export const WithUndefined = (input) => If(Token.Const('undefined', input), ([_0, input]) => [S.WithUndefinedMapping(_0), input]); | ||
| export const WithProperty = (input) => If(If(PropertyKey(input), ([_0, input]) => If(Token.Const(':', input), ([_1, input]) => If(WithValue(input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [S.WithPropertyMapping(_0), input]); | ||
| export const WithPropertyList_0 = (input, result = []) => If(If(WithProperty(input), ([_0, input]) => If(PropertyDelimiter(input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => WithPropertyList_0(input, [...result, _0]), () => [result, input]); | ||
| export const WithPropertyList = (input) => If(If(WithPropertyList_0(input), ([_0, input]) => If(If(If(WithProperty(input), ([_0, input]) => [[_0], input]), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => [S.WithPropertyListMapping(_0), input]); | ||
| export const WithObject = (input) => If(If(Token.Const('{', input), ([_0, input]) => If(WithPropertyList(input), ([_1, input]) => If(Token.Const('}', input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [S.WithObjectMapping(_0), input]); | ||
| export const WithElementList_0 = (input, result = []) => If(If(WithValue(input), ([_0, input]) => If(Token.Const(',', input), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => WithElementList_0(input, [...result, _0]), () => [result, input]); | ||
| export const WithElementList = (input) => If(If(WithElementList_0(input), ([_0, input]) => If(If(If(WithValue(input), ([_0, input]) => [[_0], input]), ([_0, input]) => [_0, input], () => If([[], input], ([_0, input]) => [_0, input], () => [])), ([_1, input]) => [[_0, _1], input])), ([_0, input]) => [S.WithElementListMapping(_0), input]); | ||
| export const WithArray = (input) => If(If(Token.Const('[', input), ([_0, input]) => If(WithElementList(input), ([_1, input]) => If(Token.Const(']', input), ([_2, input]) => [[_0, _1, _2], input]))), ([_0, input]) => [S.WithArrayMapping(_0), input]); | ||
| export const WithValue = (input) => If(If(WithBigInt(input), ([_0, input]) => [_0, input], () => If(WithNumber(input), ([_0, input]) => [_0, input], () => If(WithBoolean(input), ([_0, input]) => [_0, input], () => If(WithString(input), ([_0, input]) => [_0, input], () => If(WithNull(input), ([_0, input]) => [_0, input], () => If(WithUndefined(input), ([_0, input]) => [_0, input], () => If(WithObject(input), ([_0, input]) => [_0, input], () => If(WithArray(input), ([_0, input]) => [_0, input], () => [])))))))), ([_0, input]) => [S.WithValueMapping(_0), input]); | ||
| export const PatternBigInt = (input) => If(Token.Const('-?(?:0|[1-9][0-9]*)n', input), ([_0, input]) => [S.PatternBigIntMapping(_0), input]); | ||
@@ -112,0 +114,0 @@ export const PatternString = (input) => If(Token.Const('.*', input), ([_0, input]) => [S.PatternStringMapping(_0), input]); |
+1
-1
| { | ||
| "name": "typebox", | ||
| "description": "Json Schema Type Builder with Static Type Resolution for TypeScript", | ||
| "version": "1.2.5", | ||
| "version": "1.2.6", | ||
| "keywords": [ | ||
@@ -6,0 +6,0 @@ "typescript", |
Sorry, the diff of this file is too big to display
1501241
0.11%17133
0.05%