Comparing version 2.0.0-rc.8 to 2.0.0-rc.9
import type { ArkSchemaRegistry } from "@ark/schema"; | ||
import type { Ark } from "./keywords/ark.ts"; | ||
import type { Ark } from "./keywords/keywords.ts"; | ||
import type { exportScope } from "./module.ts"; | ||
@@ -4,0 +4,0 @@ export * from "@ark/schema/config"; |
import { GenericRoot, type arkKind, type BaseParseContext, type GenericAst, type GenericParamAst, type GenericParamDef, type genericParamNames, type LazyGenericBody } from "@ark/schema"; | ||
import { type array, type Callable, type conform, type ErrorMessage, type ErrorType, type Hkt, type Json, type WhiteSpaceToken } from "@ark/util"; | ||
import type { type } from "./keywords/ark.ts"; | ||
import type { type } from "./keywords/keywords.ts"; | ||
import type { inferAstRoot } from "./parser/ast/infer.ts"; | ||
import type { validateAst } from "./parser/ast/validate.ts"; | ||
import type { inferDefinition, validateDefinition } from "./parser/definition.ts"; | ||
import type { inferAstRoot } from "./parser/semantic/infer.ts"; | ||
import type { validateAst } from "./parser/semantic/validate.ts"; | ||
import type { state, StaticState } from "./parser/string/reduce/static.ts"; | ||
import type { Scanner } from "./parser/string/shift/scanner.ts"; | ||
import { parseUntilFinalizer } from "./parser/string/string.ts"; | ||
import type { state, StaticState } from "./parser/reduce/static.ts"; | ||
import type { Scanner } from "./parser/shift/scanner.ts"; | ||
import { parseUntilFinalizer } from "./parser/string.ts"; | ||
import type { Scope } from "./scope.ts"; | ||
@@ -11,0 +11,0 @@ import type { Type } from "./type.ts"; |
import { GenericRoot } from "@ark/schema"; | ||
import { throwParseError } from "@ark/util"; | ||
import { DynamicState } from "./parser/string/reduce/dynamic.js"; | ||
import { parseUntilFinalizer } from "./parser/string/string.js"; | ||
import { DynamicState } from "./parser/reduce/dynamic.js"; | ||
import { parseUntilFinalizer } from "./parser/string.js"; | ||
export const Generic = GenericRoot; | ||
@@ -6,0 +6,0 @@ export const emptyGenericParameterMessage = "An empty string is not a valid generic parameter name"; |
export { ArkError, ArkErrors, type ArkConfig, type ArkScopeConfig, type JsonSchema } from "@ark/schema"; | ||
export { Hkt, inferred } from "@ark/util"; | ||
export { Generic } from "./generic.ts"; | ||
export { ambient, ark, declare, define, generic, type, type Ark } from "./keywords/ark.ts"; | ||
export { ark, declare, define, generic, keywords, type, type Ark } from "./keywords/keywords.ts"; | ||
export { Module, type BoundModule, type Submodule } from "./module.ts"; | ||
export { module, scope, type Scope } from "./scope.ts"; | ||
export { Type } from "./type.ts"; |
export { ArkError, ArkErrors } from "@ark/schema"; | ||
export { Hkt, inferred } from "@ark/util"; | ||
export { Generic } from "./generic.js"; | ||
export { ambient, ark, declare, define, generic, type } from "./keywords/ark.js"; | ||
export { ark, declare, define, generic, keywords, type } from "./keywords/keywords.js"; | ||
export { Module } from "./module.js"; | ||
export { module, scope } from "./scope.js"; | ||
export { Type } from "./type.js"; |
import { Hkt, liftArray, type Digit } from "@ark/util"; | ||
import type { Module, Submodule } from "../../module.ts"; | ||
import type { To } from "../ast.ts"; | ||
import type { To } from "../inference.ts"; | ||
declare class liftFromHkt extends Hkt<[element: unknown]> { | ||
@@ -5,0 +5,0 @@ body: liftArray<this[0]> extends infer lifted ? (In: this[0] | lifted) => To<lifted> : never; |
@@ -1,2 +0,2 @@ | ||
import type { Branded, constrain, constraint, Constraints, Literal, Narrowed, normalizeLimit, Optional } from "../ast.ts"; | ||
import type { Branded, constrain, constraint, Constraints, Literal, Narrowed, normalizeLimit, Optional } from "../inference.ts"; | ||
export type AtOrAfter<rule> = { | ||
@@ -3,0 +3,0 @@ atOrAfter: constraint<rule>; |
import type { Module, Submodule } from "../../module.ts"; | ||
import type { To } from "../ast.ts"; | ||
import type { To } from "../inference.ts"; | ||
export type FormDataValue = string | File; | ||
@@ -4,0 +4,0 @@ export type ParsedFormData = Record<string, FormDataValue | FormDataValue[]>; |
import type { Module, Submodule } from "../../module.ts"; | ||
import type { Branded, constrain, constraint, Constraints, Narrowed, Optional } from "../ast.ts"; | ||
import type { Branded, constrain, constraint, Constraints, Narrowed, Optional } from "../inference.ts"; | ||
import { epoch } from "./epoch.ts"; | ||
@@ -4,0 +4,0 @@ import { integer } from "./integer.ts"; |
@@ -1,2 +0,2 @@ | ||
import type { Branded, constrain } from "../ast.ts"; | ||
import type { Branded, constrain } from "../inference.ts"; | ||
declare namespace string { | ||
@@ -3,0 +3,0 @@ type alpha = constrain<string, Branded<"alpha">>; |
@@ -1,2 +0,2 @@ | ||
import type { Branded, constrain } from "../ast.ts"; | ||
import type { Branded, constrain } from "../inference.ts"; | ||
declare namespace string { | ||
@@ -3,0 +3,0 @@ type alphanumeric = constrain<string, Branded<"alphanumeric">>; |
import type { Module, Submodule } from "../../module.ts"; | ||
import type { Branded, constrain, To } from "../ast.ts"; | ||
import type { Branded, constrain, To } from "../inference.ts"; | ||
declare namespace string { | ||
@@ -4,0 +4,0 @@ type capitalized = constrain<string, Branded<"capitalized">>; |
@@ -1,2 +0,2 @@ | ||
import type { Branded, constrain } from "../ast.ts"; | ||
import type { Branded, constrain } from "../inference.ts"; | ||
export declare const isLuhnValid: (creditCardInput: string) => boolean; | ||
@@ -3,0 +3,0 @@ declare namespace string { |
import type { Module, Submodule } from "../../module.ts"; | ||
import type { Branded, To, constrain } from "../ast.ts"; | ||
import type { Branded, To, constrain } from "../inference.ts"; | ||
type DayDelimiter = "." | "/" | "-"; | ||
@@ -4,0 +4,0 @@ type DayPart = DayPatterns[PartKey]; |
@@ -1,2 +0,2 @@ | ||
import type { Branded, constrain } from "../ast.ts"; | ||
import type { Branded, constrain } from "../inference.ts"; | ||
declare namespace string { | ||
@@ -3,0 +3,0 @@ type digits = constrain<string, Branded<"digits">>; |
@@ -1,2 +0,2 @@ | ||
import type { Branded, constrain } from "../ast.ts"; | ||
import type { Branded, constrain } from "../inference.ts"; | ||
declare namespace string { | ||
@@ -3,0 +3,0 @@ type email = constrain<string, Branded<"email">>; |
import type { Module, Submodule } from "../../module.ts"; | ||
import type { Branded, constrain, To } from "../ast.ts"; | ||
import type { Branded, constrain, To } from "../inference.ts"; | ||
import type { number } from "../number/number.ts"; | ||
@@ -4,0 +4,0 @@ declare namespace string { |
import type { Module, Submodule } from "../../module.ts"; | ||
import type { Branded, constrain } from "../ast.ts"; | ||
import type { Branded, constrain } from "../inference.ts"; | ||
declare namespace string { | ||
@@ -4,0 +4,0 @@ type ip = constrain<string, Branded<"ip">>; |
import type { Module, Submodule } from "../../module.ts"; | ||
import type { Branded, To, constrain } from "../ast.ts"; | ||
import type { Branded, To, constrain } from "../inference.ts"; | ||
declare namespace string { | ||
@@ -4,0 +4,0 @@ type json = constrain<string, Branded<"json">>; |
import type { Module, Submodule } from "../../module.ts"; | ||
import type { Branded, constrain, To } from "../ast.ts"; | ||
import type { Branded, constrain, To } from "../inference.ts"; | ||
declare namespace string { | ||
@@ -4,0 +4,0 @@ type lowercase = constrain<string, Branded<"lowercase">>; |
import type { Module, Submodule } from "../../module.ts"; | ||
import type { Branded, constrain, To } from "../ast.ts"; | ||
import type { Branded, constrain, To } from "../inference.ts"; | ||
declare namespace string { | ||
@@ -4,0 +4,0 @@ type normalized = normalized.NFC; |
import type { Module, Submodule } from "../../module.ts"; | ||
import type { Branded, constrain, To } from "../ast.ts"; | ||
import type { Branded, constrain, To } from "../inference.ts"; | ||
declare namespace string { | ||
@@ -4,0 +4,0 @@ type numeric = constrain<string, Branded<"numeric">>; |
@@ -1,2 +0,2 @@ | ||
import type { Branded, constrain } from "../ast.ts"; | ||
import type { Branded, constrain } from "../inference.ts"; | ||
declare namespace string { | ||
@@ -3,0 +3,0 @@ type semver = constrain<string, Branded<"semver">>; |
import type { Module, Submodule } from "../../module.ts"; | ||
import type { AtLeastLength, AtMostLength, Branded, Constraints, ExactlyLength, LessThanLength, MoreThanLength, Narrowed, Optional, constrain, constraint } from "../ast.ts"; | ||
import type { AtLeastLength, AtMostLength, Branded, Constraints, ExactlyLength, LessThanLength, MoreThanLength, Narrowed, Optional, constrain, constraint } from "../inference.ts"; | ||
import { alpha } from "./alpha.ts"; | ||
@@ -22,2 +22,3 @@ import { alphanumeric } from "./alphanumeric.ts"; | ||
export declare const string: Module<{ | ||
root: unknown; | ||
trim: Submodule<trim.submodule>; | ||
@@ -43,11 +44,8 @@ normalize: Submodule<{ | ||
}>; | ||
root: unknown; | ||
date: Submodule<stringDate.submodule>; | ||
lower: Submodule<lower.submodule>; | ||
upper: Submodule<upper.submodule>; | ||
integer: Submodule<stringInteger.submodule>; | ||
json: Submodule<stringJson.submodule>; | ||
alpha: unknown; | ||
alphanumeric: unknown; | ||
json: Submodule<stringJson.submodule>; | ||
creditCard: unknown; | ||
integer: Submodule<stringInteger.submodule>; | ||
date: Submodule<stringDate.submodule>; | ||
digits: unknown; | ||
@@ -70,2 +68,4 @@ email: unknown; | ||
}>; | ||
upper: Submodule<upper.submodule>; | ||
lower: Submodule<lower.submodule>; | ||
capitalize: Submodule<capitalize.submodule>; | ||
@@ -72,0 +72,0 @@ }>; |
import type { Module, Submodule } from "../../module.ts"; | ||
import type { Branded, constrain, To } from "../ast.ts"; | ||
import type { Branded, constrain, To } from "../inference.ts"; | ||
declare namespace string { | ||
@@ -4,0 +4,0 @@ type trimmed = constrain<string, Branded<"trimmed">>; |
import type { Module, Submodule } from "../../module.ts"; | ||
import type { Branded, constrain, To } from "../ast.ts"; | ||
import type { Branded, constrain, To } from "../inference.ts"; | ||
declare namespace string { | ||
@@ -4,0 +4,0 @@ type uppercase = constrain<string, Branded<"uppercase">>; |
import type { Module, Submodule } from "../../module.ts"; | ||
import type { Branded, constrain, To } from "../ast.ts"; | ||
import type { Branded, constrain, To } from "../inference.ts"; | ||
declare namespace string { | ||
@@ -4,0 +4,0 @@ type url = constrain<string, Branded<"url">>; |
import type { Module, Submodule } from "../../module.ts"; | ||
import type { Branded, constrain } from "../ast.ts"; | ||
import type { Branded, constrain } from "../inference.ts"; | ||
export declare const uuid: Module<{ | ||
@@ -4,0 +4,0 @@ root: import("./string.ts").string.matching<string> | "00000000-0000-0000-0000-000000000000" | "ffffffff-ffff-ffff-ffff-ffffffffffff"; |
import type { ExactLength, ExclusiveNumericRangeSchema, exclusivizeRangeSchema, InclusiveNumericRangeSchema } from "@ark/schema"; | ||
import type { applyConstraintSchema } from "../keywords/ast.ts"; | ||
import type { applyConstraintSchema } from "../keywords/inference.ts"; | ||
import type { ObjectType } from "./object.ts"; | ||
@@ -4,0 +4,0 @@ interface Type< |
import type { ArkErrors, BaseRoot, Disjoint, JsonSchema, MetaSchema, Morph, UndeclaredKeyBehavior } from "@ark/schema"; | ||
import type { anyOrNever, array, Callable, ErrorMessage, inferred, Json, unset } from "@ark/util"; | ||
import type { ArkAmbient } from "../config.ts"; | ||
import type { inferIntersection } from "../intersect.ts"; | ||
import type { type } from "../keywords/ark.ts"; | ||
import type { applyConstraint, Default, distill, inferMorphOut, inferPipes, Optional } from "../keywords/ast.ts"; | ||
import type { applyConstraint, Default, distill, inferIntersection, inferMorphOut, inferPipes, Optional } from "../keywords/inference.ts"; | ||
import type { type } from "../keywords/keywords.ts"; | ||
import type { Scope } from "../scope.ts"; | ||
@@ -13,9 +12,11 @@ import type { ArrayType } from "./array.ts"; | ||
t: t; | ||
infer: this["inferOut"]; | ||
inferBrandableIn: distill.brandable.In<t>; | ||
inferBrandableOut: distill.brandable.Out<t>; | ||
inferIntrospectableOut: distill.introspectable.Out<t>; | ||
infer: distill.Out<t>; | ||
inferOut: distill.Out<t>; | ||
inferIn: distill.In<t>; | ||
[inferred]: t; | ||
json: Json; | ||
toJSON(): Json; | ||
meta: ArkAmbient.meta; | ||
@@ -30,7 +31,5 @@ precompilation: string | undefined; | ||
allows(data: unknown): data is this["inferIn"]; | ||
traverse(data: unknown): distill.Out<t> | ArkErrors; | ||
traverse(data: unknown): this["infer"] | ArkErrors; | ||
configure(meta: MetaSchema): this; | ||
describe(description: string): this; | ||
optional<r = applyConstraint<t, Optional>>(): instantiateType<r, $>; | ||
default<value extends this["infer"], r = (In?: this["inferBrandableIn"]) => Default<value>>(value: value): instantiateType<r, $>; | ||
onUndeclaredKey(behavior: UndeclaredKeyBehavior): this; | ||
@@ -42,15 +41,17 @@ onDeepUndeclaredKey(behavior: UndeclaredKeyBehavior): this; | ||
get out(): instantiateType<this["inferIntrospectableOut"], $>; | ||
intersect<const def, r = type.infer<def, $>>(def: type.validate<def, $>): instantiateType<inferIntersection<t, r>, $> | Disjoint; | ||
and<const def, r = type.infer<def, $>>(def: type.validate<def, $>): instantiateType<inferIntersection<t, r>, $>; | ||
or<const def, r = type.infer<def, $>>(def: type.validate<def, $>): instantiateType<t | r, $>; | ||
intersect<const def>(def: type.validate<def, $>): type.infer<def, $> extends infer r ? instantiateType<inferIntersection<t, r>, $> | Disjoint : never; | ||
and<const def>(def: type.validate<def, $>): type.infer<def, $> extends infer r ? instantiateType<inferIntersection<t, r>, $> : never; | ||
or<const def>(def: type.validate<def, $>): type.infer<def, $> extends infer r ? instantiateType<t | r, $> : never; | ||
array(): ArrayType<t[], $>; | ||
pipe: ChainedPipes<t, $>; | ||
equals<const def>(def: type.validate<def, $>): boolean; | ||
ifEquals<const def>(def: type.validate<def, $>): instantiateType<type.infer<def, $>, $> | undefined; | ||
extends<const def>(other: type.validate<def, $>): this is instantiateType<type.infer<def, $>, $>; | ||
ifExtends<const def>(other: type.validate<def, $>): instantiateType<type.infer<def, $>, $> | undefined; | ||
ifEquals<const def>(def: type.validate<def, $>): type.infer<def, $> extends infer r ? instantiateType<r, $> | undefined : never; | ||
extends<const def>(other: type.validate<def, $>): boolean; | ||
ifExtends<const def>(other: type.validate<def, $>): type.infer<def, $> extends infer r ? instantiateType<r, $> | undefined : never; | ||
overlaps<const def>(r: type.validate<def, $>): boolean; | ||
extract<const def>(r: type.validate<def, $>): instantiateType<Extract<t, type.infer<def, $>>, $>; | ||
exclude<const def>(r: type.validate<def, $>): instantiateType<Exclude<t, type.infer<def, $>>, $>; | ||
distribute<mapOut, reduceOut = mapOut[]>(mapBranch: (branch: Type, i: number, branches: array<Type>) => mapOut, reduceMapped?: (mappedBranches: mapOut[]) => reduceOut): reduceOut; | ||
extract<const def>(r: type.validate<def, $>): type.infer<def, $> extends infer r ? instantiateType<Extract<t, r>, $> : never; | ||
exclude<const def>(r: type.validate<def, $>): type.infer<def, $> extends infer r ? instantiateType<Exclude<t, r>, $> : never; | ||
distribute<mapOut, reduceOut = mapOut[]>(mapBranch: (branch: Type, i: number, branches: array<Type>) => mapOut, reduceMapped?: (mappedBranches: mapOut[]) => reduceOut): NoInfer<reduceOut>; | ||
optional<r = applyConstraint<t, Optional>>(): instantiateType<r, $>; | ||
default<value extends this["infer"], r = (In?: this["inferBrandableIn"]) => Default<value>>(value: value): instantiateType<r, $>; | ||
/** @deprecated */ | ||
@@ -76,9 +77,9 @@ apply: Function["apply"]; | ||
interface ChainedPipeSignature<t, $> { | ||
<a extends Morph<distill.Out<t>>, r = instantiateType<inferPipes<t, [a]>, $>>(a: a): r; | ||
<a extends Morph<distill.Out<t>>, b extends Morph<inferMorphOut<a>>, r = instantiateType<inferPipes<t, [a, b]>, $>>(a: a, b: b): r; | ||
<a extends Morph<distill.Out<t>>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, r = instantiateType<inferPipes<t, [a, b, c]>, $>>(a: a, b: b, c: c): r; | ||
<a extends Morph<distill.Out<t>>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, d extends Morph<inferMorphOut<c>>, r = instantiateType<inferPipes<t, [a, b, c, d]>, $>>(a: a, b: b, c: c, d: d): r; | ||
<a extends Morph<distill.Out<t>>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, d extends Morph<inferMorphOut<c>>, e extends Morph<inferMorphOut<d>>, r = instantiateType<inferPipes<t, [a, b, c, d, e]>, $>>(a: a, b: b, c: c, d: d, e: e): r; | ||
<a extends Morph<distill.Out<t>>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, d extends Morph<inferMorphOut<c>>, e extends Morph<inferMorphOut<d>>, f extends Morph<inferMorphOut<e>>, r = instantiateType<inferPipes<t, [a, b, c, d, e, f]>, $>>(a: a, b: b, c: c, d: d, e: e, f: f): r; | ||
<a extends Morph<distill.Out<t>>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, d extends Morph<inferMorphOut<c>>, e extends Morph<inferMorphOut<d>>, f extends Morph<inferMorphOut<e>>, g extends Morph<inferMorphOut<f>>, r = instantiateType<inferPipes<t, [a, b, c, d, e, f, g]>, $>>(a: a, b: b, c: c, d: d, e: e, f: f, g: g): r; | ||
<a extends Morph<distill.Out<t>>, r = instantiateType<inferPipes<t, [a]>, $>>(a: a): NoInfer<r>; | ||
<a extends Morph<distill.Out<t>>, b extends Morph<inferMorphOut<a>>, r = instantiateType<inferPipes<t, [a, b]>, $>>(a: a, b: b): NoInfer<r>; | ||
<a extends Morph<distill.Out<t>>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, r = instantiateType<inferPipes<t, [a, b, c]>, $>>(a: a, b: b, c: c): NoInfer<r>; | ||
<a extends Morph<distill.Out<t>>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, d extends Morph<inferMorphOut<c>>, r = instantiateType<inferPipes<t, [a, b, c, d]>, $>>(a: a, b: b, c: c, d: d): NoInfer<r>; | ||
<a extends Morph<distill.Out<t>>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, d extends Morph<inferMorphOut<c>>, e extends Morph<inferMorphOut<d>>, r = instantiateType<inferPipes<t, [a, b, c, d, e]>, $>>(a: a, b: b, c: c, d: d, e: e): NoInfer<r>; | ||
<a extends Morph<distill.Out<t>>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, d extends Morph<inferMorphOut<c>>, e extends Morph<inferMorphOut<d>>, f extends Morph<inferMorphOut<e>>, r = instantiateType<inferPipes<t, [a, b, c, d, e, f]>, $>>(a: a, b: b, c: c, d: d, e: e, f: f): NoInfer<r>; | ||
<a extends Morph<distill.Out<t>>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, d extends Morph<inferMorphOut<c>>, e extends Morph<inferMorphOut<d>>, f extends Morph<inferMorphOut<e>>, g extends Morph<inferMorphOut<f>>, r = instantiateType<inferPipes<t, [a, b, c, d, e, f, g]>, $>>(a: a, b: b, c: c, d: d, e: e, f: f, g: g): NoInfer<r>; | ||
} | ||
@@ -85,0 +86,0 @@ export interface ChainedPipes<t, $> extends ChainedPipeSignature<t, $> { |
import type { ExclusiveDateRangeSchema, exclusivizeRangeSchema, InclusiveDateRangeSchema } from "@ark/schema"; | ||
import type { applyConstraintSchema } from "../keywords/ast.ts"; | ||
import type { applyConstraintSchema } from "../keywords/inference.ts"; | ||
import type { ObjectType } from "./object.ts"; | ||
@@ -4,0 +4,0 @@ /** @ts-ignore cast variance */ |
import type { anyOrNever, array } from "@ark/util"; | ||
import type { MorphAst } from "../keywords/ast.ts"; | ||
import type { InferredMorph } from "../keywords/inference.ts"; | ||
import type { ArrayType } from "./array.ts"; | ||
@@ -12,3 +12,3 @@ import type { BaseType } from "./base.ts"; | ||
export type instantiateType<t, $> = [ | ||
Extract<t, MorphAst> | ||
Extract<t, InferredMorph> | ||
] extends [anyOrNever] ? [ | ||
@@ -18,2 +18,2 @@ t | ||
t | ||
] extends [array] ? ArrayType<t, $> : [t] extends [Date] ? DateType<t, $> : ObjectType<t, $> : ValidatorType<t, $> : MorphType<t, $>; | ||
] extends [array] ? ArrayType<t, $> : [t] extends [Date] ? DateType<t, $> : ObjectType<t, $> : unknown extends t ? BaseType<unknown, $> : ValidatorType<t, $> : MorphType<t, $>; |
import type { Predicate, PredicateCast } from "@ark/schema"; | ||
import type { inferPipe } from "../intersect.ts"; | ||
import type { type } from "../keywords/ark.ts"; | ||
import type { applyConstraintSchema, Out, To } from "../keywords/ast.ts"; | ||
import type { applyConstraintSchema, inferPipe, Out, To } from "../keywords/inference.ts"; | ||
import type { type } from "../keywords/keywords.ts"; | ||
import type { BaseType } from "./base.ts"; | ||
/** @ts-ignore cast variance */ | ||
interface Type<out t = unknown, $ = {}> extends BaseType<t, $> { | ||
to<const def, r = type.infer<def, $>>(def: type.validate<def, $>): Type<inferPipe<t, r>, $>; | ||
to<const def, r = type.infer<def, $>>(def: type.validate<def, $>): Type<inferPipe<t, NoInfer<r>>, $>; | ||
narrow<narrowed extends this["infer"] = never>(predicate: Predicate<this["infer"]> | PredicateCast<this["infer"], narrowed>): Type<([ | ||
@@ -10,0 +9,0 @@ narrowed |
import type { Divisor, ExclusiveNumericRangeSchema, exclusivizeRangeSchema, InclusiveNumericRangeSchema } from "@ark/schema"; | ||
import type { applyConstraintSchema } from "../keywords/ast.ts"; | ||
import type { applyConstraintSchema } from "../keywords/inference.ts"; | ||
import type { ValidatorType } from "./validator.ts"; | ||
@@ -4,0 +4,0 @@ /** @ts-ignore cast variance */ |
@@ -1,4 +0,5 @@ | ||
import type { array, ErrorType, inferred, intersectUnion, Key, listable, merge, optionalKeyOf, show } from "@ark/util"; | ||
import type { arkGet, arkKeyOf, toArkKey } from "../keys.ts"; | ||
import type { type } from "../keywords/ark.ts"; | ||
import type { BaseMappedPropInner, OptionalMappedPropInner, Prop } from "@ark/schema"; | ||
import type { anyOrNever, arkGet, arkIndexableOf, arkKeyOf, array, ErrorType, inferred, intersectUnion, Json, Key, listable, merge, optionalKeyOf, show, toArkKey } from "@ark/util"; | ||
import type { Default, InferredDefault, InferredOptional } from "../keywords/inference.ts"; | ||
import type { type } from "../keywords/keywords.ts"; | ||
import type { ArrayType } from "./array.ts"; | ||
@@ -15,5 +16,5 @@ import type { instantiateType } from "./instantiate.ts"; | ||
keyof(): instantiateType<arkKeyOf<t>, $>; | ||
get<k1 extends arkKeyOf<t>, r = instantiateType<arkGet<t, k1>, $>>(k1: k1 | type.cast<k1>): r; | ||
get<k1 extends arkKeyOf<t>, k2 extends arkKeyOf<arkGet<t, k1>>, r = instantiateType<arkGet<arkGet<t, k1>, k2>, $>>(k1: k1 | type.cast<k1>, k2: k2 | type.cast<k2>): r; | ||
get<k1 extends arkKeyOf<t>, k2 extends arkKeyOf<arkGet<t, k1>>, k3 extends arkKeyOf<arkGet<arkGet<t, k1>, k2>>, r = instantiateType<arkGet<arkGet<arkGet<t, k1>, k2>, k3>, $>>(k1: k1 | type.cast<k1>, k2: k2 | type.cast<k2>, k3: k3 | type.cast<k3>): r; | ||
get<const k1 extends arkIndexableOf<t>>(k1: k1 | type.cast<k1>): instantiateType<arkGet<t, k1>, $> extends infer r ? r : never; | ||
get<const k1 extends arkIndexableOf<t>, const k2 extends arkIndexableOf<arkGet<t, k1>>>(k1: k1 | type.cast<k1>, k2: k2 | type.cast<k2>): instantiateType<arkGet<arkGet<t, k1>, k2>, $> extends infer r ? r : never; | ||
get<const k1 extends arkIndexableOf<t>, const k2 extends arkIndexableOf<arkGet<t, k1>>, const k3 extends arkIndexableOf<arkGet<arkGet<t, k1>, k2>>>(k1: k1 | type.cast<k1>, k2: k2 | type.cast<k2>, k3: k3 | type.cast<k3>): instantiateType<arkGet<arkGet<arkGet<t, k1>, k2>, k3>, $> extends infer r ? r : never; | ||
pick<const key extends arkKeyOf<t> = never>(...keys: (key | type.cast<key>)[]): Type<{ | ||
@@ -25,3 +26,3 @@ [k in keyof t as Extract<toArkKey<t, k>, key>]: t[k]; | ||
}, $>; | ||
merge<const def, r = type.infer<def, $>>(def: type.validate<def, $> & (r extends object ? unknown : ErrorType<"Merged type must be an object", [actual: r]>)): Type<merge<t, r & object>, $>; | ||
merge<const def, r = type.infer<def, $>>(def: type.validate<def, $> & (r extends object ? unknown : ErrorType<"Merged type must be an object", [actual: r]>)): Type<merge<t, NoInfer<r & object>>, $>; | ||
required(): Type<{ | ||
@@ -33,28 +34,52 @@ [k in keyof t]-?: t[k]; | ||
}, $>; | ||
map<transformed extends listable<MappedTypeEntry<Key, v>>, v = unknown>(flatMapEntry: (entry: typeEntryOf<t, $>) => transformed): Type<constructMapped<t, transformed>, $>; | ||
map<transformed extends listable<MappedTypeProp>>(flatMapEntry: (entry: typePropOf<t, $>) => transformed): Type<constructMapped<t, transformed>, $>; | ||
props: array<typePropOf<t, $>>; | ||
} | ||
export type MappedTypeEntry<k extends Key = Key, v = unknown> = readonly [ | ||
key: k, | ||
value: type.cast<v>, | ||
kind?: "required" | "optional" | ||
]; | ||
type TypeEntries = array<MappedTypeEntry>; | ||
type typeEntryOf<t, $> = { | ||
[k in keyof t]-?: readonly [ | ||
k, | ||
instantiateType<t[k] & ({} | null), $>, | ||
k extends optionalKeyOf<t> ? "optional" : "required" | ||
]; | ||
}[keyof t] & unknown; | ||
type constructMapped<t, transformed extends listable<MappedTypeEntry>> = show<intersectUnion<fromTypeEntries<t, transformed extends TypeEntries ? transformed : [transformed]>>>; | ||
type fromTypeEntries<t, entries extends TypeEntries> = show<{ | ||
[entry in entries[number] as Extract<applyHomomorphicOptionality<t, entry>, readonly [unknown, unknown, "required"]>[0]]: entry[1][inferred]; | ||
type typePropOf<o, $> = { | ||
[k in keyof o]-?: typeProp<o, k, $>; | ||
}[keyof o] & unknown; | ||
type typeProp<o, k extends keyof o, $, t = o[k] & ({} | null)> = t extends InferredDefault<infer v, infer defaultValue> ? DefaultedTypeProp<k & Key, v, defaultValue, $> : BaseTypeProp<k extends optionalKeyOf<o> ? "optional" : t extends InferredOptional ? [ | ||
t | ||
] extends [anyOrNever] ? "required" : "optional" : "required", k & Key, t, $>; | ||
export interface BaseTypeProp<kind extends Prop.Kind = Prop.Kind, k extends Key = Key, | ||
/** @ts-ignore cast variance */ | ||
out v = unknown, $ = {}> { | ||
kind: kind; | ||
key: k; | ||
value: instantiateType<v, $>; | ||
meta: ArkEnv.meta; | ||
toJSON: () => Json; | ||
} | ||
export interface DefaultedTypeProp<k extends Key = Key, v = unknown, defaultValue = v, $ = {}> extends BaseTypeProp<"optional", k, v, $> { | ||
default: defaultValue; | ||
} | ||
type MappedTypeProp<k extends Key = Key, v = unknown> = BaseMappedTypeProp<k, v> | OptionalMappedTypeProp<k, v>; | ||
type BaseMappedTypeProp<k extends Key, v> = merge<BaseMappedPropInner, { | ||
key: k; | ||
value: type.cast<v>; | ||
}>; | ||
type OptionalMappedTypeProp<k extends Key, v> = merge<OptionalMappedPropInner, { | ||
key: k; | ||
value: type.cast<v>; | ||
default?: v; | ||
}>; | ||
type constructMapped<t, transformed extends listable<MappedTypeProp>> = show<intersectUnion<fromTypeProps<t, transformed extends array ? transformed : [transformed]>>>; | ||
type fromTypeProps<t, props extends array<MappedTypeProp>> = show<{ | ||
[prop in props[number] as Extract<applyHomomorphicOptionality<t, prop>, { | ||
kind: "required"; | ||
}>["key"]]: prop["value"][inferred]; | ||
} & { | ||
[entry in entries[number] as Extract<applyHomomorphicOptionality<t, entry>, readonly [unknown, unknown, "optional"]>[0]]?: entry[1][inferred]; | ||
[prop in props[number] as Extract<applyHomomorphicOptionality<t, prop>, { | ||
kind: "optional"; | ||
default?: never; | ||
}>["key"]]?: prop["value"][inferred]; | ||
} & { | ||
[prop in props[number] as Extract<applyHomomorphicOptionality<t, prop>, { | ||
kind: "optional"; | ||
default: unknown; | ||
}>["key"]]: (In?: prop["value"][inferred]) => Default<prop["default" & keyof prop]>; | ||
}>; | ||
type applyHomomorphicOptionality<t, entry extends MappedTypeEntry> = readonly [ | ||
entry[0], | ||
entry[1], | ||
entry[2] extends string ? entry[2] : entry[0] extends optionalKeyOf<t> ? "optional" : "required" | ||
]; | ||
type applyHomomorphicOptionality<t, prop extends MappedTypeProp> = prop["kind"] extends string ? prop : prop & { | ||
kind: prop["key"] extends optionalKeyOf<t> ? "optional" : "required"; | ||
}; | ||
export type { Type as ObjectType }; |
import type { ExactLength, ExclusiveNumericRangeSchema, exclusivizeRangeSchema, InclusiveNumericRangeSchema, Pattern } from "@ark/schema"; | ||
import type { applyConstraintSchema } from "../keywords/ast.ts"; | ||
import type { applyConstraintSchema } from "../keywords/inference.ts"; | ||
import type { ValidatorType } from "./validator.ts"; | ||
@@ -4,0 +4,0 @@ /** @ts-ignore cast variance */ |
import type { Predicate, PredicateCast } from "@ark/schema"; | ||
import type { applyConstraintSchema } from "../keywords/ast.ts"; | ||
import type { applyConstraintSchema } from "../keywords/inference.ts"; | ||
import type { BaseType } from "./base.ts"; | ||
@@ -4,0 +4,0 @@ import type { instantiateType } from "./instantiate.ts"; |
import { type BaseParseContext, type BaseRoot } from "@ark/schema"; | ||
import { type ErrorMessage, type Fn, type Primitive, type anyOrNever, type array, type defined, type equals, type ifEmptyObjectLiteral, type objectKindOrDomainOf, type optionalKeyOf, type requiredKeyOf, type show } from "@ark/util"; | ||
import type { type } from "../keywords/ark.ts"; | ||
import type { type } from "../keywords/keywords.ts"; | ||
import type { string } from "../keywords/string/string.ts"; | ||
import type { validateString } from "./ast/validate.ts"; | ||
import { type inferObjectLiteral, type validateObjectLiteral } from "./objectLiteral.ts"; | ||
import type { validateString } from "./semantic/validate.ts"; | ||
import type { BaseCompletions, inferString } from "./string/string.ts"; | ||
import type { BaseCompletions, inferString } from "./string.ts"; | ||
import { type TupleExpression, type inferTuple, type validateTuple } from "./tuple.ts"; | ||
@@ -9,0 +9,0 @@ export declare const parseObject: (def: object, ctx: BaseParseContext) => BaseRoot; |
import { type BaseParseContext, type BaseRoot, type Index, type Optional, type Required, type UndeclaredKeyBehavior, type writeInvalidPropertyKeyMessage } from "@ark/schema"; | ||
import { type anyOrNever, type Dict, type ErrorMessage, type ErrorType, type EscapeToken, type Key, type listable, type merge, type show } from "@ark/util"; | ||
import type { constrain } from "../keywords/ast.ts"; | ||
import type { constrain } from "../keywords/inference.ts"; | ||
import type { astToString } from "./ast/utils.ts"; | ||
import type { validateString } from "./ast/validate.ts"; | ||
import type { inferDefinition, validateDefinition } from "./definition.ts"; | ||
import type { astToString } from "./semantic/utils.ts"; | ||
import type { validateString } from "./semantic/validate.ts"; | ||
export declare const parseObjectLiteral: (def: Dict, ctx: BaseParseContext) => BaseRoot; | ||
@@ -8,0 +8,0 @@ export declare const writeInvalidUndeclaredBehaviorMessage: (actual: unknown) => string; |
import { type BaseParseContext, type BaseRoot, type MetaSchema, type Morph, type Predicate } from "@ark/schema"; | ||
import { type anyOrNever, type array, type BuiltinObjectKind, type conform, type Constructor, type Domain, type ErrorMessage, type show } from "@ark/util"; | ||
import type { inferIntersection } from "../intersect.ts"; | ||
import type { type } from "../keywords/ark.ts"; | ||
import type { applyConstraint, Default, distill, inferMorphOut, inferPredicate, Optional, OptionalAst, Out } from "../keywords/ast.ts"; | ||
import type { applyConstraint, Default, distill, inferIntersection, inferMorphOut, inferPredicate, InferredOptional, Optional, Out } from "../keywords/inference.ts"; | ||
import type { type } from "../keywords/keywords.ts"; | ||
import type { InfixOperator, PostfixExpression } from "./ast/infer.ts"; | ||
import type { inferDefinition, validateDefinition } from "./definition.ts"; | ||
import type { InfixOperator, PostfixExpression } from "./semantic/infer.ts"; | ||
import { writeMissingRightOperandMessage } from "./string/shift/operand/unenclosed.ts"; | ||
import type { BaseCompletions } from "./string/string.ts"; | ||
import { writeMissingRightOperandMessage } from "./shift/operand/unenclosed.ts"; | ||
import type { BaseCompletions } from "./string.ts"; | ||
export declare const parseTuple: (def: array, ctx: BaseParseContext) => BaseRoot; | ||
@@ -49,3 +48,3 @@ export declare const parseTupleLiteral: (def: array, ctx: BaseParseContext) => BaseRoot; | ||
spread: true; | ||
}> : [t] extends [OptionalAst<infer base>] ? PreparsedElement.from<{ | ||
}> : [t] extends [InferredOptional<infer base>] ? PreparsedElement.from<{ | ||
head: head; | ||
@@ -70,3 +69,3 @@ tail: tail; | ||
spread: false; | ||
}> : [t] extends [OptionalAst<infer base>] ? PreparsedElement.from<{ | ||
}> : [t] extends [InferredOptional<infer base>] ? PreparsedElement.from<{ | ||
head: head; | ||
@@ -73,0 +72,0 @@ tail: tail; |
import { $ark, Disjoint, intersectNodesRoot, makeRootAndArrayPropertiesMutable } from "@ark/schema"; | ||
import { append, isEmptyObject, objectKindOrDomainOf, throwParseError } from "@ark/util"; | ||
import { writeMissingRightOperandMessage } from "./string/shift/operand/unenclosed.js"; | ||
import { writeMissingRightOperandMessage } from "./shift/operand/unenclosed.js"; | ||
export const parseTuple = (def, ctx) => maybeParseTupleExpression(def, ctx) ?? parseTupleLiteral(def, ctx); | ||
@@ -5,0 +5,0 @@ export const parseTupleLiteral = (def, ctx) => { |
@@ -5,6 +5,6 @@ import { BaseScope, type AliasDefEntry, type ArkScopeConfig, type BaseNode, type BaseParseContext, type BaseParseContextInput, type BaseParseOptions, type BaseRoot, type GenericAst, type GenericParamAst, type GenericParamDef, type NodeKind, type NodeSchema, type PreparsedNodeResolution, type PrivateDeclaration, type RootKind, type RootSchema, type arkKind, type exportedNameOf, type nodeOfKind, type reducibleKindOf, type toInternalScope, type writeDuplicateAliasError } from "@ark/schema"; | ||
import { type GenericDeclaration, type GenericParser, type ParameterString, type baseGenericConstraints, type parseGenericParams, type parseValidGenericParams } from "./generic.ts"; | ||
import type { Ark, type } from "./keywords/ark.ts"; | ||
import type { Ark, type } from "./keywords/keywords.ts"; | ||
import type { BoundModule, Module, Submodule, instantiateExport } from "./module.ts"; | ||
import type { DefAst, InferredAst } from "./parser/ast/infer.ts"; | ||
import { type inferDefinition, type validateDefinition } from "./parser/definition.ts"; | ||
import type { DefAst, InferredAst } from "./parser/semantic/infer.ts"; | ||
import { InternalTypeParser, type DeclarationParser, type DefinitionParser, type EnumeratedTypeParser, type SchemaParser, type TypeParser, type UnitTypeParser } from "./type.ts"; | ||
@@ -11,0 +11,0 @@ export type ScopeParser = <const def>(def: scope.validate<def>, config?: ArkScopeConfig) => Scope<scope.infer<def>>; |
@@ -5,6 +5,6 @@ import { $ark, BaseScope, hasArkKind, parseGeneric } from "@ark/schema"; | ||
import { parseObject, writeBadDefinitionTypeMessage } from "./parser/definition.js"; | ||
import { DynamicState } from "./parser/string/reduce/dynamic.js"; | ||
import { writeUnexpectedCharacterMessage } from "./parser/string/shift/operator/operator.js"; | ||
import { Scanner } from "./parser/string/shift/scanner.js"; | ||
import { fullStringParse } from "./parser/string/string.js"; | ||
import { DynamicState } from "./parser/reduce/dynamic.js"; | ||
import { writeUnexpectedCharacterMessage } from "./parser/shift/operator/operator.js"; | ||
import { Scanner } from "./parser/shift/scanner.js"; | ||
import { fullStringParse } from "./parser/string.js"; | ||
import { InternalTypeParser } from "./type.js"; | ||
@@ -11,0 +11,0 @@ export const $arkTypeRegistry = $ark; |
import { ArkErrors, BaseRoot, type BaseParseOptions, type MetaSchema, type Morph, type Predicate, type RootSchema } from "@ark/schema"; | ||
import { Callable, Hkt, type Constructor, type array, type conform } from "@ark/util"; | ||
import type { Generic, GenericParser, ParameterString, baseGenericConstraints, parseValidGenericParams, validateParameterString } from "./generic.ts"; | ||
import type { Ark, ark, type } from "./keywords/ark.ts"; | ||
import type { distill } from "./keywords/ast.ts"; | ||
import type { distill } from "./keywords/inference.ts"; | ||
import type { Ark, keywords, type } from "./keywords/keywords.ts"; | ||
import type { BaseType } from "./methods/base.ts"; | ||
@@ -17,7 +17,7 @@ import type { instantiateType } from "./methods/instantiate.ts"; | ||
<const zero, const one, const rest extends array, r = Type<type.infer<[zero, one, ...rest], $>, $>>(_0: zero extends IndexZeroOperator ? zero : type.validate<zero, $>, _1: zero extends "keyof" ? type.validate<one, $> : zero extends "instanceof" ? conform<one, Constructor> : zero extends "===" ? conform<one, unknown> : conform<one, IndexOneOperator>, ..._2: zero extends "===" ? rest : zero extends "instanceof" ? conform<rest, readonly Constructor[]> : one extends TupleInfixOperator ? one extends ":" ? [Predicate<distill.In<type.infer<zero, $>>>] : one extends "=>" ? [Morph<distill.Out<type.infer<zero, $>>, unknown>] : one extends "@" ? [MetaSchema] : [type.validate<rest[0], $>] : []): r; | ||
errors: typeof ArkErrors; | ||
hkt: typeof Hkt; | ||
keywords: typeof keywords; | ||
$: Scope<$>; | ||
raw(def: unknown): BaseType<any, $>; | ||
errors: typeof ArkErrors; | ||
hkt: typeof Hkt; | ||
ark: typeof ark; | ||
module: ModuleParser; | ||
@@ -24,0 +24,0 @@ scope: ScopeParser; |
@@ -16,3 +16,3 @@ import { ArkErrors, BaseRoot, GenericRoot } from "@ark/schema"; | ||
// this won't be defined during bootstrapping, but externally always will be | ||
ark: $.ambient, | ||
keywords: $.ambient, | ||
unit: $.unit, | ||
@@ -19,0 +19,0 @@ enumerated: $.enumerated |
{ | ||
"name": "arktype", | ||
"description": "TypeScript's 1:1 validator, optimized from editor to runtime", | ||
"version": "2.0.0-rc.8", | ||
"version": "2.0.0-rc.9", | ||
"license": "MIT", | ||
@@ -37,4 +37,4 @@ "author": { | ||
"dependencies": { | ||
"@ark/schema": "0.10.0", | ||
"@ark/util": "0.10.0" | ||
"@ark/schema": "0.11.0", | ||
"@ark/util": "0.11.0" | ||
}, | ||
@@ -41,0 +41,0 @@ "publishConfig": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
228143
146
4457
+ Added@ark/schema@0.11.0(transitive)
+ Added@ark/util@0.11.0(transitive)
- Removed@ark/schema@0.10.0(transitive)
- Removed@ark/util@0.10.0(transitive)
Updated@ark/schema@0.11.0
Updated@ark/util@0.11.0