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-beta.5 to 2.0.0-beta.6

out/keywords/ark.d.ts

17

out/ast.d.ts
import type { ArkError, ArkErrors, Constraint, constraintKindOf, Morph, NodeSchema } from "@ark/schema";
import { type anyOrNever, type array, type BuiltinObjectKind, type BuiltinObjects, type conform, type equals, type leftIfEqual, type Primitive, type propValueOf, type show } from "@ark/util";
import type { type } from "./ark.js";
import type { inferPipe } from "./intersect.js";
import type { platformObjectExports } from "./keywords/platformObjects.js";
import type { typedArrayExports } from "./keywords/typedArray.js";
import type { Type } from "./type.js";
export declare const inferred: " arkInferred";
export type inferred = typeof inferred;
import type { inferPipe } from "./intersect.ts";
import type { type } from "./keywords/ark.ts";
import type { arkPlatform } from "./keywords/platform.ts";
import type { arkTypedArray } from "./keywords/typedArray.ts";
import type { Type } from "./type.ts";
export type Comparator = "<" | "<=" | ">" | ">=" | "==";

@@ -49,6 +47,5 @@ export type RegexLiteral<source extends string = string> = `/${source}/`;

};
export type anonymous = "?";
export type Narrowed = {
predicate: {
[k in anonymous]: 1;
[k in "?"]: 1;
};

@@ -207,3 +204,3 @@ };

/** Objects we don't want to expand during inference like Date or Promise */
type TerminallyInferredObjectKind = ArkEnv.prototypes | BuiltinObjects[Exclude<BuiltinObjectKind, "Array" | "Function">] | propValueOf<platformObjectExports> | propValueOf<typedArrayExports>;
type TerminallyInferredObjectKind = ArkEnv.prototypes | BuiltinObjects[Exclude<BuiltinObjectKind, "Array" | "Function">] | propValueOf<arkPlatform.keywords> | propValueOf<arkTypedArray.submodule>;
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>;

@@ -210,0 +207,0 @@ export type constrainWithPredicate<t> = t extends constrain<unknown, infer constraints> ? applyConstraint<constrain<t, constraints>, "predicate", any> : applyConstraint<t, "predicate", any>;

import { noSuggest } from "@ark/util";
export const inferred = noSuggest("arkInferred");
export const constrained = noSuggest("arkConstrained");
import type { ArkSchemaRegistry } from "@ark/schema";
import type { Ark } from "./ark.js";
import type { exportScope } from "./module.js";
import type { Ark } from "./keywords/ark.ts";
import type { exportScope } from "./module.ts";
export * from "@ark/schema/config";

@@ -10,5 +10,20 @@ export interface ArkTypeRegistryContents extends ArkSchemaRegistry {

export interface ArkEnv {
$(): Ark;
}
export namespace ArkEnv {
type $ = ReturnType<ArkEnv["$"]>;
}
}
/**
* This mirrors the global ArkEnv namespace as a local export. We use it instead
* of the global internally due to a bug in twoslash that prevents `ark/docs`
* from building if we refer to the global directly.
*
* If, in the future, docs can build while arktype refers to `ArkEnv.$` directly,
* this can be removed.
*/
export declare namespace ArkAmbient {
type $ = ArkEnv.$;
type meta = ArkEnv.meta;
type prototypes = ArkEnv.prototypes;
}
import type { arkKind, GenericAst, GenericParamAst, GenericParamDef, genericParamNames, GenericRoot, LazyGenericBody } from "@ark/schema";
import { type array, type Callable, type conform, type ErrorMessage, type ErrorType, type Hkt, type WhiteSpaceToken } from "@ark/util";
import type { inferDefinition } from "./parser/definition.js";
import type { inferAstRoot } from "./parser/semantic/infer.js";
import type { validateAst } from "./parser/semantic/validate.js";
import type { state, StaticState } from "./parser/string/reduce/static.js";
import { Scanner } from "./parser/string/shift/scanner.js";
import { parseUntilFinalizer } from "./parser/string/string.js";
import type { ParseContext, Scope } from "./scope.js";
import type { inferTypeRoot, Type, validateTypeRoot } from "./type.js";
import type { inferDefinition } 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 { Scanner } from "./parser/string/shift/scanner.ts";
import { parseUntilFinalizer } from "./parser/string/string.ts";
import type { ParseContext, Scope } from "./scope.ts";
import type { inferTypeRoot, Type, validateTypeRoot } from "./type.ts";
export type ParameterString<params extends string = string> = `<${params}>`;

@@ -129,10 +129,3 @@ export type extractParams<s extends ParameterString> = s extends ParameterString<infer params> ? params : never;

], $>;
declare const paramsTerminators: {
",": boolean;
":": boolean;
" ": true;
"\n": true;
"\t": true;
};
type ParamsTerminator = keyof typeof paramsTerminators;
type ParamsTerminator = WhiteSpaceToken | "," | ":";
declare const parseName: (scanner: Scanner, result: GenericParamDef[], ctx: ParseContext) => GenericParamDef[];

@@ -139,0 +132,0 @@ type parseName<unscanned extends string, result extends array<GenericParamAst>, $> = parseNextNameChar<Scanner.skipWhitespace<unscanned>, "", result, $>;

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

import { throwParseError, whiteSpaceTokens } from "@ark/util";
import { throwParseError } from "@ark/util";
import { DynamicState } from "./parser/string/reduce/dynamic.js";

@@ -7,3 +7,2 @@ import { Scanner } from "./parser/string/shift/scanner.js";

export const parseGenericParams = (def, ctx) => parseName(new Scanner(def), [], ctx);
const paramsTerminators = { ...whiteSpaceTokens, ",": true, ":": true };
const parseName = (scanner, result, ctx) => {

@@ -10,0 +9,0 @@ scanner.shiftUntilNonWhitespace();

@@ -1,8 +0,7 @@

export { ArkError, ArkErrors } from "@ark/schema";
export type { ArkConfig, ArkScopeConfig } from "@ark/schema";
export { ArkError, ArkErrors, type ArkConfig, type ArkScopeConfig, type JsonSchema } from "@ark/schema";
export { Hkt } from "@ark/util";
export { ambient, ark, declare, define, generic, type } from "./ark.js";
export type { Generic } from "./generic.js";
export { Module, type Submodule, type BoundModule } from "./module.js";
export { scope, type Scope, type inferScope, type validateScope } from "./scope.js";
export { Type, type inferAmbient, type inferTypeRoot, type validateAmbient, type validateTypeRoot } from "./type.js";
export type { Generic } from "./generic.ts";
export { ambient, ark, declare, define, generic, type } from "./keywords/ark.ts";
export { Module, type BoundModule, type Submodule } from "./module.ts";
export { scope, type Scope, type inferScope, type validateScope } from "./scope.ts";
export { Type, type inferAmbient, type inferTypeRoot, type validateAmbient, type validateTypeRoot } from "./type.ts";
export { ArkError, ArkErrors } from "@ark/schema";
export { Hkt } from "@ark/util";
export { ambient, ark, declare, define, generic, type } from "./ark.js";
export { ambient, ark, declare, define, generic, type } from "./keywords/ark.js";
export { Module } from "./module.js";
export { scope } from "./scope.js";
export { Type } from "./type.js";
import type { anyOrNever, array, Hkt, intersectArrays, show } from "@ark/util";
import type { constrain, Constraints, MorphAst, parseConstraints, To } from "./ast.js";
import type { constrain, Constraints, MorphAst, parseConstraints, To } from "./ast.ts";
export type inferIntersection<l, r> = _inferIntersection<l, r, false>;

@@ -4,0 +4,0 @@ export type inferPipe<l, r> = _inferIntersection<l, r, true>;

import type { array, join, Key, NonNegativeIntegerLiteral, typeToString } from "@ark/util";
import type { type } from "./ark.js";
import type { termOrType } from "./ast.js";
import type { termOrType } from "./ast.ts";
import type { type } from "./keywords/ark.ts";
export type toArkKey<o, k extends keyof o> = k extends number ? [

@@ -5,0 +5,0 @@ o,

@@ -1,11 +0,14 @@

import type { Out } from "../ast.js";
import type { Module } from "../module.js";
export type formattingExports = {
trim: (In: string) => Out<string>;
uppercase: (In: string) => Out<string>;
lowercase: (In: string) => Out<string>;
capitalize: (In: string) => Out<string>;
normalize: (In: string) => Out<string>;
import type { Out } from "../ast.ts";
import type { Module, Submodule } from "../module.ts";
export declare const arkFormat: {
submodule: Module<arkFormat.submodule>;
};
export type formatting = Module<formattingExports>;
export declare const formatting: formatting;
export declare namespace arkFormat {
type submodule = Submodule<{
trim: (In: string) => Out<string>;
uppercase: (In: string) => Out<string>;
lowercase: (In: string) => Out<string>;
capitalize: (In: string) => Out<string>;
normalize: (In: string) => Out<string>;
}>;
}

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

});
export const formatting = scope({
const submodule = scope({
trim,

@@ -33,1 +33,4 @@ uppercase,

}).export();
export const arkFormat = {
submodule
};

@@ -1,16 +0,19 @@

import type { Module } from "../module.js";
export interface typedArrayExports {
Int8: Int8Array;
Uint8: Uint8Array;
Uint8Clamped: Uint8ClampedArray;
Int16: Int16Array;
Uint16: Uint16Array;
Int32: Int32Array;
Uint32: Uint32Array;
Float32: Float32Array;
Float64: Float64Array;
BigInt64: BigInt64Array;
BigUint64: BigUint64Array;
import type { Module, Submodule } from "../module.ts";
export declare const arkTypedArray: {
submodule: Module<arkTypedArray.submodule>;
};
export declare namespace arkTypedArray {
type submodule = Submodule<{
Int8: Int8Array;
Uint8: Uint8Array;
Uint8Clamped: Uint8ClampedArray;
Int16: Int16Array;
Uint16: Uint16Array;
Int32: Int32Array;
Uint32: Uint32Array;
Float32: Float32Array;
Float64: Float64Array;
BigInt64: BigInt64Array;
BigUint64: BigUint64Array;
}>;
}
export type typedArray = Module<typedArrayExports>;
export declare const typedArray: typedArray;
import { scope } from "../scope.js";
export const typedArray = scope({
const submodule = scope({
Int8: ["instanceof", Int8Array],

@@ -15,1 +15,4 @@ Uint8: ["instanceof", Uint8Array],

}, { prereducedAliases: true }).export();
export const arkTypedArray = {
submodule
};

@@ -19,3 +19,4 @@ type DayDelimiter = "." | "/" | "-";

};
export declare const iso8601Matcher: RegExp;
export declare const tryParseDatePattern: (data: string, opts?: DateOptions) => Date | string;
export {};

@@ -5,3 +5,3 @@ const dayDelimiterMatcher = /^[./-]$/;

// delimiter for date/time is mandatory. Regex from validator.js strict matcher:
const iso8601Matcher = /^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;
export const iso8601Matcher = /^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;
const isValidDateInstance = (date) => !Number.isNaN(+date);

@@ -8,0 +8,0 @@ const writeFormattedExpected = (format) => `a ${format}-formatted date`;

@@ -1,3 +0,16 @@

export declare const ipv4: import("@ark/schema").IntersectionNode;
export declare const ipv6: import("@ark/schema").IntersectionNode;
export declare const ip: import("@ark/schema").BaseRoot<import("@ark/schema").InternalRootDeclaration>;
import type { string } from "../../ast.ts";
import type { Submodule } from "../../module.ts";
export declare const arkIp: {
submodule: import("../../module.ts").Module<{
$root: string.matching<"?">;
v4: string.matching<"?">;
v6: string.matching<"?">;
}>;
};
export declare namespace arkIp {
type submodule = Submodule<{
$root: string.matching<"?">;
v4: string.matching<"?">;
v6: string.matching<"?">;
}>;
}

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

import { rootNode } from "@ark/schema";
import { scope } from "../../scope.js";
import { regexStringNode } from "./regex.js";

@@ -7,3 +7,2 @@ // Based on https://github.com/validatorjs/validator.js/blob/master/src/lib/isIP.js

const ipv4Matcher = new RegExp(`^${ipv4Address}$`);
export const ipv4 = regexStringNode(ipv4Matcher, "a valid IPv4 address");
const ipv6Segment = "(?:[0-9a-fA-F]{1,4})";

@@ -20,3 +19,10 @@ const ipv6Matcher = new RegExp("^(" +

")(%[0-9a-zA-Z-.:]{1,})?$");
export const ipv6 = regexStringNode(ipv6Matcher, "a valid IPv6 address");
export const ip = rootNode([ipv4, ipv6]);
// Based on https://github.com/validatorjs/validator.js/blob/master/src/lib/isUUID.js
const submodule = scope({
$root: ["v4 | v6", "@", "an IP address"],
v4: regexStringNode(ipv4Matcher, "an IPv4 address"),
v6: regexStringNode(ipv6Matcher, "an IPv6 address")
}, { prereducedAliases: true }).export();
export const arkIp = {
submodule
};

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

import { type Intersection } from "@ark/schema";
export declare const regexStringNode: (regex: RegExp, description: string) => Intersection.Node;
import type { string } from "../../ast.ts";
import type { Type } from "../../type.ts";
export declare const regexStringNode: (regex: RegExp, description: string) => Type<string.matching<"?">>;
import { RootModule, type GenericAst, type PreparsedNodeResolution } from "@ark/schema";
import type { anyOrNever } from "@ark/util";
import type { Generic } from "./generic.js";
import type { Type } from "./type.js";
import type { Generic } from "./generic.ts";
import type { Type } from "./type.ts";
export declare const Module: new <$ extends {}>(exports: exportScope<$>) => Module<$>;

@@ -6,0 +6,0 @@ export interface Module<$ extends {} = {}> extends RootModule<exportScope<$>> {

import { type BaseRoot } from "@ark/schema";
import { type ErrorMessage, type Primitive, type anyOrNever, type array, type defined, type equals, type objectKindOrDomainOf, type optionalKeyOf, type requiredKeyOf, type show } from "@ark/util";
import type { type } from "../ark.js";
import type { string } from "../ast.js";
import type { ParseContext } from "../scope.js";
import { type inferObjectLiteral, type validateObjectLiteral } from "./objectLiteral.js";
import type { validateString } from "./semantic/validate.js";
import type { BaseCompletions, inferString } from "./string/string.js";
import { type TupleExpression, type inferTuple, type validateTuple } from "./tuple.js";
import { type ErrorMessage, type Fn, type Primitive, type anyOrNever, type array, type defined, type equals, type objectKindOrDomainOf, type optionalKeyOf, type requiredKeyOf, type show } from "@ark/util";
import type { string } from "../ast.ts";
import type { type } from "../keywords/ark.ts";
import type { ParseContext } from "../scope.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 TupleExpression, type inferTuple, type validateTuple } from "./tuple.ts";
export declare const parseObject: (def: object, ctx: ParseContext) => BaseRoot;

@@ -28,3 +28,3 @@ export type inferDefinition<def, $, args> = [

};
type Terminal = RegExp | type.cast<unknown> | ((...args: never[]) => unknown);
type Terminal = RegExp | type.cast<unknown> | Fn;
export type ThunkCast<t = unknown> = () => type.cast<t>;

@@ -31,0 +31,0 @@ type BadDefinitionType = Exclude<Primitive, string>;

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 "../ast.js";
import type { ParseContext } from "../scope.js";
import type { inferDefinition, validateDefinition } from "./definition.js";
import type { astToString } from "./semantic/utils.js";
import type { validateString } from "./semantic/validate.js";
import type { constrain, Default } from "../ast.ts";
import type { ParseContext } from "../scope.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: ParseContext) => BaseRoot;

@@ -16,3 +16,5 @@ export declare const writeInvalidUndeclaredBehaviorMessage: (actual: unknown) => string;

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

@@ -19,0 +21,0 @@ -readonly [k in keyof def as optionalKeyFrom<k>]?: inferDefinition<def[k], $, args>;

import type { writeUnboundableMessage } from "@ark/schema";
import type { ErrorMessage, array, typeToString } from "@ark/util";
import type { LimitLiteral } from "../../ast.js";
import type { Comparator } from "../string/reduce/shared.js";
import type { BoundExpressionKind, writeInvalidLimitMessage } from "../string/shift/operator/bounds.js";
import type { inferAstIn } from "./infer.js";
import type { astToString } from "./utils.js";
import type { validateAst } from "./validate.js";
import type { LimitLiteral } from "../../ast.ts";
import type { Comparator } from "../string/reduce/shared.ts";
import type { BoundExpressionKind, writeInvalidLimitMessage } from "../string/shift/operator/bounds.ts";
import type { inferAstIn } from "./infer.ts";
import type { astToString } from "./utils.ts";
import type { validateAst } from "./validate.ts";
export type validateRange<l, comparator extends Comparator, r, $, args> = l extends LimitLiteral ? validateBound<r, comparator, l, "left", $, args> : l extends [infer leftAst, Comparator, unknown] ? ErrorMessage<writeDoubleRightBoundMessage<astToString<leftAst>>> : validateBound<l, comparator, r & LimitLiteral, "right", $, args>;

@@ -10,0 +10,0 @@ export type validateBound<boundedAst, comparator extends Comparator, limit extends LimitLiteral, boundKind extends BoundExpressionKind, $, args> = inferAstIn<boundedAst, $, args> extends infer bounded ? isNumericallyBoundable<bounded> extends true ? limit extends number ? validateAst<boundedAst, $, args> : ErrorMessage<writeInvalidLimitMessage<comparator, limit, boundKind>> : [bounded] extends [Date] ? validateAst<boundedAst, $, args> : ErrorMessage<writeUnboundableMessage<typeToString<bounded>>> : never;

import type { ErrorMessage } from "@ark/util";
import type { UnitLiteral } from "../string/shift/operator/default.js";
import type { inferAstOut, inferTerminal } from "./infer.js";
import type { astToString } from "./utils.js";
import type { validateAst } from "./validate.js";
import type { UnitLiteral } from "../string/shift/operator/default.ts";
import type { inferAstOut, inferTerminal } from "./infer.ts";
import type { astToString } from "./utils.ts";
import type { validateAst } from "./validate.ts";
export type validateDefault<baseAst, unitLiteral extends UnitLiteral, $, args> = validateAst<baseAst, $, args> extends infer e extends ErrorMessage ? e : inferTerminal<unitLiteral, $, args> 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}`;
import type { writeIndivisibleMessage } from "@ark/schema";
import type { ErrorMessage } from "@ark/util";
import type { inferAstIn } from "./infer.js";
import type { validateAst } from "./validate.js";
import type { inferAstIn } from "./infer.ts";
import type { validateAst } from "./validate.ts";
export type validateDivisor<l, $, args> = inferAstIn<l, $, args> extends infer data ? [
data
] extends [number] ? validateAst<l, $, args> : ErrorMessage<writeIndivisibleMessage<data>> : never;
import type { GenericAst } from "@ark/schema";
import type { BigintLiteral, Hkt, array } from "@ark/util";
import type { Ark } from "../../ark.js";
import type { Date, DateLiteral, Default, LimitLiteral, RegexLiteral, applyConstraint, distillIn, distillOut, normalizeLimit, string } from "../../ast.js";
import type { inferIntersection } from "../../intersect.js";
import type { UnparsedScope, resolve, tryInferSubmoduleReference } from "../../scope.js";
import type { inferDefinition } from "../definition.js";
import type { Comparator, MinComparator } from "../string/reduce/shared.js";
import type { StringLiteral } from "../string/shift/operand/enclosed.js";
import type { ArkAmbient } from "arktype/config";
import type { Date, DateLiteral, Default, LimitLiteral, RegexLiteral, applyConstraint, distillIn, distillOut, normalizeLimit, string } from "../../ast.ts";
import type { inferIntersection } from "../../intersect.ts";
import type { UnparsedScope, resolve, tryInferSubmoduleReference } from "../../scope.ts";
import type { inferDefinition } from "../definition.ts";
import type { Comparator, MinComparator } from "../string/reduce/shared.ts";
import type { StringLiteral } from "../string/shift/operand/enclosed.ts";
export type inferAstRoot<ast, $, args> = inferConstrainableAst<ast, $, args>;

@@ -31,3 +31,3 @@ export type inferAstIn<ast, $, args> = distillIn<inferAstRoot<ast, $, args>>;

export type InfixExpression<operator extends InfixOperator = InfixOperator, l = unknown, r = unknown> = [l, operator, r];
export type inferTerminal<token extends string, $, args> = token extends keyof args | keyof $ ? resolve<token, $, args> : token extends keyof Ark ? Ark[token] : `#${token}` extends keyof $ ? resolve<`#${token}`, $, args> : token extends StringLiteral<infer text> ? text : token extends `${infer n extends number}` ? n : token extends BigintLiteral<infer b> ? b : token extends RegexLiteral<infer source> ? string.matching<source> : token extends DateLiteral<infer source> ? Date.literal<source> : tryInferSubmoduleReference<$, token>;
export type inferTerminal<token extends string, $, args> = token extends keyof args | keyof $ ? resolve<token, $, args> : token extends keyof ArkAmbient.$ ? resolve<token, ArkAmbient.$, args> : `#${token}` extends keyof $ ? resolve<`#${token}`, $, args> : token extends StringLiteral<infer text> ? text : token extends `${infer n extends number}` ? n : token extends BigintLiteral<infer b> ? b : token extends RegexLiteral<infer source> ? string.matching<source> : token extends DateLiteral<infer source> ? Date.literal<source> : tryInferSubmoduleReference<$, token>;
export {};
import type { writeNonStructuralOperandMessage } from "@ark/schema";
import type { ErrorMessage, typeToString } from "@ark/util";
import type { inferAstRoot } from "./infer.js";
import type { validateAst } from "./validate.js";
import type { inferAstRoot } from "./infer.ts";
import type { validateAst } from "./validate.ts";
export type validateKeyof<operandAst, $, args> = inferAstRoot<operandAst, $, args> extends infer data ? [
data
] extends [object] ? validateAst<operandAst, $, args> : ErrorMessage<writeNonStructuralOperandMessage<"keyof", typeToString<data>>> : never;
import type { Stringifiable } from "@ark/util";
import type { Comparator } from "../string/reduce/shared.js";
import type { InfixExpression, PostfixExpression } from "./infer.js";
import type { Comparator } from "../string/reduce/shared.ts";
import type { InfixExpression, PostfixExpression } from "./infer.ts";
export type astToString<ast> = ast extends PostfixExpression<infer operator, infer operand> ? operator extends "[]" ? `${astToString<operand>}[]` : never : ast extends InfixExpression<infer operator, infer l, infer r> ? operator extends "&" | "|" | "%" | Comparator ? `${astToString<l>} ${operator} ${astToString<r>}` : never : ast extends Stringifiable ? `${ast extends bigint ? `${ast}n` : ast}` : "...";
import type { arkKind, GenericParamAst, PrivateDeclaration, writeMissingSubmoduleAccessMessage, writeUnsatisfiedParameterConstraintMessage } from "@ark/schema";
import type { anyOrNever, array, BigintLiteral, charsAfterFirst, Completion, ErrorMessage, typeToString, writeMalformedNumericLiteralMessage } from "@ark/util";
import type { Generic } from "../../generic.js";
import type { Comparator } from "../string/reduce/shared.js";
import type { writeInvalidGenericArgCountMessage } from "../string/shift/operand/genericArgs.js";
import type { UnitLiteral } from "../string/shift/operator/default.js";
import type { parseString } from "../string/string.js";
import type { validateRange } from "./bounds.js";
import type { validateDefault } from "./default.js";
import type { validateDivisor } from "./divisor.js";
import type { GenericInstantiationAst, inferAstRoot, InfixExpression, PostfixExpression } from "./infer.js";
import type { validateKeyof } from "./keyof.js";
import type { astToString } from "./utils.js";
import type { Generic } from "../../generic.ts";
import type { Comparator } from "../string/reduce/shared.ts";
import type { writeInvalidGenericArgCountMessage } from "../string/shift/operand/genericArgs.ts";
import type { UnitLiteral } from "../string/shift/operator/default.ts";
import type { parseString } from "../string/string.ts";
import type { validateRange } from "./bounds.ts";
import type { validateDefault } from "./default.ts";
import type { validateDivisor } from "./divisor.ts";
import type { GenericInstantiationAst, inferAstRoot, InfixExpression, PostfixExpression } from "./infer.ts";
import type { validateKeyof } from "./keyof.ts";
import type { astToString } from "./utils.ts";
export type validateAst<ast, $, args> = ast extends string ? validateStringAst<ast, $> : 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>>> & {

@@ -25,3 +25,3 @@ ast: ast;

[arkKind]: "module";
} ? ErrorMessage<writeMissingSubmoduleAccessMessage<def>> : undefined : def extends ErrorMessage ? def : undefined;
} ? "$root" extends keyof $[alias] ? undefined : ErrorMessage<writeMissingSubmoduleAccessMessage<def>> : undefined : def extends ErrorMessage ? def : undefined;
export type maybeExtractAlias<def extends string, $> = def extends keyof $ ? def : `#${def}` extends keyof $ ? `#${def}` : null;

@@ -28,0 +28,0 @@ 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;

import type { BaseRoot } from "@ark/schema";
import { type requireKeys } from "@ark/util";
import type { LimitLiteral } from "../../../ast.js";
import type { ParseContext } from "../../../scope.js";
import type { InfixOperator } from "../../semantic/infer.js";
import type { Scanner } from "../shift/scanner.js";
import { type Comparator, type MinComparator, type OpenLeftBound, type StringifiablePrefixOperator } from "./shared.js";
import type { LimitLiteral } from "../../../ast.ts";
import type { ParseContext } from "../../../scope.ts";
import type { InfixOperator } from "../../semantic/infer.ts";
import type { Scanner } from "../shift/scanner.ts";
import { type Comparator, type MinComparator, type OpenLeftBound, type StringifiablePrefixOperator } from "./shared.ts";
type BranchState = {

@@ -16,5 +16,2 @@ prefixes: StringifiablePrefixOperator[];

export declare class DynamicState {
readonly scanner: Scanner;
readonly ctx: ParseContext;
readonly defaultable: boolean;
root: BaseRoot<any> | undefined;

@@ -24,2 +21,5 @@ branches: BranchState;

groups: BranchState[];
scanner: Scanner;
ctx: ParseContext;
defaultable: boolean;
constructor(scanner: Scanner, ctx: ParseContext, defaultable: boolean);

@@ -26,0 +26,0 @@ error(message: string): never;

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

export class DynamicState {
scanner;
ctx;
defaultable;
// set root type to `any` so that all constraints can be applied

@@ -21,2 +18,5 @@ root;

groups = [];
scanner;
ctx;
defaultable;
constructor(scanner, ctx, defaultable) {

@@ -23,0 +23,0 @@ this.scanner = scanner;

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

import type { LimitLiteral } from "../../../ast.js";
import type { LimitLiteral } from "../../../ast.ts";
export type StringifiablePrefixOperator = "keyof";

@@ -3,0 +3,0 @@ export declare const minComparators: {

import type { Completion, ErrorMessage, defined } from "@ark/util";
import type { LimitLiteral } from "../../../ast.js";
import type { Scanner } from "../shift/scanner.js";
import type { Comparator, InvertedComparators, MaxComparator, MinComparator, OpenLeftBound, StringifiablePrefixOperator, writeMultipleLeftBoundsMessage, writeOpenRangeMessage, writeUnclosedGroupMessage, writeUnmatchedGroupCloseMessage, writeUnpairableComparatorMessage } from "./shared.js";
import type { LimitLiteral } from "../../../ast.ts";
import type { Scanner } from "../shift/scanner.ts";
import type { Comparator, InvertedComparators, MaxComparator, MinComparator, OpenLeftBound, StringifiablePrefixOperator, writeMultipleLeftBoundsMessage, writeOpenRangeMessage, writeUnclosedGroupMessage, writeUnmatchedGroupCloseMessage, writeUnpairableComparatorMessage } from "./shared.ts";
export type StaticState = {

@@ -21,3 +21,3 @@ root: unknown;

export declare namespace state {
export type initialize<def extends string> = from<{
type initialize<def extends string> = from<{
root: undefined;

@@ -30,3 +30,3 @@ branches: initialBranches;

}>;
export type error<message extends string> = from<{
type error<message extends string> = from<{
root: ErrorMessage<message>;

@@ -39,3 +39,3 @@ branches: initialBranches;

}>;
export type completion<text extends string> = from<{
type completion<text extends string> = from<{
root: Completion<text>;

@@ -55,3 +55,3 @@ branches: initialBranches;

type updateScanned<previousScanned extends string, previousUnscanned extends string, updatedUnscanned extends string> = previousUnscanned extends `${infer justScanned}${updatedUnscanned}` ? `${previousScanned}${justScanned}` : previousScanned;
export type setRoot<s extends StaticState, root, unscanned extends string> = from<{
type setRoot<s extends StaticState, root, unscanned extends string> = from<{
root: root;

@@ -64,3 +64,3 @@ branches: s["branches"];

}>;
export type addPrefix<s extends StaticState, prefix extends StringifiablePrefixOperator, unscanned extends string> = from<{
type addPrefix<s extends StaticState, prefix extends StringifiablePrefixOperator, unscanned extends string> = from<{
root: s["root"];

@@ -78,3 +78,3 @@ branches: {

}>;
export type reduceBranch<s extends StaticState, token extends "|" | "&", unscanned extends string> = s["branches"]["leftBound"] extends {} ? openRangeError<s["branches"]["leftBound"]> : from<{
type reduceBranch<s extends StaticState, token extends "|" | "&", unscanned extends string> = s["branches"]["leftBound"] extends {} ? openRangeError<s["branches"]["leftBound"]> : from<{
root: undefined;

@@ -92,3 +92,3 @@ branches: {

}>;
export type reduceLeftBound<s extends StaticState, limit extends LimitLiteral, comparator extends Comparator, unscanned extends string> = comparator extends "<" | "<=" ? s["branches"]["leftBound"] extends {} ? state.error<writeMultipleLeftBoundsMessage<s["branches"]["leftBound"]["limit"], s["branches"]["leftBound"]["comparator"], limit, InvertedComparators[comparator]>> : from<{
type reduceLeftBound<s extends StaticState, limit extends LimitLiteral, comparator extends Comparator, unscanned extends string> = comparator extends "<" | "<=" ? s["branches"]["leftBound"] extends {} ? state.error<writeMultipleLeftBoundsMessage<s["branches"]["leftBound"]["limit"], s["branches"]["leftBound"]["comparator"], limit, InvertedComparators[comparator]>> : from<{
root: undefined;

@@ -109,3 +109,3 @@ branches: {

}> : state.error<writeUnpairableComparatorMessage<comparator>>;
export type reduceRange<s extends StaticState, minLimit extends LimitLiteral, minComparator extends MinComparator, maxComparator extends MaxComparator, maxLimit extends LimitLiteral, unscanned extends string> = state.from<{
type reduceRange<s extends StaticState, minLimit extends LimitLiteral, minComparator extends MinComparator, maxComparator extends MaxComparator, maxLimit extends LimitLiteral, unscanned extends string> = state.from<{
root: [minLimit, minComparator, [s["root"], maxComparator, maxLimit]];

@@ -123,3 +123,3 @@ branches: {

}>;
export type reduceSingleBound<s extends StaticState, comparator extends Comparator, limit extends number | string, unscanned extends string> = state.from<{
type reduceSingleBound<s extends StaticState, comparator extends Comparator, limit extends number | string, unscanned extends string> = state.from<{
root: [s["root"], comparator, limit];

@@ -147,3 +147,3 @@ branches: {

];
export type finalizeGroup<s extends StaticState, unscanned extends string> = s["branches"]["leftBound"] extends {} ? openRangeError<s["branches"]["leftBound"]> : s["groups"] extends popGroup<infer stack, infer top> ? from<{
type finalizeGroup<s extends StaticState, unscanned extends string> = s["branches"]["leftBound"] extends {} ? openRangeError<s["branches"]["leftBound"]> : s["groups"] extends popGroup<infer stack, infer top> ? from<{
groups: stack;

@@ -156,3 +156,3 @@ branches: top;

}> : state.error<writeUnmatchedGroupCloseMessage<unscanned>>;
export type reduceGroupOpen<s extends StaticState, unscanned extends string> = from<{
type reduceGroupOpen<s extends StaticState, unscanned extends string> = from<{
groups: [...s["groups"], s["branches"]];

@@ -165,3 +165,3 @@ branches: initialBranches;

}>;
export type finalize<s extends StaticState, finalizer extends Scanner.FinalizingLookahead> = s["groups"] extends [] ? s["branches"]["leftBound"] extends {} ? openRangeError<s["branches"]["leftBound"]> : from<{
type finalize<s extends StaticState, finalizer extends Scanner.FinalizingLookahead> = s["groups"] extends [] ? s["branches"]["leftBound"] extends {} ? openRangeError<s["branches"]["leftBound"]> : from<{
root: mergeToUnion<s>;

@@ -175,7 +175,7 @@ groups: s["groups"];

type openRangeError<range extends defined<BranchState["leftBound"]>> = state.error<writeOpenRangeMessage<range["limit"], range["comparator"]>>;
export type previousOperator<s extends StaticState> = s["branches"]["leftBound"] extends {} ? s["branches"]["leftBound"]["comparator"] : s["branches"]["prefixes"] extends ([
type previousOperator<s extends StaticState> = s["branches"]["leftBound"] extends {} ? s["branches"]["leftBound"]["comparator"] : s["branches"]["prefixes"] extends ([
...unknown[],
infer tail extends string
]) ? tail : s["branches"]["intersection"] extends {} ? "&" : s["branches"]["union"] extends {} ? "|" : undefined;
export type scanTo<s extends StaticState, unscanned extends string> = from<{
type scanTo<s extends StaticState, unscanned extends string> = from<{
root: s["root"];

@@ -188,6 +188,5 @@ branches: s["branches"];

}>;
export type from<s extends StaticState> = s;
export type branchesFrom<b extends BranchState> = b;
export {};
type from<s extends StaticState> = s;
type branchesFrom<b extends BranchState> = b;
}
export {};

@@ -1,6 +0,5 @@

import type { DateLiteral } from "../../../../ast.js";
import type { DateLiteral } from "../../../../ast.ts";
export declare const isDateLiteral: (value: unknown) => value is DateLiteral;
export declare const isValidDate: (d: Date) => boolean;
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,2 +10,1 @@ 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,4 +0,4 @@

import type { DynamicState } from "../../reduce/dynamic.js";
import type { StaticState, state } from "../../reduce/static.js";
import type { Scanner } from "../scanner.js";
import type { DynamicState } from "../../reduce/dynamic.ts";
import type { StaticState, state } from "../../reduce/static.ts";
import type { Scanner } from "../scanner.ts";
export type StringLiteral<Text extends string = string> = DoubleQuotedStringLiteral<Text> | SingleQuotedStringLiteral<Text>;

@@ -5,0 +5,0 @@ export type DoubleQuotedStringLiteral<Text extends string = string> = `"${Text}"`;

import type { BaseRoot, GenericAst, genericParamNames, GenericRoot } from "@ark/schema";
import type { array, ErrorMessage, join } from "@ark/util";
import type { DynamicState } from "../../reduce/dynamic.js";
import { writeUnclosedGroupMessage } from "../../reduce/shared.js";
import type { state, StaticState } from "../../reduce/static.js";
import type { parseUntilFinalizer } from "../../string.js";
import type { DynamicState } from "../../reduce/dynamic.ts";
import { writeUnclosedGroupMessage } from "../../reduce/shared.ts";
import type { state, StaticState } from "../../reduce/static.ts";
import type { parseUntilFinalizer } from "../../string.ts";
export declare const parseGenericArgs: (name: string, g: GenericRoot, s: DynamicState) => BaseRoot[];

@@ -8,0 +8,0 @@ export type parseGenericArgs<name extends string, g extends GenericAst, unscanned extends string, $, args> = _parseGenericArgs<name, g, unscanned, $, args, [], []>;

import { type WhiteSpaceToken } from "@ark/util";
import type { DynamicState } from "../../reduce/dynamic.js";
import type { StaticState, state } from "../../reduce/static.js";
import type { BaseCompletions } from "../../string.js";
import type { Scanner } from "../scanner.js";
import { parseEnclosed, type EnclosingQuote, type EnclosingStartToken } from "./enclosed.js";
import { parseUnenclosed } from "./unenclosed.js";
import type { DynamicState } from "../../reduce/dynamic.ts";
import type { StaticState, state } from "../../reduce/static.ts";
import type { BaseCompletions } from "../../string.ts";
import type { Scanner } from "../scanner.ts";
import { parseEnclosed, type EnclosingQuote, type EnclosingStartToken } from "./enclosed.ts";
import { parseUnenclosed } from "./unenclosed.ts";
export declare const parseOperand: (s: DynamicState) => void;
export type parseOperand<s extends StaticState, $, args> = s["unscanned"] extends Scanner.shift<infer lookahead, infer unscanned> ? lookahead extends "(" ? state.reduceGroupOpen<s, unscanned> : lookahead extends EnclosingStartToken ? parseEnclosed<s, lookahead, unscanned> : lookahead extends WhiteSpaceToken ? parseOperand<state.scanTo<s, unscanned>, $, args> : lookahead extends "d" ? unscanned extends (Scanner.shift<infer enclosing extends EnclosingQuote, infer nextUnscanned>) ? parseEnclosed<s, `d${enclosing}`, nextUnscanned> : parseUnenclosed<s, $, args> : parseUnenclosed<s, $, args> : state.completion<`${s["scanned"]}${BaseCompletions<$, args>}`>;

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

import { BaseRoot, writeUnresolvableMessage, type GenericAst, type GenericRoot, type arkKind, type genericParamNames, type resolvableReferenceIn, type resolveReference, type writeNonSubmoduleDotMessage } from "@ark/schema";
import { writeUnresolvableMessage, type BaseRoot, type GenericAst, type GenericRoot, type arkKind, type genericParamNames, type resolvableReferenceIn, type resolveReference, type writeNonSubmoduleDotMessage } from "@ark/schema";
import { type BigintLiteral, type Completion, type ErrorMessage, type anyOrNever, type join } from "@ark/util";
import type { Ark } from "../../../../ark.js";
import type { GenericInstantiationAst } from "../../../semantic/infer.js";
import type { DynamicState } from "../../reduce/dynamic.js";
import type { StaticState, state } from "../../reduce/static.js";
import type { BaseCompletions } from "../../string.js";
import type { Scanner } from "../scanner.js";
import { parseGenericArgs, writeInvalidGenericArgCountMessage, type ParsedArgs } from "./genericArgs.js";
import type { ArkAmbient } from "arktype/config";
import type { GenericInstantiationAst } from "../../../semantic/infer.ts";
import type { DynamicState } from "../../reduce/dynamic.ts";
import type { StaticState, state } from "../../reduce/static.ts";
import type { BaseCompletions } from "../../string.ts";
import type { Scanner } from "../scanner.ts";
import { parseGenericArgs, writeInvalidGenericArgCountMessage, type ParsedArgs } from "./genericArgs.ts";
export declare const parseUnenclosed: (s: DynamicState) => void;
export type parseUnenclosed<s extends StaticState, $, args> = Scanner.shiftUntilNextTerminator<s["unscanned"]> extends (Scanner.shiftResult<infer token, infer unscanned>) ? token extends "keyof" ? state.addPrefix<s, "keyof", unscanned> : tryResolve<s, token, $, args> extends infer result ? result extends ErrorMessage<infer message> ? state.error<message> : result extends resolvableReferenceIn<$> ? parseResolution<s, unscanned, result, resolveReference<result, $>, $, args> : result extends resolvableReferenceIn<Ark> ? parseResolution<s, unscanned, result, resolveReference<result, Ark>, $, args> : state.setRoot<s, result, unscanned> : never : never;
export type parseUnenclosed<s extends StaticState, $, args> = Scanner.shiftUntilNextTerminator<s["unscanned"]> extends (Scanner.shiftResult<infer token, infer unscanned>) ? token extends "keyof" ? state.addPrefix<s, "keyof", unscanned> : tryResolve<s, token, $, args> extends infer result ? result extends ErrorMessage<infer message> ? state.error<message> : result extends resolvableReferenceIn<$> ? parseResolution<s, unscanned, result, resolveReference<result, $>, $, args> : result extends resolvableReferenceIn<ArkAmbient.$> ? parseResolution<s, unscanned, result, resolveReference<result, ArkAmbient.$>, $, args> : state.setRoot<s, result, unscanned> : never : never;
type parseResolution<s extends StaticState, unscanned extends string, alias extends string, resolution, $, args> = [

@@ -18,3 +18,5 @@ resolution

]>>;
type tryResolve<s extends StaticState, token extends string, $, args> = token extends keyof Ark ? token : token extends keyof $ ? token : `#${token}` extends keyof $ ? token : token extends keyof args ? token : token extends `${number}` ? token : token extends BigintLiteral ? token : token extends (`${infer submodule extends (keyof $ | keyof Ark) & string}.${infer reference}`) ? tryResolveSubmodule<token, submodule, reference, s, $ & Ark, [submodule]> : unresolvableError<s, token, $, args, []>;
type tryResolve<s extends StaticState, token extends string, $, args> = token extends keyof ArkAmbient.$ ? token : token extends keyof $ ? token : `#${token}` extends keyof $ ? token : token extends keyof args ? token : token extends `${number}` ? token : token extends BigintLiteral ? token : token extends (`${infer submodule extends (keyof $ | keyof ArkAmbient.$) & string}.${infer reference}`) ? tryResolveSubmodule<token, submodule, reference, s, $ & ArkAmbient.$, [
submodule
]> : unresolvableError<s, token, $, args, []>;
type tryResolveSubmodule<token, submodule extends keyof $ & string, reference extends string, s extends StaticState, $, submodulePath extends string[]> = $[submodule] extends {

@@ -21,0 +23,0 @@ [arkKind]: "module";

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

import { BaseRoot, hasArkKind, writeUnresolvableMessage } from "@ark/schema";
import { hasArkKind, writeUnresolvableMessage } from "@ark/schema";
import { printable, throwParseError, tryParseWellFormedBigint, tryParseWellFormedNumber } from "@ark/util";

@@ -30,3 +30,3 @@ import { writePrefixedPrivateReferenceMessage } from "../../../semantic/validate.js";

const resolution = s.ctx.$.maybeResolve(token);
if (resolution instanceof BaseRoot)
if (hasArkKind(resolution, "root"))
return resolution;

@@ -33,0 +33,0 @@ if (resolution === undefined)

import { type BaseRoot, type BoundKind } from "@ark/schema";
import { type keySet } from "@ark/util";
import type { LimitLiteral } from "../../../../ast.js";
import type { astToString } from "../../../semantic/utils.js";
import type { DynamicState, DynamicStateWithRoot } from "../../reduce/dynamic.js";
import { writeUnpairableComparatorMessage, type Comparator, type InvertedComparators, type MaxComparator } from "../../reduce/shared.js";
import type { StaticState, state } from "../../reduce/static.js";
import type { parseOperand } from "../operand/operand.js";
import type { Scanner } from "../scanner.js";
import type { LimitLiteral } from "../../../../ast.ts";
import type { astToString } from "../../../semantic/utils.ts";
import type { DynamicState, DynamicStateWithRoot } from "../../reduce/dynamic.ts";
import { writeUnpairableComparatorMessage, type Comparator, type InvertedComparators, type MaxComparator } from "../../reduce/shared.ts";
import type { StaticState, state } from "../../reduce/static.ts";
import type { parseOperand } from "../operand/operand.ts";
import type { Scanner } from "../scanner.ts";
export declare const parseBound: (s: DynamicStateWithRoot, start: ComparatorStartChar) => void;
export type parseBound<s extends StaticState, start extends ComparatorStartChar, unscanned extends string, $, args> = shiftComparator<start, unscanned> extends infer shiftResultOrError ? shiftResultOrError extends (Scanner.shiftResult<infer comparator extends Comparator, infer nextUnscanned>) ? s["root"] extends `${infer limit extends LimitLiteral}` ? state.reduceLeftBound<s, limit, comparator, nextUnscanned> : parseRightBound<state.scanTo<s, nextUnscanned>, comparator, $, args> : shiftResultOrError : never;
declare const oneCharComparators: {
readonly "<": true;
readonly ">": true;
};
type OneCharComparator = keyof typeof oneCharComparators;
type OneCharComparator = ">" | "<";
export type ComparatorStartChar = Comparator extends `${infer char}${string}` ? char : never;

@@ -18,0 +14,0 @@ export declare const comparatorStartChars: keySet<ComparatorStartChar>;

@@ -22,6 +22,2 @@ import { $ark, writeUnboundableMessage } from "@ark/schema";

};
const oneCharComparators = {
"<": true,
">": true
};
export const comparatorStartChars = {

@@ -28,0 +24,0 @@ "<": 1,

import type { BaseRoot } from "@ark/schema";
import { type BigintLiteral, type ErrorMessage, type NumberLiteral, type trim } from "@ark/util";
import type { DateLiteral } from "../../../../ast.js";
import type { DynamicStateWithRoot } from "../../reduce/dynamic.js";
import type { StringLiteral } from "../operand/enclosed.js";
declare const unitLiteralKeywords: {
readonly null: null;
readonly undefined: undefined;
readonly true: true;
readonly false: false;
};
type UnitLiteralKeyword = keyof typeof unitLiteralKeywords;
import type { DateLiteral } from "../../../../ast.ts";
import type { DynamicStateWithRoot } from "../../reduce/dynamic.ts";
import type { StringLiteral } from "../operand/enclosed.ts";
type UnitLiteralKeyword = "null" | "undefined" | "true" | "false";
export type UnitLiteral = StringLiteral | BigintLiteral | NumberLiteral | DateLiteral | UnitLiteralKeyword;

@@ -14,0 +8,0 @@ export type ParsedDefault = [BaseRoot, "=", unknown];

import { throwParseError } from "@ark/util";
const unitLiteralKeywords = {
null: null,
undefined,
true: true,
false: false
};
export const parseDefault = (s) => {

@@ -9,0 +3,0 @@ if (!s.defaultable)

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

import type { DynamicStateWithRoot } from "../../reduce/dynamic.js";
import type { StaticState, state } from "../../reduce/static.js";
import type { Scanner } from "../scanner.js";
import type { DynamicStateWithRoot } from "../../reduce/dynamic.ts";
import type { StaticState, state } from "../../reduce/static.ts";
import type { Scanner } from "../scanner.ts";
export declare const parseDivisor: (s: DynamicStateWithRoot) => void;

@@ -5,0 +5,0 @@ export type parseDivisor<s extends StaticState, unscanned extends string> = Scanner.shiftUntilNextTerminator<Scanner.skipWhitespace<unscanned>> extends (Scanner.shiftResult<infer scanned, infer nextUnscanned>) ? scanned extends `${infer divisor extends number}` ? divisor extends 0 ? state.error<writeInvalidDivisorMessage<0>> : state.setRoot<s, [s["root"], "%", divisor], nextUnscanned> : state.error<writeInvalidDivisorMessage<scanned>> : never;

import { type WhiteSpaceToken } from "@ark/util";
import type { DynamicStateWithRoot } from "../../reduce/dynamic.js";
import type { StaticState, state } from "../../reduce/static.js";
import { Scanner } from "../scanner.js";
import { parseBound, type ComparatorStartChar } from "./bounds.js";
import { parseDivisor } from "./divisor.js";
import type { DynamicStateWithRoot } from "../../reduce/dynamic.ts";
import type { StaticState, state } from "../../reduce/static.ts";
import { Scanner } from "../scanner.ts";
import { parseBound, type ComparatorStartChar } from "./bounds.ts";
import { parseDivisor } from "./divisor.ts";
export declare const parseOperator: (s: DynamicStateWithRoot) => void;

@@ -8,0 +8,0 @@ export type parseOperator<s extends StaticState, $, args> = s["unscanned"] extends Scanner.shift<infer lookahead, infer unscanned> ? lookahead extends "[" ? unscanned extends Scanner.shift<"]", infer nextUnscanned> ? state.setRoot<s, [s["root"], "[]"], nextUnscanned> : state.error<incompleteArrayTokenMessage> : lookahead extends "|" | "&" ? state.reduceBranch<s, lookahead, unscanned> : lookahead extends ")" ? state.finalizeGroup<s, unscanned> : Scanner.lookaheadIsFinalizing<lookahead, unscanned> extends true ? state.finalize<state.scanTo<s, unscanned>, lookahead & Scanner.FinalizingLookahead> : lookahead extends ComparatorStartChar ? parseBound<s, lookahead, unscanned, $, args> : lookahead extends "%" ? parseDivisor<s, unscanned> : lookahead extends WhiteSpaceToken ? parseOperator<state.scanTo<s, unscanned>, $, args> : state.error<writeUnexpectedCharacterMessage<lookahead>> : state.finalize<s, "">;

import { type Dict, type EscapeToken, type WhiteSpaceToken } from "@ark/util";
import type { Comparator } from "../reduce/shared.js";
import type { Comparator } from "../reduce/shared.ts";
export declare class Scanner<lookahead extends string = string> {

@@ -23,12 +23,3 @@ private chars;

lookaheadIsIn<tokens extends Dict>(tokens: tokens): this is Scanner<Extract<keyof tokens, string>>;
}
export declare namespace Scanner {
type UntilCondition = (scanner: Scanner, shifted: string) => boolean;
type OnInputEndFn = (scanner: Scanner, shifted: string) => string;
type ShiftUntilOptions = {
onInputEnd?: OnInputEndFn;
};
const lookaheadIsTerminator: UntilCondition;
const lookaheadIsNotWhitespace: UntilCondition;
const terminatingChars: {
static terminatingChars: {
readonly "<": true;

@@ -46,4 +37,3 @@ readonly ">": true;

};
type TerminatingChar = keyof typeof terminatingChars;
const finalizingLookaheads: {
static finalizingLookaheads: {
readonly ">": true;

@@ -54,8 +44,18 @@ readonly ",": true;

};
type FinalizingLookahead = keyof typeof finalizingLookaheads;
static lookaheadIsTerminator: Scanner.UntilCondition;
static lookaheadIsNotWhitespace: Scanner.UntilCondition;
static lookaheadIsFinalizing: (lookahead: string, unscanned: string) => lookahead is ">" | "," | "=";
}
export declare namespace Scanner {
type lookaheadIsFinalizing<lookahead extends string, unscanned extends string> = lookahead extends ">" ? unscanned extends `=${infer nextUnscanned}` ? nextUnscanned extends `=${string}` ? true : false : Scanner.skipWhitespace<unscanned> extends ("" | `${TerminatingChar}${string}`) ? true : false : lookahead extends "=" ? unscanned extends `=${string}` ? false : true : lookahead extends "," ? true : false;
type UntilCondition = (scanner: Scanner, shifted: string) => boolean;
type OnInputEndFn = (scanner: Scanner, shifted: string) => string;
type ShiftUntilOptions = {
onInputEnd?: OnInputEndFn;
};
type TerminatingChar = keyof typeof Scanner.terminatingChars;
type FinalizingLookahead = keyof typeof Scanner.finalizingLookaheads;
type InfixToken = Comparator | "|" | "&" | "%" | ":" | "=>";
type PostfixToken = "[]";
type OperatorToken = InfixToken | PostfixToken;
const lookaheadIsFinalizing: (lookahead: string, unscanned: string) => lookahead is ">" | "," | "=";
type lookaheadIsFinalizing<lookahead extends string, unscanned extends string> = lookahead extends ">" ? unscanned extends `=${infer nextUnscanned}` ? nextUnscanned extends `=${string}` ? true : false : Scanner.skipWhitespace<unscanned> extends ("" | `${TerminatingChar}${string}`) ? true : false : lookahead extends "=" ? unscanned extends `=${string}` ? false : true : lookahead extends "," ? true : false;
type shift<lookahead extends string, unscanned extends string> = `${lookahead}${unscanned}`;

@@ -62,0 +62,0 @@ type shiftUntil<unscanned extends string, terminator extends string, scanned extends string = ""> = unscanned extends shift<infer lookahead, infer nextUnscanned> ? lookahead extends terminator ? scanned extends `${infer base}${EscapeToken}` ? shiftUntil<nextUnscanned, terminator, `${base}${lookahead}`> : [scanned, unscanned] : shiftUntil<nextUnscanned, terminator, `${scanned}${lookahead}`> : [scanned, ""];

@@ -66,7 +66,3 @@ import { escapeToken, isKeyOf, whiteSpaceTokens } from "@ark/util";

}
}
(function (Scanner) {
Scanner.lookaheadIsTerminator = (scanner) => scanner.lookahead in Scanner.terminatingChars;
Scanner.lookaheadIsNotWhitespace = (scanner) => !(scanner.lookahead in whiteSpaceTokens);
Scanner.terminatingChars = {
static terminatingChars = {
"<": true,

@@ -84,3 +80,3 @@ ">": true,

};
Scanner.finalizingLookaheads = {
static finalizingLookaheads = {
">": true,

@@ -91,3 +87,5 @@ ",": true,

};
Scanner.lookaheadIsFinalizing = (lookahead, unscanned) => lookahead === ">" ?
static lookaheadIsTerminator = (scanner) => scanner.lookahead in this.terminatingChars;
static lookaheadIsNotWhitespace = (scanner) => !(scanner.lookahead in whiteSpaceTokens);
static lookaheadIsFinalizing = (lookahead, unscanned) => lookahead === ">" ?
unscanned[0] === "=" ?

@@ -105,2 +103,2 @@ // >== would only occur in an expression like Array<number>==5

: lookahead === ",";
})(Scanner || (Scanner = {}));
}
import type { BaseRoot, resolvableReferenceIn } from "@ark/schema";
import { type ErrorMessage } from "@ark/util";
import type { Ark } from "../../ark.js";
import type { inferAstRoot } from "../semantic/infer.js";
import type { DynamicState, DynamicStateWithRoot } from "./reduce/dynamic.js";
import type { StringifiablePrefixOperator } from "./reduce/shared.js";
import type { state, StaticState } from "./reduce/static.js";
import type { parseOperand } from "./shift/operand/operand.js";
import { parseDefault, type ParsedDefault } from "./shift/operator/default.js";
import { writeUnexpectedCharacterMessage, type parseOperator } from "./shift/operator/operator.js";
import type { ArkAmbient } from "arktype/config";
import type { inferAstRoot } from "../semantic/infer.ts";
import type { DynamicState, DynamicStateWithRoot } from "./reduce/dynamic.ts";
import type { StringifiablePrefixOperator } from "./reduce/shared.ts";
import type { state, StaticState } from "./reduce/static.ts";
import type { parseOperand } from "./shift/operand/operand.ts";
import { parseDefault, type ParsedDefault } from "./shift/operator/default.ts";
import { writeUnexpectedCharacterMessage, type parseOperator } from "./shift/operator/operator.ts";
/**

@@ -20,3 +20,3 @@ * Try to parse the definition from right to left using the most common syntax.

export type inferString<def extends string, $, args> = inferAstRoot<parseString<def, $, args>, $, args>;
export type BaseCompletions<$, args, otherSuggestions extends string = never> = resolvableReferenceIn<$> | resolvableReferenceIn<Ark> | (keyof args & string) | StringifiablePrefixOperator | otherSuggestions;
export type BaseCompletions<$, args, otherSuggestions extends string = never> = resolvableReferenceIn<$> | resolvableReferenceIn<ArkAmbient.$> | (keyof args & string) | StringifiablePrefixOperator | otherSuggestions;
export type StringParseResult = BaseRoot | ParsedDefault;

@@ -23,0 +23,0 @@ export declare const fullStringParse: (s: DynamicState) => StringParseResult;

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 { distillConstrainableIn, distillOut, inferMorphOut, inferPredicate, Out } from "../ast.js";
import type { inferIntersection } from "../intersect.js";
import type { ParseContext } from "../scope.js";
import type { inferDefinition, validateDefinition } from "./definition.js";
import type { InfixOperator, PostfixExpression } from "./semantic/infer.js";
import { writeMissingRightOperandMessage } from "./string/shift/operand/unenclosed.js";
import type { BaseCompletions } from "./string/string.js";
import type { distillConstrainableIn, distillOut, inferMorphOut, inferPredicate, Out } from "../ast.ts";
import type { inferIntersection } from "../intersect.ts";
import type { ParseContext } from "../scope.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";
export declare const parseTuple: (def: array, ctx: ParseContext) => BaseRoot;

@@ -11,0 +11,0 @@ export declare const parseTupleLiteral: (def: array, ctx: ParseContext) => BaseRoot;

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

spread.optionals.forEach(node => appendElement(base, "optional", node));
spread.variadic && appendElement(base, "variadic", spread.variadic);
if (spread.variadic)
appendElement(base, "variadic", spread.variadic);
spread.postfix.forEach(node => appendElement(base, "required", node));

@@ -94,0 +95,0 @@ return base;

import { BaseScope, type AliasDefEntry, type ArkScopeConfig, type BaseNode, type BaseRoot, type GenericArgResolutions, type GenericAst, type GenericParamAst, type InternalResolutions, type NodeKind, type NodeParseOptions, type NodeSchema, type PreparsedNodeResolution, type PrivateDeclaration, type RootKind, type RootSchema, type arkKind, type destructuredExportContext, type destructuredImportContext, type exportedNameOf, type nodeOfKind, type reducibleKindOf, type toInternalScope, type writeDuplicateAliasError } from "@ark/schema";
import { type ErrorType, type Json, type anyOrNever, type array, type flattenListable, type nominal, type show } from "@ark/util";
import type { Ark } from "./ark.js";
import { parseGenericParams, type GenericDeclaration, type GenericHktParser, type ParameterString, type baseGenericConstraints, type parseValidGenericParams } from "./generic.js";
import type { BoundModule, Module, Submodule, instantiateExport } from "./module.js";
import { type inferDefinition, type validateDefinition } from "./parser/definition.js";
import type { ParsedDefault } from "./parser/string/shift/operator/default.js";
import { InternalTypeParser, type DeclarationParser, type DefinitionParser, type Type, type TypeParser } from "./type.js";
import { type ErrorType, type Json, type anyOrNever, type array, type flattenListable, type inferred, type noSuggest, type nominal, type show } from "@ark/util";
import type { ArkAmbient } from "./config.ts";
import { parseGenericParams, type GenericDeclaration, type GenericHktParser, type ParameterString, type baseGenericConstraints, type parseValidGenericParams } from "./generic.ts";
import type { type } from "./keywords/ark.ts";
import type { BoundModule, Module, Submodule, instantiateExport } from "./module.ts";
import { type inferDefinition, type validateDefinition } from "./parser/definition.ts";
import type { ParsedDefault } from "./parser/string/shift/operator/default.ts";
import { InternalTypeParser, type DeclarationParser, type DefinitionParser, type Type, type TypeParser } from "./type.ts";
export type ScopeParser = <const def>(def: validateScope<def>, config?: ArkScopeConfig) => Scope<inferScope<def>>;
export type validateScope<def> = {
[k in keyof def]: parseScopeKey<k, def>["params"] extends infer params ? params extends array<GenericParamAst> ? params["length"] extends 0 ? def[k] extends Type.Any | PreparsedResolution ? def[k] : k extends PrivateDeclaration<infer name extends keyof def & string> ? ErrorType<writeDuplicateAliasError<name>> : validateDefinition<def[k], bootstrapAliases<def>, {}> : validateDefinition<def[k], bootstrapAliases<def>, baseGenericConstraints<params>> : params : never;
[k in keyof def]: k extends noSuggest ? unknown : parseScopeKey<k, def>["params"] extends infer params ? params extends array<GenericParamAst> ? params["length"] extends 0 ? def[k] extends Type.Any | PreparsedResolution ? def[k] : k extends PrivateDeclaration<infer name extends keyof def & string> ? ErrorType<writeDuplicateAliasError<name>> : validateDefinition<def[k], bootstrapAliases<def>, {}> : validateDefinition<def[k], bootstrapAliases<def>, baseGenericConstraints<params>> : params : never;
};

@@ -26,5 +27,5 @@ export type inferScope<def> = inferBootstrapped<bootstrapAliases<def>>;

t: infer g extends GenericAst;
} ? g : def[k] : def[k] extends (() => infer thunkReturn extends PreparsedResolution) ? thunkReturn extends {
} ? g : def[k] extends Module<infer $> ? Submodule<$> : def[k] : def[k] extends (() => infer thunkReturn extends PreparsedResolution) ? thunkReturn extends {
t: infer g extends GenericAst;
} ? g : thunkReturn : Def<def[k]>;
} ? g : thunkReturn extends Module<infer $> ? Submodule<$> : thunkReturn : Def<def[k]>;
} & {

@@ -35,5 +36,6 @@ [k in keyof def & GenericDeclaration as extractGenericName<k>]: GenericAst<parseValidGenericParams<extractGenericParameters<k>, bootstrapAliases<def>>, def[k], UnparsedScope>;

[name in keyof $]: $[name] extends Def<infer def> ? inferDefinition<def, $, {}> : $[name] extends {
t: GenericAst<infer params, infer def, infer body$>;
} ? GenericAst<params, def, body$ extends UnparsedScope ? $ : body$, $> : $[name] extends Module<infer exports> ? Submodule<exports> : never;
t: infer g extends GenericAst;
} ? bindGenericToScope<g, $> : $[name];
} & unknown;
export type bindGenericToScope<g extends GenericAst, $> = GenericAst<g["paramsAst"], g["bodyDef"], g["$"] extends UnparsedScope ? $ : g["$"], $>;
type extractGenericName<k> = k extends GenericDeclaration<infer name> ? name : never;

@@ -43,3 +45,5 @@ type extractGenericParameters<k> = k extends `${string}<${infer params}>` ? ParameterString<params> : never;

resolution
] extends [anyOrNever] ? resolution : resolution extends Def<infer def> ? inferDefinition<def, $, args> : resolution : never;
] extends [anyOrNever] ? resolution : resolution extends {
[inferred]: infer t;
} ? t : resolution extends Def<infer def> ? inferDefinition<def, $, args> : resolution : never;
export type moduleKeyOf<$> = {

@@ -52,3 +56,4 @@ [k in keyof $]: $[k] extends {

}[keyof $];
export type tryInferSubmoduleReference<$, token> = token extends `${infer submodule extends moduleKeyOf<$>}.${infer subalias}` ? subalias extends keyof $[submodule] ? $[submodule][subalias] : tryInferSubmoduleReference<$[submodule], subalias> : token extends (`${infer submodule extends moduleKeyOf<Ark>}.${infer subalias}`) ? subalias extends keyof Ark[submodule] ? Ark[submodule][subalias] : tryInferSubmoduleReference<Ark[submodule], subalias> : never;
type unwrapPreinferred<t> = t extends type.cast<infer inferred> ? inferred : t;
export type tryInferSubmoduleReference<$, token> = token extends `${infer submodule extends moduleKeyOf<$>}.${infer subalias}` ? subalias extends keyof $[submodule] ? unwrapPreinferred<$[submodule][subalias]> : tryInferSubmoduleReference<$[submodule], subalias> : token extends (`${infer submodule extends moduleKeyOf<ArkAmbient.$>}.${infer subalias}`) ? subalias extends keyof ArkAmbient.$[submodule] ? unwrapPreinferred<ArkAmbient.$[submodule][subalias]> : tryInferSubmoduleReference<ArkAmbient.$[submodule], subalias> : never;
export interface ParseContext extends TypeParseOptions {

@@ -63,2 +68,7 @@ $: InternalScope;

private parseCache;
preparseAlias(k: string, v: unknown): AliasDefEntry;
preparseRoot(def: unknown): unknown;
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);
parseRoot: (def: unknown, opts?: TypeParseOptions) => BaseRoot;
type: InternalTypeParser;

@@ -69,7 +79,2 @@ declare: () => {

define: (def: unknown) => unknown;
preparseAlias(k: string, v: unknown): AliasDefEntry;
preparseRoot(def: unknown): unknown;
parseRoot(def: unknown, opts?: TypeParseOptions): BaseRoot;
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);
}

@@ -76,0 +81,0 @@ export interface Scope<$ = {}> {

@@ -1,37 +0,3 @@

var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
var useValue = arguments.length > 2;
for (var i = 0; i < initializers.length; i++) {
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
}
return useValue ? value : void 0;
};
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
var _, done = false;
for (var i = decorators.length - 1; i >= 0; i--) {
var context = {};
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
if (kind === "accessor") {
if (result === void 0) continue;
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
if (_ = accept(result.get)) descriptor.get = _;
if (_ = accept(result.set)) descriptor.set = _;
if (_ = accept(result.init)) initializers.unshift(_);
}
else if (_ = accept(result)) {
if (kind === "field") initializers.unshift(_);
else descriptor[key] = _;
}
}
if (target) Object.defineProperty(target, contextIn.name, descriptor);
done = true;
};
import { BaseScope, hasArkKind, parseGeneric } from "@ark/schema";
import { bound, domainOf, hasDomain, isThunk, throwParseError } from "@ark/util";
import { domainOf, hasDomain, isThunk, throwParseError } from "@ark/util";
import { parseGenericParams } from "./generic.js";

@@ -45,84 +11,72 @@ import { parseObject, writeBadDefinitionTypeMessage } from "./parser/definition.js";

export const scope = ((def, config = {}) => new InternalScope(def, config));
let InternalScope = (() => {
let _classSuper = BaseScope;
let _instanceExtraInitializers = [];
let _parseRoot_decorators;
return class InternalScope extends _classSuper {
static {
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(_classSuper[Symbol.metadata] ?? null) : void 0;
_parseRoot_decorators = [bound];
__esDecorate(this, null, _parseRoot_decorators, { kind: "method", name: "parseRoot", static: false, private: false, access: { has: obj => "parseRoot" in obj, get: obj => obj.parseRoot }, metadata: _metadata }, null, _instanceExtraInitializers);
if (_metadata) Object.defineProperty(this, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
export class InternalScope extends BaseScope {
parseCache = {};
preparseAlias(k, v) {
const firstParamIndex = k.indexOf("<");
if (firstParamIndex === -1)
return [k, v];
if (k.at(-1) !== ">") {
throwParseError(`'>' must be the last character of a generic declaration in a scope`);
}
parseCache = (__runInitializers(this, _instanceExtraInitializers), {});
type = new InternalTypeParser(this);
declare = (() => ({
type: this.type
})).bind(this);
define = ((def) => def).bind(this);
preparseAlias(k, v) {
const firstParamIndex = k.indexOf("<");
if (firstParamIndex === -1)
return [k, v];
if (k.at(-1) !== ">") {
throwParseError(`'>' must be the last character of a generic declaration in a scope`);
const name = k.slice(0, firstParamIndex);
const paramString = k.slice(firstParamIndex + 1, -1);
return [
name,
// use a thunk definition for the generic so that we can parse
// constraints within the current scope
() => {
const params = parseGenericParams(paramString, {
$: this,
args: {}
});
const generic = parseGeneric(params, v, this);
return generic;
}
const name = k.slice(0, firstParamIndex);
const paramString = k.slice(firstParamIndex + 1, -1);
return [
name,
// use a thunk definition for the generic so that we can parse
// constraints within the current scope
() => {
const params = parseGenericParams(paramString, {
$: this,
args: {}
});
const generic = parseGeneric(params, v, this);
return generic;
}
];
}
preparseRoot(def) {
if (isThunk(def) && !hasArkKind(def, "generic"))
return def();
return def;
}
parseRoot(def, opts = {}) {
const node = this.parse(def, Object.assign(this.finalizeRootArgs(opts, () => node), { $: this })).bindScope(this);
return node;
}
parse(def, ctx, defaultable = false) {
if (typeof def === "string") {
if (ctx.args && Object.keys(ctx.args).some(k => def.includes(k))) {
// we can only rely on the cache if there are no contextual
// resolutions like "this" or generic args
return this.parseString(def, ctx, defaultable);
}
const contextKey = `${def}${defaultable}`;
return (this.parseCache[contextKey] ??= this.parseString(def, ctx, defaultable));
];
}
preparseRoot(def) {
if (isThunk(def) && !hasArkKind(def, "generic"))
return def();
return def;
}
parse(def, ctx, defaultable = false) {
if (typeof def === "string") {
if (ctx.args && Object.keys(ctx.args).some(k => def.includes(k))) {
// we can only rely on the cache if there are no contextual
// resolutions like "this" or generic args
return this.parseString(def, ctx, defaultable);
}
return hasDomain(def, "object") ?
parseObject(def, ctx)
: throwParseError(writeBadDefinitionTypeMessage(domainOf(def)));
const contextKey = `${def}${defaultable}`;
return (this.parseCache[contextKey] ??= this.parseString(def, ctx, defaultable));
}
parseString(def, ctx, defaultable) {
const aliasResolution = this.maybeResolveRoot(def);
if (aliasResolution)
return aliasResolution;
const aliasArrayResolution = def.endsWith("[]") ?
this.maybeResolveRoot(def.slice(0, -2))?.array()
: undefined;
if (aliasArrayResolution)
return aliasArrayResolution;
const s = new DynamicState(new Scanner(def), ctx, defaultable);
const node = fullStringParse(s);
if (s.finalizer === ">")
throwParseError(writeUnexpectedCharacterMessage(">"));
return node;
}
return hasDomain(def, "object") ?
parseObject(def, ctx)
: throwParseError(writeBadDefinitionTypeMessage(domainOf(def)));
}
parseString(def, ctx, defaultable) {
const aliasResolution = this.maybeResolveRoot(def);
if (aliasResolution)
return aliasResolution;
const aliasArrayResolution = def.endsWith("[]") ?
this.maybeResolveRoot(def.slice(0, -2))?.array()
: undefined;
if (aliasArrayResolution)
return aliasArrayResolution;
const s = new DynamicState(new Scanner(def), ctx, defaultable);
const node = fullStringParse(s);
if (s.finalizer === ">")
throwParseError(writeUnexpectedCharacterMessage(">"));
return node;
}
parseRoot = (def, opts = {}) => {
const node = this.parse(def, Object.assign(this.finalizeRootArgs(opts, () => node), { $: this })).bindScope(this);
return node;
};
})();
export { InternalScope };
type = new InternalTypeParser(this);
declare = () => ({
type: this.type
});
define = ((def) => def).bind(this);
}
export const Scope = InternalScope;
export const writeShallowCycleErrorMessage = (name, seen) => `Alias '${name}' has a shallow resolution cycle: ${[...seen, name].join(":")}`;
import type { ExactLength, ExclusiveNumericRangeSchema, exclusivizeRangeSchema, InclusiveNumericRangeSchema } from "@ark/schema";
import type { applyConstraint } from "../ast.js";
import type { ObjectType } from "./object.js";
import type { applyConstraint } from "../ast.ts";
import type { ObjectType } from "./object.ts";
interface Type<

@@ -5,0 +5,0 @@ /** @ts-ignore cast variance */

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

import type { ArkErrors, BaseRoot, Disjoint, MetaSchema, Morph, UndeclaredKeyBehavior } from "@ark/schema";
import type { anyOrNever, Callable, ErrorMessage, Json, unset } from "@ark/util";
import type { distillConstrainableIn, distillConstrainableOut, distillIn, distillOut, distillValidatedOut, inferMorphOut, inferPipes, inferred } from "../ast.js";
import type { inferIntersection } from "../intersect.js";
import type { Scope } from "../scope.js";
import type { inferTypeRoot, validateTypeRoot } from "../type.js";
import type { ArrayType } from "./array.js";
import type { instantiateType } from "./instantiate.js";
import type { ArkErrors, BaseRoot, Disjoint, JsonSchema, MetaSchema, Morph, UndeclaredKeyBehavior } from "@ark/schema";
import type { anyOrNever, Callable, ErrorMessage, inferred, Json, unset } from "@ark/util";
import type { distillConstrainableIn, distillConstrainableOut, distillIn, distillOut, distillValidatedOut, inferMorphOut, inferPipes } from "../ast.ts";
import type { inferIntersection } from "../intersect.ts";
import type { Scope } from "../scope.ts";
import type { inferTypeRoot, validateTypeRoot } from "../type.ts";
import type { ArrayType } from "./array.ts";
import type { instantiateType } from "./instantiate.ts";
/** @ts-ignore cast variance */

@@ -19,2 +19,3 @@ interface Type<out t = unknown, $ = {}> extends Callable<(data: unknown) => distillOut<t> | ArkErrors> {

json: Json;
toJsonSchema(): JsonSchema;
description: string;

@@ -21,0 +22,0 @@ expression: string;

import type { ExclusiveDateRangeSchema, exclusivizeRangeSchema, InclusiveDateRangeSchema } from "@ark/schema";
import type { applyConstraint } from "../ast.js";
import type { ObjectType } from "./object.js";
import type { applyConstraint } from "../ast.ts";
import type { ObjectType } from "./object.ts";
/** @ts-ignore cast variance */

@@ -5,0 +5,0 @@ interface Type<out t extends globalThis.Date = globalThis.Date, $ = {}> extends ObjectType<t, $> {

import type { anyOrNever, array } from "@ark/util";
import type { MorphAst } from "../ast.js";
import type { ArrayType } from "./array.js";
import type { DateType } from "./date.js";
import type { MorphType } from "./morph.js";
import type { NumberType } from "./number.js";
import type { ObjectType } from "./object.js";
import type { StringType } from "./string.js";
import type { ValidatorType } from "./validator.js";
import type { MorphAst } from "../ast.ts";
import type { ArrayType } from "./array.ts";
import type { DateType } from "./date.ts";
import type { MorphType } from "./morph.ts";
import type { NumberType } from "./number.ts";
import type { ObjectType } from "./object.ts";
import type { StringType } from "./string.ts";
import type { ValidatorType } from "./validator.ts";
export type instantiateType<t, $> = [

@@ -11,0 +11,0 @@ Extract<t, MorphAst>

import type { Predicate, PredicateCast } from "@ark/schema";
import type { applyConstraint, Out, To } from "../ast.js";
import type { inferPipe } from "../intersect.js";
import type { inferTypeRoot, validateTypeRoot } from "../type.js";
import type { BaseType } from "./base.js";
import type { applyConstraint, Out, To } from "../ast.ts";
import type { inferPipe } from "../intersect.ts";
import type { inferTypeRoot, validateTypeRoot } from "../type.ts";
import type { BaseType } from "./base.ts";
/** @ts-ignore cast variance */

@@ -7,0 +7,0 @@ interface Type<out t = unknown, $ = {}> extends BaseType<t, $> {

import type { Divisor, ExclusiveNumericRangeSchema, exclusivizeRangeSchema, InclusiveNumericRangeSchema } from "@ark/schema";
import type { applyConstraint } from "../ast.js";
import type { ValidatorType } from "./validator.js";
import type { applyConstraint } from "../ast.ts";
import type { ValidatorType } from "./validator.ts";
/** @ts-ignore cast variance */

@@ -5,0 +5,0 @@ interface Type<out t extends number = number, $ = {}> extends ValidatorType<t, $> {

import type { array, ErrorType, merge } from "@ark/util";
import type { type } from "../ark.js";
import type { arkKeyOf, getArkKey, toArkKey } from "../keys.js";
import type { inferTypeRoot, validateTypeRoot } from "../type.js";
import type { ArrayType } from "./array.js";
import type { instantiateType } from "./instantiate.js";
import type { ValidatorType } from "./validator.js";
import type { arkKeyOf, getArkKey, toArkKey } from "../keys.ts";
import type { type } from "../keywords/ark.ts";
import type { inferTypeRoot, validateTypeRoot } from "../type.ts";
import type { ArrayType } from "./array.ts";
import type { instantiateType } from "./instantiate.ts";
import type { ValidatorType } from "./validator.ts";
/** @ts-ignore cast variance */

@@ -9,0 +9,0 @@ interface Type<out t extends object = object, $ = {}> extends ValidatorType<t, $> {

import type { ExactLength, ExclusiveNumericRangeSchema, exclusivizeRangeSchema, InclusiveNumericRangeSchema, Pattern } from "@ark/schema";
import type { applyConstraint } from "../ast.js";
import type { ValidatorType } from "./validator.js";
import type { applyConstraint } from "../ast.ts";
import type { ValidatorType } from "./validator.ts";
/** @ts-ignore cast variance */

@@ -5,0 +5,0 @@ interface Type<out t extends string = string, $ = {}> extends ValidatorType<t, $> {

import type { Predicate, PredicateCast } from "@ark/schema";
import type { applyConstraint } from "../ast.js";
import type { BaseType } from "./base.js";
import type { instantiateType } from "./instantiate.js";
import type { applyConstraint } from "../ast.ts";
import type { BaseType } from "./base.ts";
import type { instantiateType } from "./instantiate.ts";
/** @ts-ignore cast variance */

@@ -6,0 +6,0 @@ interface Type<out t = unknown, $ = {}> extends BaseType<t, $> {

import { ArkErrors, BaseRoot, type MetaSchema, type Morph, type Predicate } from "@ark/schema";
import { Callable, type Constructor, type array, type conform } from "@ark/util";
import type { distillIn, distillOut } from "./ast.js";
import { type Generic, type ParameterString, type baseGenericConstraints, type parseValidGenericParams, type validateParameterString } from "./generic.js";
import type { inferDefinition, validateDeclared, validateDefinition } from "./parser/definition.js";
import type { IndexOneOperator, IndexZeroOperator, TupleInfixOperator } from "./parser/tuple.js";
import type { InternalScope, Scope, bindThis } from "./scope.js";
import type { BaseType } from "./subtypes/base.js";
import type { instantiateType } from "./subtypes/instantiate.js";
import type { distillIn, distillOut } from "./ast.ts";
import { type Generic, type ParameterString, type baseGenericConstraints, type parseValidGenericParams, type validateParameterString } from "./generic.ts";
import type { inferDefinition, validateDeclared, validateDefinition } from "./parser/definition.ts";
import type { IndexOneOperator, IndexZeroOperator, TupleInfixOperator } from "./parser/tuple.ts";
import type { InternalScope, Scope, bindThis } from "./scope.ts";
import type { BaseType } from "./subtypes/base.ts";
import type { instantiateType } from "./subtypes/instantiate.ts";
/** The convenience properties attached to `type` */

@@ -11,0 +11,0 @@ export type TypeParserAttachments = Omit<TypeParser, never>;

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

@@ -20,5 +20,14 @@ "author": {

"exports": {
".": "./out/index.js",
"./config": "./out/config.js",
"./internal/*": "./out/*"
".": {
"ark-ts": "./index.ts",
"default": "./out/index.js"
},
"./config": {
"ark-ts": "./config.ts",
"default": "./out/config.js"
},
"./internal/*.ts": {
"ark-ts": "./*.ts",
"default": "./out/*.js"
}
},

@@ -29,4 +38,4 @@ "files": [

"dependencies": {
"@ark/util": "0.2.1",
"@ark/schema": "0.3.2"
"@ark/util": "0.2.2",
"@ark/schema": "0.3.3"
},

@@ -37,5 +46,5 @@ "publishConfig": {

"scripts": {
"build": "tsx ../repo/build.ts",
"test": "tsx ../repo/testPackage.ts"
"build": "ts ../repo/build.ts",
"test": "ts ../repo/testPackage.ts"
}
}
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