Socket
Socket
Sign inDemoInstall

arktype

Package Overview
Dependencies
Maintainers
1
Versions
100
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

arktype - npm Package Compare versions

Comparing version 2.0.0-rc.4 to 2.0.0-rc.5

out/keywords/constructors/Date.d.ts

2

out/generic.js

@@ -35,5 +35,5 @@ import { GenericRoot } from "@ark/schema";

}
const s = parseUntilFinalizer(new DynamicState(scanner, ctx, false));
const s = parseUntilFinalizer(new DynamicState(scanner, ctx));
result.push([name, s.root]);
return parseName(scanner, result, ctx);
};
export { ArkError, ArkErrors, type ArkConfig, type ArkScopeConfig, type JsonSchema } from "@ark/schema";
export { Hkt } from "@ark/util";
export { Hkt, inferred } from "@ark/util";
export { Generic } from "./generic.ts";

@@ -4,0 +4,0 @@ export { ambient, ark, declare, define, generic, type, type Ark } from "./keywords/ark.ts";

export { ArkError, ArkErrors } from "@ark/schema";
export { Hkt } from "@ark/util";
export { Hkt, inferred } from "@ark/util";
export { Generic } from "./generic.js";

@@ -4,0 +4,0 @@ export { ambient, ark, declare, define, generic, type } from "./keywords/ark.js";

@@ -5,4 +5,6 @@ import type { ArkErrors, arkKind } from "@ark/schema";

import type { BoundModule, Module } from "../module.ts";
import type { inferDefinition } from "../parser/definition.ts";
import { type Scope } from "../scope.ts";
import type { DeclarationParser, DefinitionParser, TypeParser } from "../type.ts";
import type { DeclarationParser, DefinitionParser, Type, TypeParser, validateTypeRoot } from "../type.ts";
import type { distill } from "./ast.ts";
import { arkBuiltins } from "./builtins.ts";

@@ -37,5 +39,19 @@ import { arkPrototypes } from "./constructors/constructors.ts";

type errors = ArkErrors;
type infer<def, $ = {}, args = {}> = inferDefinition<def, $, args>;
namespace infer {
type In<def, $ = {}, args = {}> = distill.In<inferDefinition<def, $, args>>;
type Out<def, $ = {}, args = {}> = distill.Out<inferDefinition<def, $, args>>;
namespace brandable {
type In<def, $ = {}, args = {}> = distill.brandable.In<inferDefinition<def, $, args>>;
type Out<def, $ = {}, args = {}> = distill.brandable.Out<inferDefinition<def, $, args>>;
}
namespace introspectable {
type Out<def, $ = {}, args = {}> = distill.introspectable.Out<inferDefinition<def, $, args>>;
}
}
type validate<def, $ = {}> = validateTypeRoot<def, $>;
}
export type type<t = unknown, $ = {}> = Type<t, $>;
export declare const generic: GenericParser<{}>;
export declare const define: DefinitionParser<{}>;
export declare const declare: DeclarationParser<{}>;

@@ -7,4 +7,5 @@ import type { ArkError, ArkErrors, Constraint, constraintKindOf, Morph, NodeSchema } from "@ark/schema";

import type { arkPrototypes } from "./constructors/constructors.ts";
import type { number } from "./number/number.ts";
import type { string } from "./string/string.ts";
import type { Date } from "./constructors/Date.ts";
import type { DivisibleBy, number } from "./number/number.ts";
import type { Matching, string } from "./string/string.ts";
export type { arkPrototypes as object } from "./constructors/constructors.ts";

@@ -25,32 +26,11 @@ export type { number } from "./number/number.ts";

export type normalizeLimit<limit> = limit extends DateLiteral<infer source> ? source : limit extends number | string ? limit : never;
type constraint<rule> = {
export type constraint<rule> = {
[k in rule & PropertyKey]: 1;
};
export type AtLeast<rule> = {
atLeast: constraint<rule>;
};
export type AtMost<rule> = {
atMost: constraint<rule>;
};
export type MoreThan<rule> = {
moreThan: constraint<rule>;
};
export type LessThan<rule> = {
lessThan: constraint<rule>;
};
export type Literal<rule> = {
literal: constraint<rule>;
};
export type DivisibleBy<rule> = {
divisibleBy: constraint<rule>;
};
export type Length<rule> = {
length: constraint<rule>;
};
export type Matching<rule> = {
matching: constraint<rule>;
};
export type Narrowed = {
predicate: {
[k in "?"]: 1;
"?": 1;
};

@@ -78,31 +58,4 @@ };

};
export type AtOrAfter<rule> = {
atOrAfter: constraint<rule>;
};
export type AtOrBefore<rule> = {
atOrBefore: constraint<rule>;
};
export type After<rule> = {
after: constraint<rule>;
};
export type Before<rule> = {
before: constraint<rule>;
};
export declare namespace Date {
type atOrAfter<rule> = constrain<Date, AtOrAfter<rule>>;
type after<rule> = constrain<Date, After<rule>>;
type atOrBefore<rule> = constrain<Date, AtOrBefore<rule>>;
type before<rule> = constrain<Date, Before<rule>>;
type narrowed = constrain<Date, Narrowed>;
type branded<rule> = constrain<Date, Branded<rule>>;
type literal<rule> = constrain<Date, Literal<rule>>;
type is<constraints extends Constraints> = constrain<Date, constraints>;
type parseConstraint<kind extends Constraint.PrimitiveKind, schema extends NodeSchema<kind>> = normalizePrimitiveConstraintRoot<schema> extends infer rule ? kind extends "after" ? schema extends {
exclusive: true;
} ? after<normalizeLimit<rule>> : atOrAfter<normalizeLimit<rule>> : kind extends "before" ? schema extends {
exclusive: true;
} ? before<normalizeLimit<rule>> : atOrBefore<normalizeLimit<rule>> : narrowed : never;
}
export type applyConstraint<t, kind extends Constraint.PrimitiveKind, schema extends NodeSchema<kind>> = t extends MorphAst<infer i, infer o> ? (In: leftIfEqual<i, _applyConstraint<i, kind, schema>>) => o : leftIfEqual<t, _applyConstraint<t, kind, schema>>;
type _applyConstraint<t, kind extends Constraint.PrimitiveKind, schema extends NodeSchema<kind>> = schemaToConstraint<kind, schema> extends infer constraint ? parseConstraints<t> extends ([
export type applyConstraintSchema<t, kind extends Constraint.PrimitiveKind, schema extends NodeSchema<kind>> = t extends MorphAst<infer i, infer o> ? (In: leftIfEqual<i, applyConstraint<i, schemaToConstraint<kind, schema>>>) => o : leftIfEqual<t, applyConstraint<t, schemaToConstraint<kind, schema>>>;
export type applyConstraint<t, constraint> = parseConstraints<t> extends ([
infer base,

@@ -113,3 +66,3 @@ infer constraints extends Constraints

base
] extends [base, number] ? number.is<constraint & constraints> : [string, base] extends [base, string] ? string.is<constraint & constraints> : [Date, base] extends [base, Date] ? Date.is<constraint & constraints> : constrain<base, constraints & constraint> : [number, t] extends [t, number] ? number.parseConstraint<kind, schema> : [string, t] extends [t, string] ? string.parseConstraint<kind, schema> : [Date, t] extends [t, Date] ? Date.parseConstraint<kind, schema> : constrain<t, conform<constraint, Constraints>> : never;
] extends [base, number] ? number.is<constraint & constraints> : [string, base] extends [base, string] ? string.is<constraint & constraints> : [Date, base] extends [base, Date] ? Date.is<constraint & constraints> : constrain<base, constraints & constraint> : [number, t] extends [t, number] ? number.withConstraint<constraint> : [string, t] extends [t, string] ? string.withConstraint<constraint> : [Date, t] extends [t, Date] ? Date.withConstraint<constraint> : constrain<t, conform<constraint, Constraints>>;
export type parseConstraints<t> = t extends constrain<infer base, infer constraints> ? equals<t, number & {

@@ -132,61 +85,97 @@ [constrained]: constraints;

export type normalizePrimitiveConstraintRoot<schema extends NodeSchema<Constraint.PrimitiveKind>> = "rule" extends keyof schema ? conform<schema["rule"], PropertyKey> : conform<schema, PropertyKey>;
export type schemaToConstraint<kind extends Constraint.PrimitiveKind, schema extends NodeSchema<kind>> = normalizePrimitiveConstraintRoot<schema> extends infer rule ? kind extends "pattern" ? Matching<rule> : kind extends "divisor" ? DivisibleBy<rule> : kind extends "exactLength" ? Length<rule> : kind extends "min" ? schema extends {
type minLengthSchemaToConstraint<schema, rule> = schema extends {
exclusive: true;
} ? MoreThan<rule> : AtLeast<rule> : kind extends "max" ? schema extends {
} ? MoreThanLength<rule> : AtLeastLength<rule>;
type maxLengthSchemaToConstraint<schema, rule> = schema extends {
exclusive: true;
} ? LessThan<rule> : AtMost<rule> : kind extends "minLength" ? schema extends {
exclusive: true;
} ? MoreThanLength<rule> : AtLeastLength<rule> : kind extends "maxLength" ? schema extends {
exclusive: true;
} ? LessThanLength<rule> : AtMostLength<rule> : kind extends "exactLength" ? ExactlyLength<rule> : kind extends "after" ? schema extends {
exclusive: true;
} ? After<normalizeLimit<rule>> : AtOrAfter<normalizeLimit<rule>> : kind extends "before" ? schema extends {
exclusive: true;
} ? Before<normalizeLimit<rule>> : AtOrBefore<normalizeLimit<rule>> : Narrowed : never;
export type distillIn<t> = finalizeDistillation<t, _distill<t, "in", "base">>;
export type distillOut<t> = finalizeDistillation<t, _distill<t, "out", "base">>;
export type distillConstrainableIn<t> = finalizeDistillation<t, _distill<t, "in", "constrainable">>;
export type distillConstrainableOut<t> = finalizeDistillation<t, _distill<t, "out", "constrainable">>;
export type distillValidatedOut<t> = finalizeDistillation<t, _distill<t, "validatedOut", "constrainable">>;
} ? LessThanLength<rule> : AtMostLength<rule>;
export type schemaToConstraint<kind extends Constraint.PrimitiveKind, schema extends NodeSchema<kind>> = normalizePrimitiveConstraintRoot<schema> extends infer rule ? kind extends "pattern" ? Matching<rule> : kind extends "divisor" ? DivisibleBy<rule> : kind extends "min" ? number.minSchemaToConstraint<schema, rule> : kind extends "max" ? number.maxSchemaToConstraint<schema, rule> : kind extends "minLength" ? minLengthSchemaToConstraint<schema, rule> : kind extends "maxLength" ? maxLengthSchemaToConstraint<schema, rule> : kind extends "exactLength" ? ExactlyLength<rule> : kind extends "after" ? Date.afterSchemaToConstraint<schema, rule> : kind extends "before" ? Date.beforeSchemaToConstraint<schema, rule> : Narrowed : never;
export type distill<t, opts extends distill.Options = {}> = finalizeDistillation<t, _distill<t, opts>>;
export declare namespace distill {
type Endpoint = "in" | "out" | "out.introspectable";
type Options = {
endpoint?: Endpoint;
branded?: true;
};
type In<t> = distill<t, {
endpoint: "in";
}>;
type Out<t> = distill<t, {
endpoint: "out";
}>;
namespace brandable {
type In<t> = distill<t, {
endpoint: "in";
branded: true;
}>;
type Out<t> = distill<t, {
endpoint: "out";
branded: true;
}>;
namespace introspectable {
type Out<t> = distill<t, {
endpoint: "out.introspectable";
branded: true;
}>;
}
}
type unbranded<t> = distill<t>;
namespace introspectable {
type Out<t> = distill<t, {
endpoint: "out.introspectable";
}>;
}
}
type finalizeDistillation<t, distilled> = equals<t, distilled> extends true ? t : distilled;
export type includesMorphs<t> = [
_distill<t, "in", "constrainable">,
_distill<t, "out", "constrainable">
_distill<t, {
endpoint: "in";
branded: true;
}>,
_distill<t, {
endpoint: "out";
branded: true;
}>
] extends ([
_distill<t, "out", "constrainable">,
_distill<t, "in", "constrainable">
_distill<t, {
endpoint: "out";
branded: true;
}>,
_distill<t, {
endpoint: "in";
branded: true;
}>
]) ? false : true;
type IoKind = "in" | "out" | "validatedOut";
type DistilledKind = "base" | "constrainable";
type _distill<t, io extends IoKind, distilledKind extends DistilledKind> = t extends undefined ? t : [t] extends [anyOrNever] ? t : parseConstraints<t> extends ([
type _distill<t, opts extends distill.Options> = t extends undefined ? t : [t] extends [anyOrNever] ? t : parseConstraints<t> extends ([
infer base,
infer constraints extends Constraints
]) ? distilledKind extends "base" ? _distill<base, io, distilledKind> : constrain<_distill<base, io, distilledKind>, constraints> : t extends TerminallyInferredObjectKind | Primitive ? t : unknown extends t ? unknown : t extends MorphAst<infer i, infer o> ? io extends "in" ? _distill<i, io, distilledKind> : io extends "validatedOut" ? o extends To<infer validatedOut> ? _distill<validatedOut, io, distilledKind> : unknown : _distill<o[1], io, distilledKind> : t extends DefaultableAst<infer t> ? _distill<t, io, distilledKind> : t extends array ? distillArray<t, io, distilledKind, []> : t extends Function ? t : {
]) ? opts["branded"] extends true ? constrain<_distill<base, opts>, constraints> : _distill<base, opts> : t extends TerminallyInferredObjectKind | Primitive ? t : unknown extends t ? unknown : t extends MorphAst<infer i, infer o> ? opts["endpoint"] extends "in" ? _distill<i, opts> : opts["endpoint"] extends "out.introspectable" ? o extends To<infer validatedOut> ? _distill<validatedOut, opts> : unknown : opts["endpoint"] extends "out" ? _distill<o[1], opts> : _distill<o[1], opts> extends infer r ? o extends To ? (In: i) => To<r> : (In: i) => Out<r> : never : t extends DefaultedAst<infer t> ? _distill<t, opts> : t extends array ? distillArray<t, opts, []> : t extends Function ? t : {
[k in keyof t]: t[k];
} extends t ? io extends "in" ? show<{
[k in keyof t as k extends defaultableKeyOf<t> ? never : k]: _distill<t[k], io, distilledKind>;
} extends t ? opts["endpoint"] extends "in" ? show<{
[k in keyof t as k extends defaultedKeyOf<t> | metaOptionalKey<t> ? never : k]: _distill<t[k], opts>;
} & {
[k in defaultableKeyOf<t>]?: _distill<t[k], io, distilledKind>;
}> : {
[k in keyof t]: _distill<t[k], io, distilledKind>;
} : t;
export type defaultableKeyOf<t> = {
[k in keyof t]: [t[k]] extends [anyOrNever] ? never : t[k] extends DefaultableAst ? k : never;
[k in defaultedKeyOf<t> | metaOptionalKey<t>]?: _distill<t[k], opts>;
}> : show<{
[k in keyof t as k extends metaOptionalKey<t> ? never : k]: _distill<t[k], opts>;
} & {
[k in keyof t as k extends metaOptionalKey<t> ? k : never]?: _distill<t[k], opts>;
}> : t;
type defaultedKeyOf<t> = {
[k in keyof t]: [t[k]] extends [anyOrNever] ? never : t[k] extends DefaultedAst ? k : never;
}[keyof t];
type distillArray<t extends array, io extends IoKind, constraints extends DistilledKind, prefix extends array> = _distillArray<t, io, constraints, prefix> extends infer result ? t extends unknown[] ? result : Readonly<t> : never;
type _distillArray<t extends array, io extends IoKind, constraints extends DistilledKind, prefix extends array> = t extends readonly [infer head, ...infer tail] ? _distillArray<tail, io, constraints, [
...prefix,
_distill<head, io, constraints>
]> : [...prefix, ...distillPostfix<t, io, constraints>];
type distillPostfix<t extends array, io extends IoKind, constraints extends DistilledKind, postfix extends array = []> = t extends readonly [...infer init, infer last] ? distillPostfix<init, io, constraints, [
_distill<last, io, constraints>,
...postfix
]> : [...{
[i in keyof t]: _distill<t[i], io, constraints>;
type metaOptionalKey<o> = {
[k in keyof o]: o[k] extends OptionalAst ? [
o[k]
] extends [anyOrNever] ? never : k : never;
}[keyof o];
type distillArray<t extends array, opts extends distill.Options, prefix extends array> = _distillArray<t, opts, prefix> extends infer result ? t extends unknown[] ? result : Readonly<t> : never;
type _distillArray<t extends array, opts extends distill.Options, prefix extends array> = t extends readonly [infer head, ...infer tail] ? _distillArray<tail, opts, [...prefix, _distill<head, opts>]> : [...prefix, ...distillPostfix<t, opts>];
type distillPostfix<t extends array, opts extends distill.Options, postfix extends array = []> = t extends readonly [...infer init, infer last] ? distillPostfix<init, opts, [_distill<last, opts>, ...postfix]> : [...{
[i in keyof t]: _distill<t[i], opts>;
}, ...postfix];
/** Objects we don't want to expand during inference like Date or Promise */
type TerminallyInferredObjectKind = arkPrototypes.instanceOfExcluding<"Array" | "Function"> | ArkEnv.prototypes;
export type inferPredicate<t, predicate> = predicate extends (data: any, ...args: any[]) => data is infer narrowed ? t extends constrain<unknown, infer constraints> ? applyConstraint<constrain<narrowed, constraints>, "predicate", any> : applyConstraint<narrowed, "predicate", any> : applyConstraint<t, "predicate", any>;
export type constrainWithPredicate<t> = t extends constrain<unknown, infer constraints> ? applyConstraint<constrain<t, constraints>, "predicate", any> : applyConstraint<t, "predicate", any>;
export type inferPipes<t, pipes extends Morph[]> = pipes extends [infer head extends Morph, ...infer tail extends Morph[]] ? inferPipes<pipes[0] extends type.cast<infer tPipe> ? inferPipe<t, tPipe> : inferMorphOut<head> extends infer out ? (In: distillConstrainableIn<t>) => Out<out> : never, tail> : t;
export type inferPredicate<t, predicate> = predicate extends (data: any, ...args: any[]) => data is infer narrowed ? t extends constrain<unknown, infer constraints> ? applyConstraintSchema<constrain<narrowed, constraints>, "predicate", any> : applyConstraintSchema<narrowed, "predicate", any> : applyConstraintSchema<t, "predicate", any>;
export type constrainWithPredicate<t> = t extends constrain<unknown, infer constraints> ? applyConstraintSchema<constrain<t, constraints>, "predicate", any> : applyConstraintSchema<t, "predicate", any>;
export type inferPipes<t, pipes extends Morph[]> = pipes extends [infer head extends Morph, ...infer tail extends Morph[]] ? inferPipes<pipes[0] extends type.cast<infer tPipe> ? inferPipe<t, tPipe> : inferMorphOut<head> extends infer out ? (In: distill.brandable.In<t>) => Out<out> : never, tail> : t;
export type inferMorphOut<morph extends Morph> = Exclude<ReturnType<morph>, ArkError | ArkErrors>;

@@ -196,4 +185,8 @@ export type Out<o = any> = ["=>", o, boolean];

export type MorphAst<i = any, o extends Out = Out> = (In: i) => o;
export type Optional = {
optional?: {};
};
export type OptionalAst<t = unknown> = constrain<t, Optional>;
export type Default<v = any> = ["=", v];
export type DefaultableAst<t = any, v = any> = (In?: t) => Default<v>;
export type DefaultedAst<t = any, v = any> = (In?: t) => Default<v>;
export type termOrType<t> = t | Type<t, any>;

@@ -13,3 +13,3 @@ import { Hkt, liftArray, type Digit } from "@ark/util";

type $ = {
$root: unknown[];
root: unknown[];
readonly: readonly unknown[];

@@ -16,0 +16,0 @@ index: NonNegativeIntegerString;

@@ -15,6 +15,6 @@ import { genericNode, intrinsic, rootNode } from "@ark/schema";

export const arkArray = submodule({
$root: intrinsic.Array,
readonly: "$root",
root: intrinsic.Array,
readonly: "root",
index: intrinsic.nonNegativeIntegerString,
liftFrom
});

@@ -10,3 +10,3 @@ import type { Module, Submodule } from "../../module.ts";

type $ = {
$root: FormData;
root: FormData;
value: FormDataValue;

@@ -13,0 +13,0 @@ parse: (In: FormData) => To<ParsedFormData>;

@@ -15,3 +15,3 @@ import { rootNode } from "@ark/schema";

export const arkFormData = submodule({
$root: ["instanceof", FormData],
root: ["instanceof", FormData],
value,

@@ -18,0 +18,0 @@ parsed,

@@ -1,3 +0,2 @@

import type { AtLeast, AtMost, DivisibleBy } from "../ast.ts";
import type { number } from "./number.ts";
import type { AtLeast, AtMost, DivisibleBy, number } from "./number.ts";
/**

@@ -4,0 +3,0 @@ * As per the ECMA-262 specification:

@@ -1,7 +0,21 @@

import { type Constraint, type NodeSchema } from "@ark/schema";
import type { Module, Submodule } from "../../module.ts";
import type { AtLeast, AtMost, Branded, constrain, Constraints, DivisibleBy, LessThan, MoreThan, Narrowed, normalizePrimitiveConstraintRoot } from "../ast.ts";
import type { Branded, constrain, constraint, Constraints, Narrowed, Optional } from "../ast.ts";
import { epoch } from "./epoch.ts";
import { integer } from "./integer.ts";
export declare const number: number.module;
export type AtLeast<rule> = {
atLeast: constraint<rule>;
};
export type AtMost<rule> = {
atMost: constraint<rule>;
};
export type MoreThan<rule> = {
moreThan: constraint<rule>;
};
export type LessThan<rule> = {
lessThan: constraint<rule>;
};
export type DivisibleBy<rule> = {
divisibleBy: constraint<rule>;
};
export declare namespace number {

@@ -14,13 +28,16 @@ type atLeast<rule> = constrain<number, AtLeast<rule>>;

type narrowed = constrain<number, Narrowed>;
type optional = constrain<number, Optional>;
type branded<rule> = constrain<number, Branded<rule>>;
type is<constraints extends Constraints> = constrain<number, constraints>;
type parseConstraint<kind extends Constraint.PrimitiveKind, schema extends NodeSchema<kind>> = normalizePrimitiveConstraintRoot<schema> extends infer rule ? kind extends "min" ? schema extends {
type minSchemaToConstraint<schema, rule> = schema extends {
exclusive: true;
} ? moreThan<rule> : atLeast<rule> : kind extends "max" ? schema extends {
} ? MoreThan<rule> : AtLeast<rule>;
type maxSchemaToConstraint<schema, rule> = schema extends {
exclusive: true;
} ? lessThan<rule> : atMost<rule> : kind extends "divisor" ? divisibleBy<rule> : narrowed : never;
} ? LessThan<rule> : AtMost<rule>;
type withConstraint<constraint> = constraint extends MoreThan<infer rule> ? moreThan<rule> : constraint extends AtLeast<infer rule> ? atLeast<rule> : constraint extends AtMost<infer rule> ? atMost<rule> : constraint extends LessThan<infer rule> ? lessThan<rule> : constraint extends DivisibleBy<infer rule> ? divisibleBy<rule> : constraint extends Optional ? optional : constraint extends Narrowed ? narrowed : never;
type module = Module<submodule>;
type submodule = Submodule<$>;
type $ = {
$root: number;
root: number;
epoch: epoch;

@@ -27,0 +44,0 @@ integer: integer;

@@ -6,5 +6,5 @@ import { intrinsic } from "@ark/schema";

export const number = submodule({
$root: intrinsic.number,
root: intrinsic.number,
integer,
epoch
});

@@ -11,3 +11,3 @@ import type { Module, Submodule } from "../../module.ts";

type $ = {
$root: (In: string) => To<string.capitalized>;
root: (In: string) => To<string.capitalized>;
preformatted: string.capitalized;

@@ -14,0 +14,0 @@ };

@@ -6,3 +6,3 @@ import { rootNode } from "@ark/schema";

export const capitalize = submodule({
$root: rootNode({
root: rootNode({
in: "string",

@@ -9,0 +9,0 @@ morphs: (s) => s.charAt(0).toUpperCase() + s.slice(1),

@@ -36,3 +36,3 @@ import type { Module, Submodule } from "../../module.ts";

type $ = {
$root: string.date;
root: string.date;
parse: (In: string.date) => To<Date>;

@@ -48,3 +48,3 @@ iso: iso.submodule;

type $ = {
$root: string.date.iso;
root: string.date.iso;
parse: (In: string.date.iso) => To<Date>;

@@ -56,3 +56,3 @@ };

type $ = {
$root: string.date.epoch;
root: string.date.epoch;
parse: (In: string.date.epoch) => To<Date>;

@@ -59,0 +59,0 @@ };

@@ -50,3 +50,3 @@ import { ArkErrors, intrinsic, rootNode } from "@ark/schema";

}).assertHasKind("intersection");
const epoch$root = integer.$root.internal
const epochroot = integer.root.internal
.narrow((s, ctx) => {

@@ -68,5 +68,5 @@ // we know this is safe since it has already

const epoch = submodule({
$root: epoch$root,
root: epochroot,
parse: rootNode({
in: epoch$root,
in: epochroot,
morphs: (s) => new Date(s),

@@ -76,7 +76,7 @@ declaredOut: intrinsic.Date

});
const iso$root = regexStringNode(iso8601Matcher, "an ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ) date").internal.assertHasKind("intersection");
const isoroot = regexStringNode(iso8601Matcher, "an ISO 8601 (YYYY-MM-DDTHH:mm:ss.sssZ) date").internal.assertHasKind("intersection");
const iso = submodule({
$root: iso$root,
root: isoroot,
parse: rootNode({
in: iso$root,
in: isoroot,
morphs: (s) => new Date(s),

@@ -87,3 +87,3 @@ declaredOut: intrinsic.Date

export const stringDate = submodule({
$root: parsableDate,
root: parsableDate,
parse: rootNode({

@@ -90,0 +90,0 @@ declaredIn: parsableDate,

@@ -12,3 +12,3 @@ import type { Module, Submodule } from "../../module.ts";

type $ = {
$root: string.integer;
root: string.integer;
parse: (In: string.integer) => To<number.divisibleBy<1>>;

@@ -15,0 +15,0 @@ };

@@ -5,7 +5,7 @@ import { intrinsic, rootNode } from "@ark/schema";

import { regexStringNode } from "./utils.js";
const $root = regexStringNode(wellFormedIntegerMatcher, "a well-formed integer string");
const root = regexStringNode(wellFormedIntegerMatcher, "a well-formed integer string");
export const integer = submodule({
$root,
root,
parse: rootNode({
in: $root,
in: root,
morphs: (s, ctx) => {

@@ -12,0 +12,0 @@ const parsed = Number.parseInt(s);

@@ -15,3 +15,3 @@ import type { Module, Submodule } from "../../module.ts";

type $ = {
$root: string.ip;
root: string.ip;
v4: string.ip.v4;

@@ -18,0 +18,0 @@ v6: string.ip.v6;

@@ -20,5 +20,5 @@ import { submodule } from "../utils.js";

export const ip = submodule({
$root: ["v4 | v6", "@", "an IP address"],
root: ["v4 | v6", "@", "an IP address"],
v4: regexStringNode(ipv4Matcher, "an IPv4 address"),
v6: regexStringNode(ipv6Matcher, "an IPv6 address")
});

@@ -11,3 +11,3 @@ import type { Module, Submodule } from "../../module.ts";

type $ = {
$root: string.json;
root: string.json;
parse: (In: string.json) => To<object>;

@@ -14,0 +14,0 @@ };

@@ -13,3 +13,3 @@ import { intrinsic, rootNode } from "@ark/schema";

};
const $root = rootNode({
const root = rootNode({
domain: "string",

@@ -22,3 +22,3 @@ predicate: {

export const json = submodule({
$root,
root,
parse: rootNode({

@@ -25,0 +25,0 @@ in: "string",

@@ -11,3 +11,3 @@ import type { Module, Submodule } from "../../module.ts";

type $ = {
$root: (In: string) => To<string.lowercase>;
root: (In: string) => To<string.lowercase>;
preformatted: string.lowercase;

@@ -14,0 +14,0 @@ };

@@ -6,3 +6,3 @@ import { rootNode } from "@ark/schema";

export const lower = submodule({
$root: rootNode({
root: rootNode({
in: "string",

@@ -9,0 +9,0 @@ morphs: (s) => s.toLowerCase(),

@@ -16,33 +16,33 @@ import type { Module, Submodule } from "../../module.ts";

export declare const NFC: Module<{
$root: unknown;
root: unknown;
preformatted: unknown;
}>;
export declare const NFD: Module<{
$root: unknown;
root: unknown;
preformatted: unknown;
}>;
export declare const NFKC: Module<{
$root: unknown;
root: unknown;
preformatted: unknown;
}>;
export declare const NFKD: Module<{
$root: unknown;
root: unknown;
preformatted: unknown;
}>;
export declare const normalize: Module<{
$root: unknown;
root: unknown;
NFC: Submodule<{
$root: unknown;
root: unknown;
preformatted: unknown;
}>;
NFD: Submodule<{
$root: unknown;
root: unknown;
preformatted: unknown;
}>;
NFKC: Submodule<{
$root: unknown;
root: unknown;
preformatted: unknown;
}>;
NFKD: Submodule<{
$root: unknown;
root: unknown;
preformatted: unknown;

@@ -55,3 +55,3 @@ }>;

type $ = {
$root: (In: string) => To<string.normalized.NFC>;
root: (In: string) => To<string.normalized.NFC>;
NFC: NFC.submodule;

@@ -68,3 +68,3 @@ NFD: NFD.submodule;

type $ = {
$root: (In: string) => To<string.normalized.NFC>;
root: (In: string) => To<string.normalized.NFC>;
preformatted: string.normalized.NFC;

@@ -76,3 +76,3 @@ };

type $ = {
$root: (In: string) => To<string.normalized.NFD>;
root: (In: string) => To<string.normalized.NFD>;
preformatted: string.normalized.NFD;

@@ -84,3 +84,3 @@ };

type $ = {
$root: (In: string) => To<string.normalized.NFKC>;
root: (In: string) => To<string.normalized.NFKC>;
preformatted: string.normalized.NFKC;

@@ -92,3 +92,3 @@ };

type $ = {
$root: (In: string) => To<string.normalized.NFKD>;
root: (In: string) => To<string.normalized.NFKD>;
preformatted: string.normalized.NFKD;

@@ -95,0 +95,0 @@ };

@@ -22,19 +22,19 @@ import { rootNode } from "@ark/schema";

export const NFC = submodule({
$root: normalizeNodes.NFC,
root: normalizeNodes.NFC,
preformatted: preformattedNodes.NFC
});
export const NFD = submodule({
$root: normalizeNodes.NFD,
root: normalizeNodes.NFD,
preformatted: preformattedNodes.NFD
});
export const NFKC = submodule({
$root: normalizeNodes.NFKC,
root: normalizeNodes.NFKC,
preformatted: preformattedNodes.NFKC
});
export const NFKD = submodule({
$root: normalizeNodes.NFKD,
root: normalizeNodes.NFKD,
preformatted: preformattedNodes.NFKD
});
export const normalize = submodule({
$root: "NFC",
root: "NFC",
NFC,

@@ -41,0 +41,0 @@ NFD,

@@ -11,3 +11,3 @@ import type { Module, Submodule } from "../../module.ts";

type $ = {
$root: string.numeric;
root: string.numeric;
parse: (In: string.numeric) => To<number>;

@@ -14,0 +14,0 @@ };

@@ -5,7 +5,7 @@ import { intrinsic, rootNode } from "@ark/schema";

import { regexStringNode } from "./utils.js";
const $root = regexStringNode(wellFormedNumberMatcher, "a well-formed numeric string");
const root = regexStringNode(wellFormedNumberMatcher, "a well-formed numeric string");
export const numeric = submodule({
$root,
root,
parse: rootNode({
in: $root,
in: root,
morphs: (s) => Number.parseFloat(s),

@@ -12,0 +12,0 @@ declaredOut: intrinsic.number

@@ -1,5 +0,4 @@

import { type Constraint, type NodeSchema } from "@ark/schema";
import type { Module, Submodule } from "../../module.ts";
import type { type } from "../ark.ts";
import type { AtLeastLength, AtMostLength, Branded, Constraints, ExactlyLength, LessThanLength, Matching, MoreThanLength, Narrowed, constrain, normalizePrimitiveConstraintRoot } from "../ast.ts";
import type { AtLeastLength, AtMostLength, Branded, Constraints, ExactlyLength, LessThanLength, MoreThanLength, Narrowed, Optional, constrain, constraint } from "../ast.ts";
import { alpha } from "./alpha.ts";

@@ -26,22 +25,25 @@ import { alphanumeric } from "./alphanumeric.ts";

normalize: Submodule<{
$root: unknown;
root: unknown;
NFC: Submodule<{
$root: unknown;
root: unknown;
preformatted: unknown;
}>;
NFD: Submodule<{
$root: unknown;
root: unknown;
preformatted: unknown;
}>;
NFKC: Submodule<{
$root: unknown;
root: unknown;
preformatted: unknown;
}>;
NFKD: Submodule<{
$root: unknown;
root: unknown;
preformatted: unknown;
}>;
}>;
root: unknown;
date: Submodule<stringDate.submodule>;
lower: Submodule<lower.submodule>;
upper: Submodule<upper.submodule>;
json: Submodule<stringJson.submodule>;
$root: unknown;
integer: Submodule<stringInteger.submodule>;

@@ -51,3 +53,2 @@ alpha: unknown;

creditCard: unknown;
date: Submodule<stringDate.submodule>;
digits: unknown;

@@ -60,3 +61,3 @@ email: unknown;

uuid: Submodule<{
$root: string.matching<string> | "00000000-0000-0000-0000-000000000000" | "ffffffff-ffff-ffff-ffff-ffffffffffff";
root: string.matching<string> | "00000000-0000-0000-0000-000000000000" | "ffffffff-ffff-ffff-ffff-ffffffffffff";
v4: unknown;

@@ -71,6 +72,7 @@ v6: unknown;

}>;
upper: Submodule<upper.submodule>;
lower: Submodule<lower.submodule>;
capitalize: Submodule<capitalize.submodule>;
}>;
export type Matching<rule> = {
matching: constraint<rule>;
};
export declare namespace string {

@@ -84,13 +86,10 @@ type atLeastLength<rule> = constrain<string, AtLeastLength<rule>>;

type narrowed = constrain<string, Narrowed>;
type optional = constrain<string, Optional>;
type branded<rule> = constrain<string, Branded<rule>>;
type is<constraints extends Constraints> = constrain<string, constraints>;
type parseConstraint<kind extends Constraint.PrimitiveKind, schema extends NodeSchema<kind>> = normalizePrimitiveConstraintRoot<schema> extends infer rule ? kind extends "minLength" ? schema extends {
exclusive: true;
} ? moreThanLength<rule> : atLeastLength<rule> : kind extends "maxLength" ? schema extends {
exclusive: true;
} ? lessThanLength<rule> : atMostLength<rule> : kind extends "pattern" ? matching<rule & string> : kind extends "exactLength" ? exactlyLength<rule> : narrowed : never;
type withConstraint<constraint> = constraint extends ExactlyLength<infer rule> ? exactlyLength<rule> : constraint extends MoreThanLength<infer rule> ? moreThanLength<rule> : constraint extends AtLeastLength<infer rule> ? atLeastLength<rule> : constraint extends AtMostLength<infer rule> ? atMostLength<rule> : constraint extends LessThanLength<infer rule> ? lessThanLength<rule> : constraint extends Matching<infer rule> ? matching<rule> : constraint extends Optional ? optional : constraint extends Narrowed ? narrowed : never;
type module = Module<string.submodule>;
type submodule = Submodule<$>;
type $ = {
$root: string;
root: string;
alpha: alpha;

@@ -97,0 +96,0 @@ alphanumeric: alphanumeric;

@@ -22,3 +22,3 @@ import { intrinsic } from "@ark/schema";

export const string = submodule({
$root: intrinsic.string,
root: intrinsic.string,
numeric,

@@ -25,0 +25,0 @@ integer,

@@ -11,3 +11,3 @@ import type { Module, Submodule } from "../../module.ts";

type $ = {
$root: (In: string) => To<string.trimmed>;
root: (In: string) => To<string.trimmed>;
preformatted: string.trimmed;

@@ -14,0 +14,0 @@ };

@@ -8,3 +8,3 @@ import { rootNode } from "@ark/schema";

export const trim = submodule({
$root: rootNode({
root: rootNode({
in: "string",

@@ -11,0 +11,0 @@ morphs: (s) => s.trim(),

@@ -11,3 +11,3 @@ import type { Module, Submodule } from "../../module.ts";

type $ = {
$root: (In: string) => To<string.uppercase>;
root: (In: string) => To<string.uppercase>;
preformatted: string.uppercase;

@@ -14,0 +14,0 @@ };

@@ -6,3 +6,3 @@ import { rootNode } from "@ark/schema";

export const upper = submodule({
$root: rootNode({
root: rootNode({
in: "string",

@@ -9,0 +9,0 @@ morphs: (s) => s.toUpperCase(),

@@ -11,3 +11,3 @@ import type { Module, Submodule } from "../../module.ts";

type $ = {
$root: string.url;
root: string.url;
parse: (In: string.url) => To<URL>;

@@ -14,0 +14,0 @@ };

@@ -15,3 +15,3 @@ import { rootNode } from "@ark/schema";

};
const $root = rootNode({
const root = rootNode({
domain: "string",

@@ -24,5 +24,5 @@ predicate: {

export const url = submodule({
$root,
root,
parse: rootNode({
declaredIn: $root,
declaredIn: root,
in: "string",

@@ -29,0 +29,0 @@ morphs: (s, ctx) => {

import type { Module, Submodule } from "../../module.ts";
import type { Branded, constrain } from "../ast.ts";
export declare const uuid: Module<{
$root: import("./string.ts").string.matching<string> | "00000000-0000-0000-0000-000000000000" | "ffffffff-ffff-ffff-ffff-ffffffffffff";
root: import("./string.ts").string.matching<string> | "00000000-0000-0000-0000-000000000000" | "ffffffff-ffff-ffff-ffff-ffffffffffff";
v4: unknown;

@@ -31,3 +31,3 @@ v6: unknown;

type $ = {
$root: string.uuid;
root: string.uuid;
v1: string.uuid.v1;

@@ -34,0 +34,0 @@ v2: string.uuid.v2;

@@ -7,3 +7,3 @@ import { submodule } from "../utils.js";

// to the individual branches, which are too detailed
$root: ["versioned | nil | max", "@", "a UUID"],
root: ["versioned | nil | max", "@", "a UUID"],
"#nil": "'00000000-0000-0000-0000-000000000000'",

@@ -10,0 +10,0 @@ "#max": "'ffffffff-ffff-ffff-ffff-ffffffffffff'",

@@ -15,4 +15,4 @@ import { RootModule, type GenericAst, type PreparsedNodeResolution } from "@ark/schema";

} & unknown;
export type Submodule<exports extends {}> = RootModule<exports & ("$root" extends keyof exports ? {
[inferred]: exports["$root"];
export type Submodule<exports extends {}> = RootModule<exports & ("root" extends keyof exports ? {
[inferred]: exports["root"];
} : {})>;

@@ -19,0 +19,0 @@ export type instantiateExport<t, $> = [

import { type BaseRoot, type Index, type Optional, type Required, type UndeclaredKeyBehavior, type writeInvalidPropertyKeyMessage } from "@ark/schema";
import { type anyOrNever, type conform, type Dict, type ErrorMessage, type ErrorType, type EscapeToken, type Key, type listable, type merge, type show } from "@ark/util";
import type { constrain, Default } from "../keywords/ast.ts";
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 { ParseContext } from "../scope.ts";

@@ -16,5 +16,5 @@ import type { inferDefinition, validateDefinition } from "./definition.ts";

type _inferObjectLiteral<def extends object, $, args> = {
-readonly [k in keyof def as nonOptionalKeyFrom<k, $, args>]: def[k] extends (DefaultValueTuple<infer baseDef, infer defaultValue>) ? [
-readonly [k in keyof def as nonOptionalKeyFrom<k, $, args>]: [
def[k]
] extends [anyOrNever] ? def[k] : (In?: inferDefinition<baseDef, $, args>) => Default<defaultValue> : inferDefinition<def[k], $, args>;
] extends [anyOrNever] ? def[k] : inferDefinition<def[k], $, args>;
} & {

@@ -24,27 +24,4 @@ -readonly [k in keyof def as optionalKeyFrom<k>]?: inferDefinition<def[k], $, args>;

export type validateObjectLiteral<def, $, args> = {
[k in keyof def]: k extends IndexKey<infer indexDef> ? validateString<indexDef, $, args> extends ErrorMessage<infer message> ? ErrorType<message> : inferDefinition<indexDef, $, args> extends Key | constrain<Key, {}> ? validateDefinition<def[k], $, args> : ErrorType<writeInvalidPropertyKeyMessage<indexDef>> : k extends "..." ? inferDefinition<def[k], $, args> extends object ? validateDefinition<def[k], $, args> : ErrorType<writeInvalidSpreadTypeMessage<astToString<def[k]>>> : k extends "+" ? UndeclaredKeyBehavior : validateDefaultableValue<def, k, $, args>;
[k in keyof def]: k extends IndexKey<infer indexDef> ? validateString<indexDef, $, args> extends ErrorMessage<infer message> ? ErrorType<message> : inferDefinition<indexDef, $, args> extends Key | constrain<Key, {}> ? validateDefinition<def[k], $, args> : ErrorType<writeInvalidPropertyKeyMessage<indexDef>> : k extends "..." ? inferDefinition<def[k], $, args> extends object ? validateDefinition<def[k], $, args> : ErrorType<writeInvalidSpreadTypeMessage<astToString<def[k]>>> : k extends "+" ? UndeclaredKeyBehavior : validateDefinition<def[k], $, args>;
};
type validateDefaultableValue<def, k extends keyof def, $, args> = def[k] extends DefaultValueTuple ? [
def[k]
] extends [anyOrNever] ?
/** this extra [anyOrNever] check is required to ensure that nested `type` invocations
* like the following are not prematurely validated by the outer call:
*
* ```ts
* type({
* "test?": type("string").pipe(x => x === "true")
* })
* ```
*/
def[k] : validateDefaultValueTuple<def[k], k, $, args> : validateDefinition<def[k], $, args>;
type DefaultValueTuple<baseDef = unknown, defaultValue = unknown> = readonly [
baseDef,
"=",
defaultValue
];
type validateDefaultValueTuple<def extends DefaultValueTuple, k extends PropertyKey, $, args> = parseKey<k>["kind"] extends "required" ? conform<def, readonly [
validateDefinition<def[0], $, args>,
"=",
inferDefinition<def[0], $, args>
]> : ErrorMessage<invalidDefaultKeyKindMessage>;
type nonOptionalKeyFrom<k, $, args> = parseKey<k> extends PreparsedKey<"required", infer inner> ? inner : parseKey<k> extends PreparsedKey<"index", infer inner> ? inferDefinition<inner, $, args> extends infer t extends Key ? t : never : never;

@@ -72,4 +49,2 @@ type optionalKeyFrom<k> = parseKey<k> extends PreparsedKey<"optional", infer inner> ? inner : never;

export declare const parseEntry: (key: Key, value: unknown, ctx: ParseContext) => listable<ParsedEntry>;
export declare const invalidDefaultKeyKindMessage = "Only required keys may specify default values, e.g. { value: 'number = 0' }";
export type invalidDefaultKeyKindMessage = typeof invalidDefaultKeyKindMessage;
declare const parseKey: (key: Key) => PreparsedKey;

@@ -76,0 +51,0 @@ type parseKey<k> = k extends `${infer inner}?` ? inner extends `${infer baseName}${EscapeToken}` ? PreparsedKey.from<{

@@ -1,4 +0,3 @@

import { ArkErrors, normalizeIndex } from "@ark/schema";
import { append, escapeToken, isArray, printable, stringAndSymbolicEntriesOf, throwParseError } from "@ark/util";
import { writeUnassignableDefaultValueMessage } from "./semantic/default.js";
import { normalizeIndex } from "@ark/schema";
import { append, escapeToken, printable, stringAndSymbolicEntriesOf, throwParseError } from "@ark/util";
export const parseObjectLiteral = (def, ctx) => {

@@ -48,18 +47,3 @@ let spread;

return { kind: "spread", node: ctx.$.parse(value, ctx) };
const parsedValue = isArray(value) && value[1] === "=" ?
[ctx.$.parse(value[0], ctx), "=", value[2]]
: ctx.$.parse(value, ctx, true);
if (isArray(parsedValue)) {
if (parsedKey.kind !== "required")
throwParseError(invalidDefaultKeyKindMessage);
const out = parsedValue[0].traverse(parsedValue[2]);
if (out instanceof ArkErrors) {
throwParseError(writeUnassignableDefaultValueMessage(printable(parsedKey.key), out.message));
}
return ctx.$.node("optional", {
key: parsedKey.key,
value: parsedValue[0],
default: parsedValue[2]
});
}
const parsedValue = ctx.$.parse(value, ctx);
if (parsedKey.kind === "index") {

@@ -74,2 +58,17 @@ const signature = ctx.$.parse(parsedKey.key, ctx);

}
if (parsedValue.meta) {
if ("default" in parsedValue.meta) {
return ctx.$.node("optional", {
key: parsedKey.key,
value: parsedValue,
default: parsedValue.meta.default
});
}
if (parsedValue.meta.optional) {
return ctx.$.node("optional", {
key: parsedKey.key,
value: parsedValue
});
}
}
return ctx.$.node(parsedKey.kind, {

@@ -80,4 +79,2 @@ key: parsedKey.key,

};
// single quote use here is better for TypeScript's inlined error to avoid escapes
export const invalidDefaultKeyKindMessage = `Only required keys may specify default values, e.g. { value: 'number = 0' }`;
const parseKey = (key) => typeof key === "symbol" ? { kind: "required", key }

@@ -84,0 +81,0 @@ : key.at(-1) === "?" ?

@@ -0,1 +1,2 @@

import type { writeUnassignableDefaultValueMessage } from "@ark/schema";
import type { ErrorMessage } from "@ark/util";

@@ -8,3 +9,1 @@ import type { inferAmbient } from "../../type.ts";

export type validateDefault<baseAst, unitLiteral extends UnitLiteral, $, args> = validateAst<baseAst, $, args> extends infer e extends ErrorMessage ? e : inferAmbient<unitLiteral> extends inferAstOut<baseAst, $, args> ? undefined : ErrorMessage<writeUnassignableDefaultValueMessage<astToString<baseAst>, unitLiteral>>;
export declare const writeUnassignableDefaultValueMessage: <key extends string, message extends string>(key: key, message: message) => string;
export type writeUnassignableDefaultValueMessage<baseDef extends string, defaultValue extends string> = `Default value ${defaultValue} is not assignable to ${baseDef}`;

@@ -1,1 +0,1 @@

export const writeUnassignableDefaultValueMessage = (key, message) => `Default value at ${key} ${message}`;
export {};
import type { GenericAst } from "@ark/schema";
import type { Hkt, array } from "@ark/util";
import type { inferIntersection } from "../../intersect.ts";
import type { Date, Default, LimitLiteral, applyConstraint, distillIn, distillOut, normalizeLimit } from "../../keywords/ast.ts";
import type { Default, LimitLiteral, applyConstraintSchema, distill, normalizeLimit } from "../../keywords/ast.ts";
import type { Date } from "../../keywords/constructors/Date.ts";
import type { UnparsedScope } from "../../scope.ts";

@@ -10,4 +11,4 @@ import type { inferAmbient } from "../../type.ts";

export type inferAstRoot<ast, $, args> = ast extends array ? inferExpression<ast, $, args> : never;
export type inferAstIn<ast, $, args> = distillIn<inferAstRoot<ast, $, args>>;
export type inferAstOut<ast, $, args> = distillOut<inferAstRoot<ast, $, args>>;
export type inferAstIn<ast, $, args> = distill.In<inferAstRoot<ast, $, args>>;
export type inferAstOut<ast, $, args> = distill.Out<inferAstRoot<ast, $, args>>;
export type DefAst<def = unknown, alias extends string = string> = [

@@ -29,4 +30,4 @@ def,

[i in keyof g["names"] & `${number}` as g["names"][i]]: inferExpression<argAsts[i & keyof argAsts], resolveScope<g["arg$"], $>, args>;
}> : ast[1] extends "[]" ? inferExpression<ast[0], $, args>[] : ast[1] extends "|" ? inferExpression<ast[0], $, args> | inferExpression<ast[2], $, args> : ast[1] extends "&" ? inferIntersection<inferExpression<ast[0], $, args>, inferExpression<ast[2], $, args>> : ast[1] extends "=" ? inferAmbient<ast[2]> extends infer defaultValue ? (In?: inferExpression<ast[0], $, args>) => Default<defaultValue> : never : ast[1] extends Comparator ? ast[0] extends LimitLiteral ? constrainBound<inferExpression<ast[2], $, args>, ast[1], ast[0]> : constrainBound<inferExpression<ast[0], $, args>, ast[1], ast[2] & LimitLiteral> : ast[1] extends "%" ? applyConstraint<inferExpression<ast[0], $, args>, "divisor", ast[2] & number> : ast[0] extends "keyof" ? keyof inferExpression<ast[1], $, args> : never : never;
export type constrainBound<constrainableIn, comparator extends Comparator, limit extends LimitLiteral> = distillIn<constrainableIn> extends infer In ? comparator extends "==" ? In extends number ? limit : In extends Date ? Date.literal<normalizeLimit<limit>> : applyConstraint<constrainableIn, "exactLength", limit & number> : applyConstraint<constrainableIn, In extends number ? comparator extends MinComparator ? "min" : "max" : In extends string | array ? comparator extends MinComparator ? "minLength" : "maxLength" : comparator extends MinComparator ? "after" : "before", {
}> : ast[1] extends "[]" ? inferExpression<ast[0], $, args>[] : ast[1] extends "|" ? inferExpression<ast[0], $, args> | inferExpression<ast[2], $, args> : ast[1] extends "&" ? inferIntersection<inferExpression<ast[0], $, args>, inferExpression<ast[2], $, args>> : ast[1] extends "=" ? inferAmbient<ast[2]> extends infer defaultValue ? (In?: inferExpression<ast[0], $, args>) => Default<defaultValue> : never : ast[1] extends Comparator ? ast[0] extends LimitLiteral ? brandBound<inferExpression<ast[2], $, args>, ast[1], ast[0]> : brandBound<inferExpression<ast[0], $, args>, ast[1], ast[2] & LimitLiteral> : ast[1] extends "%" ? applyConstraintSchema<inferExpression<ast[0], $, args>, "divisor", ast[2] & number> : ast[0] extends "keyof" ? keyof inferExpression<ast[1], $, args> : never : never;
export type brandBound<brandableIn, comparator extends Comparator, limit extends LimitLiteral> = distill.In<brandableIn> extends infer In ? comparator extends "==" ? In extends number ? limit : In extends Date ? Date.literal<normalizeLimit<limit>> : applyConstraintSchema<brandableIn, "exactLength", limit & number> : applyConstraintSchema<brandableIn, In extends number ? comparator extends MinComparator ? "min" : "max" : In extends string | array ? comparator extends MinComparator ? "minLength" : "maxLength" : comparator extends MinComparator ? "after" : "before", {
rule: normalizeLimit<limit>;

@@ -39,4 +40,4 @@ exclusive: comparator extends ">" | "<" ? true : false;

export type PostfixExpression<operator extends PostfixOperator = PostfixOperator, operand = unknown> = readonly [operand, operator];
export type InfixOperator = "|" | "&" | Comparator | "%" | ":" | "=>" | "@";
export type InfixOperator = "|" | "&" | Comparator | "%" | ":" | "=>" | "@" | "=";
export type InfixExpression<operator extends InfixOperator = InfixOperator, l = unknown, r = unknown> = [l, operator, r];
export {};

@@ -14,3 +14,3 @@ import type { arkKind, GenericParamAst, PrivateDeclaration, writeMissingSubmoduleAccessMessage, writeUnsatisfiedParameterConstraintMessage } from "@ark/schema";

import type { astToString } from "./utils.ts";
export type validateAst<ast, $, args> = ast extends ErrorMessage ? ast : ast extends InferredAst ? validateInferredAst<ast[0], ast[2]> : ast extends DefAst ? ast[2] extends PrivateDeclaration ? ErrorMessage<writePrefixedPrivateReferenceMessage<ast[2]>> : undefined : ast extends PostfixExpression<infer operator, infer operand> ? operator extends "[]" ? validateAst<operand, $, args> : never : ast extends InfixExpression<infer operator, infer l, infer r> ? operator extends "&" | "|" ? validateInfix<ast, $, args> : operator extends Comparator ? validateRange<l, operator, r, $, args> : operator extends "%" ? validateDivisor<l, $, args> : undefined : ast extends [infer baseAst, "=", infer unitLiteral extends UnitLiteral] ? validateDefault<baseAst, unitLiteral, $, args> : ast extends ["keyof", infer operand] ? validateKeyof<operand, $, args> : ast extends GenericInstantiationAst<infer g, infer argAsts> ? validateGenericArgs<g["paramsAst"], argAsts, $, args, []> : ErrorMessage<writeUnexpectedExpressionMessage<astToString<ast>>> & {
export type validateAst<ast, $, args> = ast extends ErrorMessage ? ast : ast extends InferredAst ? validateInferredAst<ast[0], ast[2]> : ast extends DefAst ? ast[2] extends PrivateDeclaration ? ErrorMessage<writePrefixedPrivateReferenceMessage<ast[2]>> : undefined : ast extends PostfixExpression<infer operator, infer operand> ? operator extends "[]" ? validateAst<operand, $, args> : never : ast extends InfixExpression<infer operator, infer l, infer r> ? operator extends "&" | "|" ? validateInfix<ast, $, args> : operator extends Comparator ? validateRange<l, operator, r, $, args> : operator extends "%" ? validateDivisor<l, $, args> : operator extends "=" ? validateDefault<l, r & UnitLiteral, $, args> : never : ast extends ["keyof", infer operand] ? validateKeyof<operand, $, args> : ast extends GenericInstantiationAst<infer g, infer argAsts> ? validateGenericArgs<g["paramsAst"], argAsts, $, args, []> : ErrorMessage<writeUnexpectedExpressionMessage<astToString<ast>>> & {
ast: ast;

@@ -24,5 +24,5 @@ };

[arkKind]: "module";
} ? "$root" extends keyof inferred ? undefined : ErrorMessage<writeMissingSubmoduleAccessMessage<def>> : def extends ErrorMessage ? def : undefined;
} ? "root" extends keyof inferred ? undefined : ErrorMessage<writeMissingSubmoduleAccessMessage<def>> : def extends ErrorMessage ? def : undefined;
export type validateString<def extends string, $, args> = validateAst<parseString<def, $, args>, $, args> extends (infer result extends ErrorMessage) ? result extends Completion<infer text> ? text : result : def;
type validateInfix<ast extends InfixExpression, $, args> = validateAst<ast[0], $, args> extends infer e extends ErrorMessage ? e : validateAst<ast[2], $, args> extends infer e extends ErrorMessage ? e : undefined;
export {};

@@ -22,4 +22,3 @@ import type { BaseRoot } from "@ark/schema";

ctx: ParseContext;
defaultable: boolean;
constructor(scanner: Scanner, ctx: ParseContext, defaultable: boolean);
constructor(scanner: Scanner, ctx: ParseContext);
error(message: string): never;

@@ -26,0 +25,0 @@ hasRoot(): this is DynamicStateWithRoot;

@@ -19,7 +19,5 @@ import { isKeyOf, throwInternalError, throwParseError } from "@ark/util";

ctx;
defaultable;
constructor(scanner, ctx, defaultable) {
constructor(scanner, ctx) {
this.scanner = scanner;
this.ctx = ctx;
this.defaultable = defaultable;
}

@@ -107,3 +105,3 @@ error(message) {

parseUntilFinalizer() {
return parseUntilFinalizer(new DynamicState(this.scanner, this.ctx, false));
return parseUntilFinalizer(new DynamicState(this.scanner, this.ctx));
}

@@ -110,0 +108,0 @@ parseOperator() {

@@ -5,2 +5,3 @@ import type { DateLiteral } from "../../../../keywords/ast.ts";

export declare const extractDateLiteralSource: <literal extends DateLiteral>(literal: literal) => extractDateLiteralSource<literal>;
type extractDateLiteralSource<literal extends DateLiteral> = literal extends DateLiteral<infer source> ? source : never;
export declare const writeInvalidDateMessage: <source extends string>(source: source) => writeInvalidDateMessage<source>;

@@ -11,1 +12,2 @@ export type writeInvalidDateMessage<source extends string> = `'${source}' could not be parsed by the Date constructor`;

export declare const tryParseDate: <errorOnFail extends boolean | string>(source: string, errorOnFail?: errorOnFail) => DateParseResult<errorOnFail>;
export {};

@@ -1,2 +0,3 @@

import type { Date, string } from "../../../../keywords/ast.ts";
import type { string } from "../../../../keywords/ast.ts";
import type { Date } from "../../../../keywords/constructors/Date.ts";
import type { InferredAst } from "../../../semantic/infer.ts";

@@ -3,0 +4,0 @@ import type { DynamicState } from "../../reduce/dynamic.ts";

import type { BaseRoot } from "@ark/schema";
import { type BigintLiteral, type ErrorMessage, type NumberLiteral, type trim } from "@ark/util";
import type { BigintLiteral, ErrorMessage, NumberLiteral, trim } from "@ark/util";
import type { DateLiteral } from "../../../../keywords/ast.ts";

@@ -8,4 +8,3 @@ import type { DynamicStateWithRoot } from "../../reduce/dynamic.ts";

export type UnitLiteral = StringLiteral | BigintLiteral | NumberLiteral | DateLiteral | UnitLiteralKeyword;
export type ParsedDefault = [BaseRoot, "=", unknown];
export declare const parseDefault: (s: DynamicStateWithRoot) => ParsedDefault;
export declare const parseDefault: (s: DynamicStateWithRoot) => BaseRoot;
export type parseDefault<root, unscanned extends string> = trim<unscanned> extends infer defaultValue extends UnitLiteral ? [

@@ -18,4 +17,2 @@ root,

export type writeNonLiteralDefaultMessage<defaultDef extends string> = `Default value '${defaultDef}' must a literal value`;
export declare const shallowDefaultMessage = "Default values must be specified on objects like { isAdmin: 'boolean = false' }";
export type shallowDefaultMessage = typeof shallowDefaultMessage;
export {};

@@ -1,5 +0,2 @@

import { throwParseError } from "@ark/util";
export const parseDefault = (s) => {
if (!s.defaultable)
return throwParseError(shallowDefaultMessage);
// store the node that will be bounded

@@ -13,6 +10,4 @@ const baseNode = s.unsetRoot();

return s.error(writeNonLiteralDefaultMessage(defaultNode.expression));
// assignability is checked in parseEntries
return [baseNode, "=", defaultNode.unit];
return baseNode.default(defaultNode.unit);
};
export const writeNonLiteralDefaultMessage = (defaultDef) => `Default value '${defaultDef}' must a literal value`;
export const shallowDefaultMessage = `Default values must be specified on objects like { isAdmin: 'boolean = false' }`;

@@ -10,3 +10,3 @@ import type { BaseRoot, resolvableReferenceIn } from "@ark/schema";

import type { parseOperand } from "./shift/operand/operand.ts";
import { parseDefault, type ParsedDefault } from "./shift/operator/default.ts";
import { parseDefault } from "./shift/operator/default.ts";
import { writeUnexpectedCharacterMessage, type parseOperator } from "./shift/operator/operator.ts";

@@ -23,4 +23,3 @@ /**

export type BaseCompletions<$, args, otherSuggestions extends string = never> = resolvableReferenceIn<$> | resolvableReferenceIn<ArkAmbient.$> | (keyof args & string) | StringifiablePrefixOperator | otherSuggestions;
export type StringParseResult = BaseRoot | ParsedDefault;
export declare const fullStringParse: (s: DynamicState) => StringParseResult;
export declare const fullStringParse: (s: DynamicState) => BaseRoot;
type fullStringParse<s extends StaticState, $, args> = extractFinalizedResult<parseUntilFinalizer<s, $, args>>;

@@ -27,0 +26,0 @@ export declare const parseUntilFinalizer: (s: DynamicState) => DynamicStateWithRoot;

import { type BaseRoot, type MetaSchema, type Morph, type Predicate } from "@ark/schema";
import { 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 { distillConstrainableIn, distillOut, inferMorphOut, inferPredicate, Out } from "../keywords/ast.ts";
import type { type } from "../keywords/ark.ts";
import type { Default, distill, inferMorphOut, inferPredicate, Out } from "../keywords/ast.ts";
import type { ParseContext } from "../scope.ts";

@@ -102,3 +103,3 @@ import type { inferDefinition, validateDefinition } from "./definition.ts";

export type inferTuple<def extends array, $, args> = def extends TupleExpression ? inferTupleExpression<def, $, args> : inferTupleLiteral<def, $, args>;
export type inferTupleExpression<def extends TupleExpression, $, args> = def[1] extends "[]" ? inferDefinition<def[0], $, args>[] : def[1] extends "&" ? inferIntersection<inferDefinition<def[0], $, args>, inferDefinition<def[2], $, args>> : def[1] extends "|" ? inferDefinition<def[0], $, args> | inferDefinition<def[2], $, args> : def[1] extends ":" ? inferPredicate<inferDefinition<def[0], $, args>, def[2]> : def[1] extends "=>" ? parseMorph<def[0], def[2], $, args> : def[1] extends "@" ? inferDefinition<def[0], $, args> : def extends readonly ["===", ...infer values] ? values[number] : def extends (readonly ["instanceof", ...infer constructors extends Constructor[]]) ? InstanceType<constructors[number]> : def[0] extends "keyof" ? inferKeyOfExpression<def[1], $, args> : never;
export type inferTupleExpression<def extends TupleExpression, $, args> = def[1] extends "[]" ? inferDefinition<def[0], $, args>[] : def[1] extends "&" ? inferIntersection<inferDefinition<def[0], $, args>, inferDefinition<def[2], $, args>> : def[1] extends "|" ? inferDefinition<def[0], $, args> | inferDefinition<def[2], $, args> : def[1] extends ":" ? inferPredicate<inferDefinition<def[0], $, args>, def[2]> : def[1] extends "=>" ? parseMorph<def[0], def[2], $, args> : def[1] extends "@" ? inferDefinition<def[0], $, args> : def[1] extends "=" ? (In?: inferDefinition<def[0], $, args>) => Default<def[2]> : def extends readonly ["===", ...infer values] ? values[number] : def extends (readonly ["instanceof", ...infer constructors extends Constructor[]]) ? InstanceType<constructors[number]> : def[0] extends "keyof" ? inferKeyOfExpression<def[1], $, args> : never;
export type validatePrefixExpression<def extends IndexZeroExpression, $, args> = def["length"] extends 1 ? readonly [writeMissingRightOperandMessage<def[0]>] : def[0] extends "keyof" ? readonly [def[0], validateDefinition<def[1], $, args>] : def[0] extends "===" ? readonly [def[0], ...unknown[]] : def[0] extends "instanceof" ? readonly [def[0], ...Constructor[]] : never;

@@ -109,3 +110,3 @@ export type validatePostfixExpression<def extends PostfixExpression, $, args> = conform<def, readonly [validateDefinition<def[0], $, args>, "[]"]>;

def[1],
def[1] extends "|" ? validateDefinition<def[2], $, args> : def[1] extends "&" ? validateDefinition<def[2], $, args> : def[1] extends ":" ? Predicate<distillOut<inferDefinition<def[0], $, args>>> : def[1] extends "=>" ? Morph<distillOut<inferDefinition<def[0], $, args>>, unknown> : def[1] extends "@" ? MetaSchema : validateDefinition<def[2], $, args>
def[1] extends "|" ? validateDefinition<def[2], $, args> : def[1] extends "&" ? validateDefinition<def[2], $, args> : def[1] extends ":" ? Predicate<type.infer.Out<def[0], $, args>> : def[1] extends "=>" ? Morph<type.infer.Out<def[0], $, args>> : def[1] extends "@" ? MetaSchema : def[1] extends "=" ? type.infer.Out<def[0], $, args> : validateDefinition<def[2], $, args>
];

@@ -125,7 +126,7 @@ export type UnparsedTupleExpressionInput = {

export type TuplePostfixOperator = "[]";
export type TupleInfixOperator = "&" | "|" | "=>" | ":" | "@";
export type TupleInfixOperator = "&" | "|" | "=>" | ":" | "@" | "=";
export type IndexOneExpression<token extends IndexOneOperator = IndexOneOperator> = readonly [unknown, token, ...unknown[]];
export declare const parseMorphTuple: PostfixParser<"=>">;
export declare const writeMalformedFunctionalExpressionMessage: (operator: ":" | "=>", value: unknown) => string;
export type parseMorph<inDef, morph, $, args> = morph extends Morph ? inferMorphOut<morph> extends infer out ? (In: distillConstrainableIn<inferDefinition<inDef, $, args>>) => Out<out> : never : never;
export type parseMorph<inDef, morph, $, args> = morph extends Morph ? inferMorphOut<morph> extends infer out ? (In: distill.brandable.In<inferDefinition<inDef, $, args>>) => Out<out> : never : never;
export declare const parseNarrowTuple: PostfixParser<":">;

@@ -132,0 +133,0 @@ export type IndexZeroOperator = "keyof" | "instanceof" | "===";

@@ -132,2 +132,3 @@ import { $ark, makeRootAndArrayPropertiesMutable } from "@ark/schema";

const parseAttributeTuple = (def, ctx) => ctx.$.parse(def[0], ctx).configureShallowDescendants(def[2]);
const parseDefaultTuple = (def, ctx) => ctx.$.parse(def[0], ctx).default(def[2]);
const indexOneParsers = {

@@ -139,3 +140,4 @@ "|": parseBranchTuple,

"=>": parseMorphTuple,
"@": parseAttributeTuple
"@": parseAttributeTuple,
"=": parseDefaultTuple
};

@@ -142,0 +144,0 @@ const prefixParsers = {

@@ -9,4 +9,3 @@ import { BaseScope, type AliasDefEntry, type ArkScopeConfig, type BaseNode, type BaseRoot, type GenericArgResolutions, type GenericAst, type GenericParamAst, type NodeKind, type NodeParseOptions, 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 { DefAst, InferredAst } from "./parser/semantic/infer.ts";
import type { ParsedDefault } from "./parser/string/shift/operator/default.ts";
import { InternalTypeParser, type DeclarationParser, type DefinitionParser, type Type, type TypeParser } from "./type.ts";
import { InternalTypeParser, type DeclarationParser, type DefinitionParser, type EnumeratedTypeParser, type Type, type TypeParser, type UnitTypeParser } from "./type.ts";
export type ScopeParser = <const def>(def: validateScope<def>, config?: ArkScopeConfig) => Scope<inferScope<def>>;

@@ -48,3 +47,3 @@ export type ModuleParser = <const def>(def: validateScope<def>, config?: ArkScopeConfig) => inferScope<def> extends infer $ ? Module<{

[arkKind]: "module";
$root: infer root;
root: infer root;
} ? InferredAst<root, alias> : resolution extends GenericAst ? resolution : InferredAst<resolution, alias>;

@@ -77,5 +76,7 @@ export type moduleKeyOf<$> = {

get ambientAttachments(): Ark.boundTypeAttachments<$> | undefined;
parse<defaultable extends boolean = false>(def: unknown, ctx: ParseContext, defaultable?: defaultable): BaseRoot | (defaultable extends false ? never : ParsedDefault);
parseString<defaultable extends boolean>(def: string, ctx: ParseContext, defaultable: defaultable): BaseRoot | (defaultable extends false ? never : ParsedDefault);
parse(def: unknown, ctx: ParseContext): BaseRoot;
parseString(def: string, ctx: ParseContext): BaseRoot;
parseRoot: (def: unknown, opts?: TypeParseOptions) => BaseRoot;
unit: UnitTypeParser<$>;
enumerated: EnumeratedTypeParser<$>;
type: InternalTypeParser;

@@ -105,2 +106,4 @@ declare: () => {

node<kinds extends NodeKind | array<RootKind>>(kinds: kinds, schema: NodeSchema<flattenListable<kinds>>, opts?: NodeParseOptions): nodeOfKind<reducibleKindOf<flattenListable<kinds>>>;
unit: UnitTypeParser<$>;
enumerated: EnumeratedTypeParser<$>;
type: TypeParser<$>;

@@ -107,0 +110,0 @@ declare: DeclarationParser<$>;

@@ -53,3 +53,3 @@ import { $ark, BaseScope, hasArkKind, parseGeneric } from "@ark/schema";

}
parse(def, ctx, defaultable = false) {
parse(def, ctx) {
if (typeof def === "string") {

@@ -59,6 +59,5 @@ if (ctx.args && Object.keys(ctx.args).some(k => def.includes(k))) {

// resolutions like "this" or generic args
return this.parseString(def, ctx, defaultable);
return this.parseString(def, ctx);
}
const contextKey = `${def}${defaultable}`;
return (this.parseCache[contextKey] ??= this.parseString(def, ctx, defaultable));
return (this.parseCache[def] ??= this.parseString(def, ctx));
}

@@ -69,3 +68,3 @@ return hasDomain(def, "object") ?

}
parseString(def, ctx, defaultable) {
parseString(def, ctx) {
const aliasResolution = this.maybeResolveRoot(def);

@@ -79,3 +78,3 @@ if (aliasResolution)

return aliasArrayResolution;
const s = new DynamicState(new Scanner(def), ctx, defaultable);
const s = new DynamicState(new Scanner(def), ctx);
const node = fullStringParse(s);

@@ -90,2 +89,4 @@ if (s.finalizer === ">")

};
unit = value => this.units([value]);
enumerated = (...values) => this.units(values);
type = new InternalTypeParser(this);

@@ -92,0 +93,0 @@ declare = () => ({

@@ -5,8 +5,8 @@ import { ArkErrors, BaseRoot, type MetaSchema, type Morph, type Predicate } from "@ark/schema";

import type { Ark, ark } from "./keywords/ark.ts";
import type { distillIn, distillOut } from "./keywords/ast.ts";
import type { distill } from "./keywords/ast.ts";
import type { BaseType } from "./methods/base.ts";
import type { instantiateType } from "./methods/instantiate.ts";
import type { inferDefinition, validateDeclared, validateDefinition } from "./parser/definition.ts";
import type { IndexOneOperator, IndexZeroOperator, TupleInfixOperator } from "./parser/tuple.ts";
import type { InternalScope, ModuleParser, Scope, ScopeParser, bindThis } from "./scope.ts";
import type { BaseType } from "./subtypes/base.ts";
import type { instantiateType } from "./subtypes/instantiate.ts";
/** The convenience properties attached to `type` */

@@ -17,3 +17,3 @@ export type TypeParserAttachments = Omit<TypeParser, never>;

<params extends ParameterString, const def>(params: validateParameterString<params, $>, def: validateDefinition<def, $, baseGenericConstraints<parseValidGenericParams<params, $>>>): Generic<parseValidGenericParams<params, $>, def, $>;
<const zero, const one, const rest extends array, r = Type<inferTypeRoot<[zero, one, ...rest], $>, $>>(_0: zero extends IndexZeroOperator ? zero : validateTypeRoot<zero, $>, _1: zero extends "keyof" ? validateTypeRoot<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<distillIn<inferTypeRoot<zero, $>>>] : one extends "=>" ? [Morph<distillOut<inferTypeRoot<zero, $>>, unknown>] : one extends "@" ? [MetaSchema] : [validateTypeRoot<rest[0], $>] : []): r;
<const zero, const one, const rest extends array, r = Type<inferTypeRoot<[zero, one, ...rest], $>, $>>(_0: zero extends IndexZeroOperator ? zero : validateTypeRoot<zero, $>, _1: zero extends "keyof" ? validateTypeRoot<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<inferTypeRoot<zero, $>>>] : one extends "=>" ? [Morph<distill.Out<inferTypeRoot<zero, $>>, unknown>] : one extends "@" ? [MetaSchema] : [validateTypeRoot<rest[0], $>] : []): r;
raw(def: unknown): BaseType<any, $>;

@@ -25,2 +25,4 @@ errors: typeof ArkErrors;

ark: typeof ark;
unit: UnitTypeParser<$>;
enumerated: EnumeratedTypeParser<$>;
}

@@ -33,2 +35,4 @@ export declare class InternalTypeParser extends Callable<(...args: unknown[]) => BaseRoot | Generic, TypeParserAttachments> {

};
export type UnitTypeParser<$> = <const t>(value: t) => Type<t, $>;
export type EnumeratedTypeParser<$> = <const values extends readonly unknown[]>(...values: values) => Type<values[number], $>;
export type DefinitionParser<$> = <def>(def: validateTypeRoot<def, $>) => def;

@@ -35,0 +39,0 @@ export type validateTypeRoot<def, $ = {}> = validateDefinition<def, $, bindThis<def>>;

@@ -13,3 +13,5 @@ import { ArkErrors, BaseRoot, GenericRoot } from "@ark/schema";

// this won't be defined during bootstrapping, but externally always will be
ark: $.ambient
ark: $.ambient,
unit: $.unit,
enumerated: $.enumerated
},

@@ -16,0 +18,0 @@ // also won't be defined during bootstrapping

{
"name": "arktype",
"description": "TypeScript's 1:1 validator, optimized from editor to runtime",
"version": "2.0.0-rc.4",
"version": "2.0.0-rc.5",
"license": "MIT",

@@ -37,4 +37,4 @@ "author": {

"dependencies": {
"@ark/util": "0.6.0",
"@ark/schema": "0.6.0"
"@ark/schema": "0.7.0",
"@ark/util": "0.7.0"
},

@@ -41,0 +41,0 @@ "publishConfig": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc