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-dev.10 to 2.0.0-dev.11

out/api.d.ts

2

out/ark.d.ts

@@ -15,3 +15,3 @@ import { type Ark, type ArkErrors, type inferred } from "@arktype/schema";

};
export declare const tsGenerics: Module<TsGenericsExports>;
export declare const tsGenerics: Module<TsGenericsExports<Ark>>;
export declare const ambient: Scope<Ark>;

@@ -18,0 +18,0 @@ export declare const ark: Module<Ark>;

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

import { type GenericNodeInstantiation, type GenericProps, type SchemaScope, arkKind } from "@arktype/schema";
import { type GenericNodeInstantiation, type GenericProps, type RootScope, arkKind } from "@arktype/schema";
import { Callable, type conform } from "@arktype/util";

@@ -17,6 +17,6 @@ import type { inferDefinition } from "./parser/definition.js";

def: def;
$: SchemaScope<$>;
$: RootScope<$>;
readonly [arkKind] = "generic";
constructor(params: params, def: def, $: SchemaScope<$>);
constructor(params: params, def: def, $: RootScope<$>);
}
export {};
export const createMatchParser = ($) => {
return (() => { }).bind($);
// const matchParser = (isRestricted: boolean) => {
// const handledCases: { when: RawSchema; then: Morph }[] = []
// const handledCases: { when: RawRoot; then: Morph }[] = []
// let defaultCase: ((x: unknown) => unknown) | null = null

@@ -6,0 +6,0 @@ // const parser = {

import type { PreparsedNodeResolution, arkKind } from "@arktype/schema";
import { DynamicBase, type isAnyOrNever } from "@arktype/util";
import { DynamicBase, type anyOrNever } from "@arktype/util";
import type { Type } from "./type.js";
type exportScope<$> = {
[k in keyof $]: $[k] extends PreparsedNodeResolution ? isAnyOrNever<$[k]> extends true ? Type<$[k], $> : $[k] : Type<$[k], $>;
[k in keyof $]: $[k] extends PreparsedNodeResolution ? [
$[k]
] extends [anyOrNever] ? Type<$[k], $> : $[k] : Type<$[k], $>;
};

@@ -7,0 +9,0 @@ export declare class Module<$ = any> extends DynamicBase<exportScope<$>> {

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

import { type RawSchema, type string } from "@arktype/schema";
import { type ErrorMessage, type Primitive, type array, type defined, type equals, type isAny, type isUnknown, type objectKindOrDomainOf, type optionalKeyOf, type requiredKeyOf, type show } from "@arktype/util";
import { type BaseRoot, type string } from "@arktype/schema";
import { type ErrorMessage, type Primitive, type anyOrNever, type array, type defined, type equals, type isUnknown, type objectKindOrDomainOf, type optionalKeyOf, type requiredKeyOf, type show } from "@arktype/util";
import type { type } from "../ark.js";

@@ -9,12 +9,14 @@ import type { ParseContext } from "../scope.js";

import { type TupleExpression, type inferTuple, type validateTuple } from "./tuple.js";
export declare const parseObject: (def: object, ctx: ParseContext) => RawSchema;
export type inferDefinition<def, $, args> = isAny<def> extends true ? never : def extends type.cast<infer t> | ThunkCast<infer t> ? t : def extends string ? inferString<def, $, args> : def extends array ? inferTuple<def, $, args> : def extends RegExp ? string.matching<string> : def extends object ? inferObjectLiteral<def, $, args> : never;
export declare const parseObject: (def: object, ctx: ParseContext) => BaseRoot;
export type inferDefinition<def, $, args> = [
def
] extends [anyOrNever] ? def : def extends type.cast<infer t> | ThunkCast<infer t> ? t : def extends string ? inferString<def, $, args> : def extends array ? inferTuple<def, $, args> : def extends RegExp ? string.matching<string> : def extends object ? inferObjectLiteral<def, $, args> : never;
export type validateDefinition<def, $, args> = null extends undefined ? ErrorMessage<`'strict' or 'strictNullChecks' must be set to true in your tsconfig's 'compilerOptions'`> : [def] extends [Terminal] ? def : def extends string ? validateString<def, $, args> : def extends array ? validateTuple<def, $, args> : def extends BadDefinitionType ? writeBadDefinitionTypeMessage<objectKindOrDomainOf<def>> : isUnknown<def> extends true ? BaseCompletions<$, args> | {} : validateObjectLiteral<def, $, args>;
export type validateDeclared<declared, def, $, args> = def extends validateDefinition<def, $, args> ? validateInference<def, declared, $, args> : validateDefinition<def, $, args>;
type validateInference<def, declared, $, args> = def extends RegExp | type.cast<unknown> | ThunkCast | TupleExpression ? validateShallowInference<def, declared, $, args> : def extends array ? declared extends array ? {
[i in keyof declared]: i extends keyof def ? validateInference<def[i], declared[i], $, args> : unknown;
[i in keyof declared]: i extends keyof def ? validateInference<def[i], declared[i], $, args> : declared[i];
} : show<declarationMismatch<def, declared, $, args>> : def extends object ? show<{
[k in requiredKeyOf<declared>]: k extends keyof def ? validateInference<def[k], declared[k], $, args> : unknown;
[k in requiredKeyOf<declared>]: k extends keyof def ? validateInference<def[k], declared[k], $, args> : declared[k];
} & {
[k in optionalKeyOf<declared> & string as `${k}?`]: `${k}?` extends (keyof def) ? validateInference<def[`${k}?`], defined<declared[k]>, $, args> : unknown;
[k in optionalKeyOf<declared> & string as `${k}?`]: `${k}?` extends (keyof def) ? validateInference<def[`${k}?`], defined<declared[k]>, $, args> : declared[k];
}> : validateShallowInference<def, declared, $, args>;

@@ -29,4 +31,4 @@ type validateShallowInference<def, declared, $, args> = equals<inferDefinition<def, $, args>, declared> extends true ? def : show<declarationMismatch<def, declared, $, args>>;

type BadDefinitionType = Exclude<Primitive, string>;
export declare const writeBadDefinitionTypeMessage: <actual extends string>(actual: actual) => writeBadDefinitionTypeMessage<actual>;
export declare const writeBadDefinitionTypeMessage: <actual extends string>(actual: actual) => `Type definitions must be strings or objects (was ${actual})`;
type writeBadDefinitionTypeMessage<actual extends string> = `Type definitions must be strings or objects (was ${actual})`;
export {};

@@ -9,3 +9,3 @@ import { hasArkKind } from "@arktype/schema";

case undefined:
if (hasArkKind(def, "schema"))
if (hasArkKind(def, "root"))
return def;

@@ -22,3 +22,3 @@ return parseObjectLiteral(def, ctx);

const resolvedDef = isThunk(def) ? def() : def;
if (hasArkKind(resolvedDef, "schema"))
if (hasArkKind(resolvedDef, "root"))
return resolvedDef;

@@ -25,0 +25,0 @@ return throwParseError(writeBadDefinitionTypeMessage("Function"));

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

import { type RawSchema, type writeInvalidPropertyKeyMessage } from "@arktype/schema";
import { type Dict, type ErrorMessage, type Key, type merge, type show } from "@arktype/util";
import type { BaseRoot, writeInvalidPropertyKeyMessage } from "@arktype/schema";
import { type Dict, type ErrorMessage, type Key, type keyError, type merge, type show } from "@arktype/util";
import type { ParseContext } from "../scope.js";

@@ -8,9 +8,9 @@ import type { inferDefinition, validateDefinition } from "./definition.js";

import { Scanner } from "./string/shift/scanner.js";
export declare const parseObjectLiteral: (def: Dict, ctx: ParseContext) => RawSchema;
export declare const parseObjectLiteral: (def: Dict, ctx: ParseContext) => BaseRoot;
export declare const nonLeadingSpreadError = "Spread operator may only be used as the first key in an object";
export type inferObjectLiteral<def extends object, $, args> = show<"..." extends keyof def ? merge<inferDefinition<def["..."], $, args>, _inferObjectLiteral<def, $, args>> : _inferObjectLiteral<def, $, args>>;
/**
* Infers the contents of an object literal, ignoring a spread definition
* You probably want to use {@link inferObjectLiteral} instead.
*/
type inferObjectLiteralInner<def extends object, $, args> = {
type _inferObjectLiteral<def extends object, $, args> = {
-readonly [k in keyof def as nonOptionalKeyFrom<k, $, args>]: inferDefinition<def[k], $, args>;

@@ -20,5 +20,4 @@ } & {

};
export type inferObjectLiteral<def extends object, $, args> = show<"..." extends keyof def ? merge<inferDefinition<def["..."], $, args>, inferObjectLiteralInner<def, $, args>> : inferObjectLiteralInner<def, $, args>>;
export type validateObjectLiteral<def, $, args> = {
[k in keyof def]: k extends IndexKey<infer indexDef> ? validateString<indexDef, $, args> extends ErrorMessage<infer message> ? indexParseError<message> : inferDefinition<indexDef, $, args> extends PropertyKey ? validateDefinition<def[k], $, args> : indexParseError<writeInvalidPropertyKeyMessage<indexDef>> : k extends "..." ? inferDefinition<def[k], $, args> extends object ? validateDefinition<def[k], $, args> : indexParseError<writeInvalidSpreadTypeMessage<astToString<def[k]>>> : validateDefinition<def[k], $, args>;
[k in keyof def]: k extends IndexKey<infer indexDef> ? validateString<indexDef, $, args> extends ErrorMessage<infer message> ? keyError<message> : inferDefinition<indexDef, $, args> extends PropertyKey ? validateDefinition<def[k], $, args> : keyError<writeInvalidPropertyKeyMessage<indexDef>> : k extends "..." ? inferDefinition<def[k], $, args> extends object ? validateDefinition<def[k], $, args> : keyError<writeInvalidSpreadTypeMessage<astToString<def[k]>>> : validateDefinition<def[k], $, args>;
};

@@ -40,3 +39,3 @@ type nonOptionalKeyFrom<k, $, args> = parseKey<k> extends PreparsedKey<"required", infer inner> ? inner : parseKey<k> extends PreparsedKey<"index", infer inner> ? inferDefinition<inner, $, args> & Key : never;

export declare const parseEntry: (entry: readonly [Key, unknown]) => PreparsedEntry;
declare const parseKey: (key: Key) => PreparsedKey<ParsedKeyKind, Key>;
declare const parseKey: (key: Key) => PreparsedKey;
type parseKey<k> = k extends `${infer inner}?` ? inner extends `${infer baseName}${Scanner.EscapeToken}` ? PreparsedKey.from<{

@@ -61,8 +60,4 @@ kind: "required";

}>;
declare const indexParseSymbol: unique symbol;
export type indexParseError<message extends string = string> = {
[indexParseSymbol]: message;
};
export declare const writeInvalidSpreadTypeMessage: <def extends string>(def: def) => writeInvalidSpreadTypeMessage<def>;
export declare const writeInvalidSpreadTypeMessage: <def extends string>(def: def) => `Spread operand must resolve to an object literal type (was ${def})`;
type writeInvalidSpreadTypeMessage<def extends string> = `Spread operand must resolve to an object literal type (was ${def})`;
export {};

@@ -1,7 +0,6 @@

import { tsKeywords } from "@arktype/schema";
import { printable, spliterate, stringAndSymbolicEntriesOf, throwParseError } from "@arktype/util";
import { append, printable, spliterate, stringAndSymbolicEntriesOf, throwParseError } from "@arktype/util";
import { Scanner } from "./string/shift/scanner.js";
export const parseObjectLiteral = (def, ctx) => {
const propNodes = [];
const indexNodes = [];
let spread;
const structure = {};
// We only allow a spread operator to be used as the first key in an object

@@ -17,11 +16,8 @@ // because to match JS behavior any keys before the spread are overwritten

const spreadNode = ctx.$.parse(spreadEntry.value, ctx);
if (!spreadNode.hasKind("intersection") ||
!spreadNode.extends(tsKeywords.object)) {
return throwParseError(writeInvalidSpreadTypeMessage(printable(spreadEntry.value)));
if (!spreadNode.hasKind("intersection") || !spreadNode.structure) {
return throwParseError(writeInvalidSpreadTypeMessage(typeof spreadEntry.value === "string" ?
spreadEntry.value
: printable(spreadEntry.value)));
}
// TODO: move to props group merge in schema
// For each key on spreadNode, add it to our object.
// We filter out keys from the spreadNode that will be defined later on this same object
// because the currently parsed definition will overwrite them.
spreadNode.prop?.forEach(spreadRequired => !parsedEntries.some(({ inner: innerKey }) => innerKey === spreadRequired.key) && propNodes.push(spreadRequired));
spread = spreadNode.structure;
}

@@ -36,24 +32,25 @@ for (const entry of parsedEntries) {

// extract enumerable named props from the index signature
const [enumerable, nonEnumerable] = spliterate(key.branches, k => k.hasKind("unit"));
const [enumerable, nonEnumerable] = spliterate(key.branches, (k) => k.hasKind("unit"));
if (enumerable.length) {
propNodes.push(...enumerable.map(k => ctx.$.node("prop", { key: k.unit, value })));
if (nonEnumerable.length)
indexNodes.push(ctx.$.node("index", { key: nonEnumerable, value }));
structure.required = append(structure.required, enumerable.map(k => ctx.$.node("required", { key: k.unit, value })));
if (nonEnumerable.length) {
structure.index = append(structure.index, ctx.$.node("index", { index: nonEnumerable, value }));
}
}
else
indexNodes.push(ctx.$.node("index", { key, value }));
else {
structure.index = append(structure.index, ctx.$.node("index", { index: key, value }));
}
}
else {
const value = ctx.$.parse(entry.value, ctx);
propNodes.push({
structure[entry.kind] = append(structure[entry.kind], {
key: entry.inner,
value,
optional: entry.kind === "optional"
value
});
}
}
const structureNode = ctx.$.node("structure", structure);
return ctx.$.schema({
domain: "object",
prop: propNodes,
index: indexNodes
structure: spread?.merge(structureNode) ?? structureNode
});

@@ -60,0 +57,0 @@ };

import type { LimitLiteral, writeUnboundableMessage } from "@arktype/schema";
import type { ErrorMessage, array } from "@arktype/util";
import type { Comparator, InvertedComparators } from "../string/reduce/shared.js";
import type { Comparator } from "../string/reduce/shared.js";
import type { BoundExpressionKind, writeInvalidLimitMessage } from "../string/shift/operator/bounds.js";

@@ -8,3 +8,3 @@ import type { inferAstIn } from "./infer.js";

import type { validateAst } from "./validate.js";
export type validateRange<l, comparator extends Comparator, r, $, args> = l extends LimitLiteral ? validateBound<r, InvertedComparators[comparator], l, "left", $, args> : l extends [infer leftAst, Comparator, unknown] ? ErrorMessage<writeDoubleRightBoundMessage<astToString<leftAst>>> : validateBound<l, comparator, r & LimitLiteral, "right", $, args>;
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>;
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<astToString<boundKind extends "left" ? boundedAst[0 & keyof boundedAst] : boundedAst>>> : never;

@@ -14,4 +14,4 @@ type isNumericallyBoundable<bounded> = [

] extends [number] ? true : [bounded] extends [string] ? true : [bounded] extends [array] ? true : false;
export declare const writeDoubleRightBoundMessage: <root extends string>(root: root) => writeDoubleRightBoundMessage<root>;
export declare const writeDoubleRightBoundMessage: <root extends string>(root: root) => `Expression ${root} must have at most one right bound`;
type writeDoubleRightBoundMessage<root extends string> = `Expression ${root} must have at most one right bound`;
export {};

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

import type { Schema, writeIndivisibleMessage } from "@arktype/schema";
import type { Root, writeIndivisibleMessage } from "@arktype/schema";
import type { ErrorMessage } from "@arktype/util";

@@ -7,2 +7,2 @@ import type { inferAstIn } from "./infer.js";

data
] extends [number] ? validateAst<l, $, args> : ErrorMessage<writeIndivisibleMessage<Schema<data>>> : never;
] extends [number] ? validateAst<l, $, args> : ErrorMessage<writeIndivisibleMessage<Root<data>>> : never;

@@ -11,3 +11,3 @@ import type { Date, DateLiteral, GenericProps, LimitLiteral, RegexLiteral, constrain, distillIn, inferIntersection, normalizeLimit, string } from "@arktype/schema";

export type GenericInstantiationAst<generic extends GenericProps = GenericProps, argAsts extends unknown[] = unknown[]> = [generic, "<>", argAsts];
export type inferExpression<ast extends array, $, args> = ast extends GenericInstantiationAst<infer generic, infer argAsts> ? inferDefinition<generic["def"], generic["$"]["$"] extends UnparsedScope ? $ : generic["$"]["$"], {
export type inferExpression<ast extends array, $, args> = ast extends GenericInstantiationAst<infer generic, infer argAsts> ? inferDefinition<generic["def"], generic["$"]["t"] extends UnparsedScope ? $ : generic["$"]["t"], {
[i in keyof generic["params"] & `${number}` as generic["params"][i]]: inferConstrainableAst<argAsts[i & keyof argAsts], $, args>;

@@ -14,0 +14,0 @@ }> : ast[1] extends "[]" ? inferConstrainableAst<ast[0], $, args>[] : ast[1] extends "|" ? inferConstrainableAst<ast[0], $, args> | inferConstrainableAst<ast[2], $, args> : ast[1] extends "&" ? inferIntersection<inferConstrainableAst<ast[0], $, args>, inferConstrainableAst<ast[2], $, args>> : ast[1] extends Comparator ? ast[0] extends LimitLiteral ? constrainBound<inferConstrainableAst<ast[2], $, args>, ast[1], ast[0]> : constrainBound<inferConstrainableAst<ast[0], $, args>, ast[1], ast[2]> : ast[1] extends "%" ? constrain<inferConstrainableAst<ast[0], $, args>, "divisor", ast[2] & number> : ast[0] extends "keyof" ? keyof inferConstrainableAst<ast[1], $, args> : never;

import type { arkKind, GenericProps, PrivateDeclaration, writeMissingSubmoduleAccessMessage } from "@arktype/schema";
import type { BigintLiteral, charsAfterFirst, Completion, ErrorMessage, isAnyOrNever, writeMalformedNumericLiteralMessage } from "@arktype/util";
import type { anyOrNever, BigintLiteral, charsAfterFirst, Completion, ErrorMessage, writeMalformedNumericLiteralMessage } from "@arktype/util";
import type { Comparator } from "../string/reduce/shared.js";

@@ -15,7 +15,9 @@ import type { writeInvalidGenericArgsMessage } from "../string/shift/operand/genericArgs.js";

type validateGenericArgs<argAsts extends unknown[], $, args> = argAsts extends [infer head, ...infer tail] ? validateAst<head, $, args> extends ErrorMessage<infer message> ? ErrorMessage<message> : validateGenericArgs<tail, $, args> : undefined;
export declare const writeUnsatisfiableExpressionError: <expression extends string>(expression: expression) => writeUnsatisfiableExpressionError<expression>;
export declare const writeUnsatisfiableExpressionError: <expression extends string>(expression: expression) => `${expression} results in an unsatisfiable type`;
export type writeUnsatisfiableExpressionError<expression extends string> = `${expression} results in an unsatisfiable type`;
export declare const writePrefixedPrivateReferenceMessage: <def extends `#${string}`>(def: def) => writePrefixedPrivateReferenceMessage<def>;
export declare const writePrefixedPrivateReferenceMessage: <def extends `#${string}`>(def: def) => `Private type references should not include '#'. Use '${charsAfterFirst<def>}' instead.`;
export type writePrefixedPrivateReferenceMessage<def extends PrivateDeclaration> = `Private type references should not include '#'. Use '${charsAfterFirst<def>}' instead.`;
type validateStringAst<def extends string, $> = def extends `${infer n extends number}` ? number extends n ? ErrorMessage<writeMalformedNumericLiteralMessage<def, "number">> : undefined : def extends BigintLiteral<infer b> ? bigint extends b ? ErrorMessage<writeMalformedNumericLiteralMessage<def, "bigint">> : undefined : maybeExtractAlias<def, $> extends infer alias extends keyof $ ? isAnyOrNever<$[alias]> extends true ? def : def extends PrivateDeclaration ? ErrorMessage<writePrefixedPrivateReferenceMessage<def>> : $[alias] extends GenericProps ? ErrorMessage<writeInvalidGenericArgsMessage<def, $[alias]["params"], []>> : $[alias] extends {
type validateStringAst<def extends string, $> = def extends `${infer n extends number}` ? number extends n ? ErrorMessage<writeMalformedNumericLiteralMessage<def, "number">> : undefined : def extends BigintLiteral<infer b> ? bigint extends b ? ErrorMessage<writeMalformedNumericLiteralMessage<def, "bigint">> : undefined : maybeExtractAlias<def, $> extends infer alias extends keyof $ ? [
$[alias]
] extends [anyOrNever] ? def : def extends PrivateDeclaration ? ErrorMessage<writePrefixedPrivateReferenceMessage<def>> : $[alias] extends GenericProps ? ErrorMessage<writeInvalidGenericArgsMessage<def, $[alias]["params"], []>> : $[alias] extends {
[arkKind]: "module";

@@ -22,0 +24,0 @@ } ? ErrorMessage<writeMissingSubmoduleAccessMessage<def>> : undefined : def extends ErrorMessage ? def : undefined;

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

import type { LimitLiteral, RawSchema } from "@arktype/schema";
import type { BaseRoot, LimitLiteral } from "@arktype/schema";
import { type requireKeys } from "@arktype/util";

@@ -10,4 +10,4 @@ import type { ParseContext } from "../../../scope.js";

leftBound: OpenLeftBound | null;
intersection: RawSchema | null;
union: RawSchema | null;
intersection: BaseRoot | null;
union: BaseRoot | null;
};

@@ -18,3 +18,3 @@ export type DynamicStateWithRoot = requireKeys<DynamicState, "root">;

readonly scanner: Scanner;
root: RawSchema<any> | undefined;
root: BaseRoot<any> | undefined;
branches: BranchState;

@@ -26,5 +26,5 @@ finalizer: Scanner.FinalizingLookahead | undefined;

hasRoot(): this is DynamicStateWithRoot;
setRoot(root: RawSchema): void;
setRoot(root: BaseRoot): void;
unsetRoot(): this["root"];
constrainRoot(...args: Parameters<RawSchema<any>["constrain"]>): void;
constrainRoot(...args: Parameters<BaseRoot<any>["constrain"]>): void;
finalize(finalizer: Scanner.FinalizingLookahead): void;

@@ -31,0 +31,0 @@ reduceLeftBound(limit: LimitLiteral, comparator: Comparator): void;

@@ -14,17 +14,17 @@ import type { LimitLiteral } from "@arktype/schema";

export declare const comparators: {
">": boolean;
">=": boolean;
"<": boolean;
"<=": boolean;
"==": boolean;
"<": true;
"<=": true;
">": true;
">=": true;
};
export type Comparator = keyof typeof comparators;
export declare const invertedComparators: {
readonly "<": ">";
readonly ">": "<";
readonly "<=": ">=";
readonly ">=": "<=";
readonly "==": "==";
export declare const invertedComparators: InvertedComparators;
export type InvertedComparators = {
"<": ">";
">": "<";
"<=": ">=";
">=": "<=";
"==": "==";
};
export type InvertedComparators = typeof invertedComparators;
export type OpenLeftBound = {

@@ -34,11 +34,11 @@ limit: LimitLiteral;

};
export declare const writeUnmatchedGroupCloseMessage: <unscanned extends string>(unscanned: unscanned) => writeUnmatchedGroupCloseMessage<unscanned>;
export declare const writeUnmatchedGroupCloseMessage: <unscanned extends string>(unscanned: unscanned) => `Unmatched )${unscanned extends "" ? "" : ` before ${unscanned}`}`;
export type writeUnmatchedGroupCloseMessage<unscanned extends string> = `Unmatched )${unscanned extends "" ? "" : ` before ${unscanned}`}`;
export declare const writeUnclosedGroupMessage: <missingChar extends string>(missingChar: missingChar) => writeUnclosedGroupMessage<missingChar>;
export declare const writeUnclosedGroupMessage: <missingChar extends string>(missingChar: missingChar) => `Missing ${missingChar}`;
export type writeUnclosedGroupMessage<missingChar extends string> = `Missing ${missingChar}`;
export declare const writeOpenRangeMessage: <min extends LimitLiteral, comparator extends ">" | ">=">(min: min, comparator: comparator) => writeOpenRangeMessage<min, comparator>;
export declare const writeOpenRangeMessage: <min extends LimitLiteral, comparator extends ">" | ">=">(min: min, comparator: comparator) => `Left bounds are only valid when paired with right bounds (try ...${comparator}${min})`;
export type writeOpenRangeMessage<min extends LimitLiteral, comparator extends MinComparator> = `Left bounds are only valid when paired with right bounds (try ...${comparator}${min})`;
export type writeUnpairableComparatorMessage<comparator extends Comparator> = `Left-bounded expressions must specify their limits using < or <= (was ${comparator})`;
export declare const writeUnpairableComparatorMessage: <comparator extends "==" | "<" | "<=" | ">" | ">=">(comparator: comparator) => writeUnpairableComparatorMessage<comparator>;
export declare const writeMultipleLeftBoundsMessage: <openLimit extends LimitLiteral, openComparator extends ">" | ">=", limit extends LimitLiteral, comparator extends ">" | ">=">(openLimit: openLimit, openComparator: openComparator, limit: limit, comparator: comparator) => writeMultipleLeftBoundsMessage<openLimit, openComparator, limit, comparator>;
export declare const writeUnpairableComparatorMessage: <comparator extends ">" | "<" | ">=" | "<=" | "==">(comparator: comparator) => `Left-bounded expressions must specify their limits using < or <= (was ${comparator})`;
export declare const writeMultipleLeftBoundsMessage: <openLimit extends LimitLiteral, openComparator extends ">" | ">=", limit extends LimitLiteral, comparator extends ">" | ">=">(openLimit: openLimit, openComparator: openComparator, limit: limit, comparator: comparator) => `An expression may have at most one left bound (parsed ${openLimit}${InvertedComparators[openComparator]}, ${limit}${InvertedComparators[comparator]})`;
export type writeMultipleLeftBoundsMessage<openLimit extends LimitLiteral, openComparator extends MinComparator, limit extends LimitLiteral, comparator extends MinComparator> = `An expression may have at most one left bound (parsed ${openLimit}${InvertedComparators[openComparator]}, ${limit}${InvertedComparators[comparator]})`;

@@ -10,4 +10,6 @@ export const minComparators = {

export const comparators = {
...minComparators,
...maxComparators,
">": true,
">=": true,
"<": true,
"<=": true,
"==": true

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

@@ -6,7 +6,7 @@ import type { DateLiteral } from "@arktype/schema";

type extractDateLiteralSource<literal extends DateLiteral> = literal extends DateLiteral<infer source> ? source : never;
export declare const writeInvalidDateMessage: <source extends string>(source: source) => writeInvalidDateMessage<source>;
export declare const writeInvalidDateMessage: <source extends string>(source: source) => `'${source}' could not be parsed by the Date constructor`;
export type writeInvalidDateMessage<source extends string> = `'${source}' could not be parsed by the Date constructor`;
export type DateInput = ConstructorParameters<typeof Date>[0];
export type DateParseResult<errorOnFail extends boolean | string = boolean | string> = Date | (errorOnFail extends true | string ? never : undefined);
export declare const tryParseDate: <errorOnFail extends string | boolean>(source: string, errorOnFail?: errorOnFail) => DateParseResult<errorOnFail>;
export declare const tryParseDate: <errorOnFail extends string | boolean>(source: string, errorOnFail?: errorOnFail | undefined) => DateParseResult<errorOnFail>;
export {};

@@ -15,5 +15,5 @@ import type { DynamicState } from "../../reduce/dynamic.js";

export declare const enclosingChar: {
readonly "/": 1;
readonly "'": 1;
readonly '"': 1;
readonly "/": 1;
};

@@ -31,6 +31,20 @@ export declare const enclosingTokens: {

export declare const untilLookaheadIsClosing: Record<EnclosingEndToken, Scanner.UntilCondition>;
declare const enclosingCharDescriptions: typeof enclosingCharDescriptions;
declare const enclosingCharDescriptions: {
readonly '"': "double-quote";
readonly "'": "single-quote";
readonly "/": "forward slash";
};
type enclosingCharDescriptions = typeof enclosingCharDescriptions;
export declare const writeUnterminatedEnclosedMessage: <fragment extends string, enclosingStart extends "'" | "\"" | "/" | "d'" | "d\"">(fragment: fragment, enclosingStart: enclosingStart) => writeUnterminatedEnclosedMessage<fragment, enclosingStart>;
export declare const writeUnterminatedEnclosedMessage: <fragment extends string, enclosingStart extends "'" | "\"" | "/" | "d'" | "d\"">(fragment: fragment, enclosingStart: enclosingStart) => `${enclosingStart}${fragment} requires a closing ${{
readonly '"': "double-quote";
readonly "'": "single-quote";
readonly "/": "forward slash";
}[{
readonly "d'": "'";
readonly 'd"': "\"";
readonly "'": "'";
readonly '"': "\"";
readonly "/": "/";
}[enclosingStart]]}`;
export type writeUnterminatedEnclosedMessage<fragment extends string, enclosingStart extends EnclosingStartToken> = `${enclosingStart}${fragment} requires a closing ${enclosingCharDescriptions[EnclosingTokens[enclosingStart]]}`;
export {};

@@ -30,3 +30,4 @@ import { isKeyOf } from "@arktype/util";

"/": 1,
...enclosingQuote
"'": 1,
'"': 1
};

@@ -33,0 +34,0 @@ export const enclosingTokens = {

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

import type { RawSchema } from "@arktype/schema";
import type { BaseRoot } from "@arktype/schema";
import type { ErrorMessage, join } from "@arktype/util";

@@ -11,5 +11,5 @@ import type { DynamicState } from "../../reduce/dynamic.js";

};
export declare const parseGenericArgs: (name: string, params: string[], s: DynamicState) => ParsedArgs<RawSchema[]>;
export declare const parseGenericArgs: (name: string, params: string[], s: DynamicState) => ParsedArgs<BaseRoot[]>;
export type parseGenericArgs<name extends string, params extends string[], unscanned extends string, $, args> = _parseGenericArgs<name, params, unscanned, $, args, [], []>;
declare const _parseGenericArgs: (name: string, params: string[], s: DynamicState, argDefs: string[], argNodes: RawSchema[]) => ParsedArgs<RawSchema[]>;
declare const _parseGenericArgs: (name: string, params: string[], s: DynamicState, argDefs: string[], argNodes: BaseRoot[]) => ParsedArgs<BaseRoot[]>;
type _parseGenericArgs<name extends string, params extends string[], unscanned extends string, $, args, argDefs extends string[], argAsts extends unknown[]> = parseUntilFinalizer<state.initialize<unscanned>, $, args> extends (infer finalArgState extends StaticState) ? {

@@ -27,4 +27,4 @@ defs: [

}) ? finalArgState["finalizer"] extends ">" ? nextAsts["length"] extends params["length"] ? ParsedArgs<nextAsts, nextUnscanned> : state.error<writeInvalidGenericArgsMessage<name, params, nextDefs>> : finalArgState["finalizer"] extends "," ? _parseGenericArgs<name, params, nextUnscanned, $, args, nextDefs, nextAsts> : finalArgState["finalizer"] extends ErrorMessage ? finalArgState : state.error<writeUnclosedGroupMessage<">">> : never : never;
export declare const writeInvalidGenericArgsMessage: <name extends string, params extends string[], argDefs extends string[]>(name: name, params: params, argDefs: argDefs) => writeInvalidGenericArgsMessage<name, params, argDefs>;
export declare const writeInvalidGenericArgsMessage: <name extends string, params extends string[], argDefs extends string[]>(name: name, params: params, argDefs: argDefs) => `${name}<${join<params, ", ", "">}> requires exactly ${params["length"]} args (got ${argDefs["length"]}${argDefs["length"] extends 0 ? "" : `: ${join<argDefs, ",", "">}`})`;
export type writeInvalidGenericArgsMessage<name extends string, params extends string[], argDefs extends string[]> = `${name}<${join<params, ", ">}> requires exactly ${params["length"]} args (got ${argDefs["length"]}${argDefs["length"] extends (0) ? "" : `: ${join<argDefs, ",">}`})`;
export {};

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

import { type GenericProps, RawSchema, type arkKind, type writeNonSubmoduleDotMessage, writeUnresolvableMessage } from "@arktype/schema";
import { type BigintLiteral, type Completion, type ErrorMessage, type isAnyOrNever, type join } from "@arktype/util";
import { BaseRoot, type GenericProps, type arkKind, type writeNonSubmoduleDotMessage, writeUnresolvableMessage } from "@arktype/schema";
import { type BigintLiteral, type Completion, type ErrorMessage, type anyOrNever, type join } from "@arktype/util";
import type { Generic } from "../../../../generic.js";

@@ -11,4 +11,6 @@ import type { GenericInstantiationAst } from "../../../semantic/infer.js";

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 keyof $ ? isAnyOrNever<$[result]> extends true ? state.setRoot<s, result, unscanned> : $[result] extends GenericProps ? parseGenericInstantiation<token, $[result], state.scanTo<s, unscanned>, $, args> : state.setRoot<s, result, unscanned> : state.setRoot<s, result, unscanned> : never : never;
export declare const parseGenericInstantiation: (name: string, g: Generic, s: DynamicState) => RawSchema;
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 keyof $ ? [
$[result]
] extends [anyOrNever] ? state.setRoot<s, result, unscanned> : $[result] extends GenericProps ? parseGenericInstantiation<token, $[result], state.scanTo<s, unscanned>, $, args> : state.setRoot<s, result, unscanned> : state.setRoot<s, result, unscanned> : never : never;
export declare const parseGenericInstantiation: (name: string, g: Generic, s: DynamicState) => BaseRoot;
export type parseGenericInstantiation<name extends string, g extends GenericProps, s extends StaticState, $, args> = Scanner.skipWhitespace<s["unscanned"]> extends `<${infer unscanned}` ? parseGenericArgs<name, g["params"], unscanned, $, args> extends (infer result) ? result extends ParsedArgs<infer argAsts, infer nextUnscanned> ? state.setRoot<s, GenericInstantiationAst<g, argAsts>, nextUnscanned> : result : never : state.error<writeInvalidGenericArgsMessage<name, g["params"], []>>;

@@ -25,5 +27,5 @@ type tryResolve<s extends StaticState, token extends string, $, args> = 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 $ & string}.${infer reference}`) ? $[submodule] extends {

export type writeMissingRightOperandMessage<token extends string, unscanned extends string = ""> = `Token '${token}' requires a right operand${unscanned extends "" ? "" : ` before '${unscanned}'`}`;
export declare const writeMissingRightOperandMessage: <token extends string, unscanned extends string>(token: token, unscanned?: unscanned) => writeMissingRightOperandMessage<token, unscanned>;
export declare const writeExpressionExpectedMessage: <unscanned extends string>(unscanned: unscanned) => writeExpressionExpectedMessage<unscanned>;
export declare const writeMissingRightOperandMessage: <token extends string, unscanned extends string>(token: token, unscanned?: unscanned) => `Token '${token}' requires a right operand${unscanned extends "" ? "" : ` before '${unscanned}'`}`;
export declare const writeExpressionExpectedMessage: <unscanned extends string>(unscanned: unscanned) => `Expected an expression${unscanned extends "" ? "" : ` before '${unscanned}'`}`;
export type writeExpressionExpectedMessage<unscanned extends string> = `Expected an expression${unscanned extends "" ? "" : ` before '${unscanned}'`}`;
export {};

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

import { RawSchema, hasArkKind, writeUnresolvableMessage } from "@arktype/schema";
import { BaseRoot, hasArkKind, writeUnresolvableMessage } from "@arktype/schema";
import { printable, throwParseError, tryParseNumber, tryParseWellFormedBigint } from "@arktype/util";

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

const resolution = s.ctx.$.maybeResolve(token);
if (resolution instanceof RawSchema)
if (resolution instanceof BaseRoot)
return resolution;

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

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

import { type BoundKind, type LimitLiteral, type RawSchema } from "@arktype/schema";
import { type BaseRoot, type BoundKind, type LimitLiteral } from "@arktype/schema";
import { type keySet } from "@arktype/util";

@@ -20,4 +20,4 @@ import type { astToString } from "../../../semantic/utils.js";

type shiftComparator<start extends ComparatorStartChar, unscanned extends string> = unscanned extends `=${infer nextUnscanned}` ? [`${start}=`, nextUnscanned] : start extends OneCharComparator ? [start, unscanned] : state.error<singleEqualsMessage>;
export declare const writeIncompatibleRangeMessage: (l: BoundKind, r: BoundKind) => "Bound kinds exactLength and exactLength are incompatible" | "Bound kinds exactLength and max are incompatible" | "Bound kinds exactLength and min are incompatible" | "Bound kinds exactLength and maxLength are incompatible" | "Bound kinds exactLength and minLength are incompatible" | "Bound kinds exactLength and before are incompatible" | "Bound kinds exactLength and after are incompatible" | "Bound kinds max and exactLength are incompatible" | "Bound kinds max and max are incompatible" | "Bound kinds max and min are incompatible" | "Bound kinds max and maxLength are incompatible" | "Bound kinds max and minLength are incompatible" | "Bound kinds max and before are incompatible" | "Bound kinds max and after are incompatible" | "Bound kinds min and exactLength are incompatible" | "Bound kinds min and max are incompatible" | "Bound kinds min and min are incompatible" | "Bound kinds min and maxLength are incompatible" | "Bound kinds min and minLength are incompatible" | "Bound kinds min and before are incompatible" | "Bound kinds min and after are incompatible" | "Bound kinds maxLength and exactLength are incompatible" | "Bound kinds maxLength and max are incompatible" | "Bound kinds maxLength and min are incompatible" | "Bound kinds maxLength and maxLength are incompatible" | "Bound kinds maxLength and minLength are incompatible" | "Bound kinds maxLength and before are incompatible" | "Bound kinds maxLength and after are incompatible" | "Bound kinds minLength and exactLength are incompatible" | "Bound kinds minLength and max are incompatible" | "Bound kinds minLength and min are incompatible" | "Bound kinds minLength and maxLength are incompatible" | "Bound kinds minLength and minLength are incompatible" | "Bound kinds minLength and before are incompatible" | "Bound kinds minLength and after are incompatible" | "Bound kinds before and exactLength are incompatible" | "Bound kinds before and max are incompatible" | "Bound kinds before and min are incompatible" | "Bound kinds before and maxLength are incompatible" | "Bound kinds before and minLength are incompatible" | "Bound kinds before and before are incompatible" | "Bound kinds before and after are incompatible" | "Bound kinds after and exactLength are incompatible" | "Bound kinds after and max are incompatible" | "Bound kinds after and min are incompatible" | "Bound kinds after and maxLength are incompatible" | "Bound kinds after and minLength are incompatible" | "Bound kinds after and before are incompatible" | "Bound kinds after and after are incompatible";
export declare const getBoundKinds: (comparator: Comparator, limit: LimitLiteral, root: RawSchema, boundKind: BoundExpressionKind) => BoundKind[];
export declare const writeIncompatibleRangeMessage: (l: BoundKind, r: BoundKind) => string;
export declare const getBoundKinds: (comparator: Comparator, limit: LimitLiteral, root: BaseRoot, boundKind: BoundExpressionKind) => BoundKind[];
export declare const singleEqualsMessage = "= is not a valid comparator. Use == to check for equality";

@@ -27,5 +27,5 @@ type singleEqualsMessage = typeof singleEqualsMessage;

export type parseRightBound<s extends StaticState, comparator extends Comparator, $, args> = parseOperand<s, $, args> extends infer nextState extends StaticState ? nextState["root"] extends `${infer limit extends LimitLiteral}` ? s["branches"]["leftBound"] extends {} ? comparator extends MaxComparator ? state.reduceRange<s, s["branches"]["leftBound"]["limit"], s["branches"]["leftBound"]["comparator"], comparator, limit, nextState["unscanned"]> : state.error<writeUnpairableComparatorMessage<comparator>> : state.reduceSingleBound<s, comparator, limit, nextState["unscanned"]> : state.error<writeInvalidLimitMessage<comparator, astToString<nextState["root"]>, "right">> : never;
export declare const writeInvalidLimitMessage: <comparator extends "==" | "<" | "<=" | ">" | ">=", limit extends string | number, boundKind extends BoundExpressionKind>(comparator: comparator, limit: limit, boundKind: boundKind) => writeInvalidLimitMessage<comparator, limit, boundKind>;
export type writeInvalidLimitMessage<comparator extends Comparator, limit extends string | number, boundKind extends BoundExpressionKind> = `Comparator ${boundKind extends "left" ? InvertedComparators[comparator] : comparator} must be ${boundKind extends "left" ? "preceded" : "followed"} by a corresponding literal (was '${limit}')`;
export declare const writeInvalidLimitMessage: <comparator extends ">" | "<" | ">=" | "<=" | "==", limit extends string | number, boundKind extends BoundExpressionKind>(comparator: comparator, limit: limit, boundKind: boundKind) => `Comparator ${boundKind extends "left" ? InvertedComparators[comparator] : comparator} must be ${boundKind extends "left" ? "preceded" : "followed"} by a corresponding literal (was ${limit})`;
export type writeInvalidLimitMessage<comparator extends Comparator, limit extends string | number, boundKind extends BoundExpressionKind> = `Comparator ${boundKind extends "left" ? InvertedComparators[comparator] : comparator} must be ${boundKind extends "left" ? "preceded" : "followed"} by a corresponding literal (was ${limit})`;
export type BoundExpressionKind = "left" | "right";
export {};

@@ -61,3 +61,3 @@ import { internalKeywords, jsObjects, tsKeywords, writeUnboundableMessage } from "@arktype/schema";

export const singleEqualsMessage = "= is not a valid comparator. Use == to check for equality";
const openLeftBoundToSchema = (leftBound) => ({
const openLeftBoundToRoot = (leftBound) => ({
rule: isDateLiteral(leftBound.limit) ?

@@ -93,5 +93,5 @@ extractDateLiteralSource(leftBound.limit)

const lowerBoundKind = getBoundKinds(s.branches.leftBound.comparator, s.branches.leftBound.limit, previousRoot, "left");
s.constrainRoot(lowerBoundKind[0], openLeftBoundToSchema(s.branches.leftBound));
s.constrainRoot(lowerBoundKind[0], openLeftBoundToRoot(s.branches.leftBound));
s.branches.leftBound = null;
};
export const writeInvalidLimitMessage = (comparator, limit, boundKind) => `Comparator ${boundKind === "left" ? invertedComparators[comparator] : comparator} must be ${boundKind === "left" ? "preceded" : "followed"} by a corresponding literal (was '${limit}')`;
export const writeInvalidLimitMessage = (comparator, limit, boundKind) => `Comparator ${boundKind === "left" ? invertedComparators[comparator] : comparator} must be ${boundKind === "left" ? "preceded" : "followed"} by a corresponding literal (was ${limit})`;

@@ -6,3 +6,3 @@ import type { DynamicStateWithRoot } from "../../reduce/dynamic.js";

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;
export declare const writeInvalidDivisorMessage: <divisor extends string | number>(divisor: divisor) => writeInvalidDivisorMessage<divisor>;
export declare const writeInvalidDivisorMessage: <divisor extends string | number>(divisor: divisor) => `% operator must be followed by a non-zero integer literal (was ${divisor})`;
export type writeInvalidDivisorMessage<divisor extends string | number> = `% operator must be followed by a non-zero integer literal (was ${divisor})`;

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

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 Scanner.WhiteSpaceToken ? parseOperator<state.scanTo<s, unscanned>, $, args> : state.error<writeUnexpectedCharacterMessage<lookahead>> : state.finalize<s, "">;
export declare const writeUnexpectedCharacterMessage: <char extends string, shouldBe extends string>(char: char, shouldBe?: shouldBe) => writeUnexpectedCharacterMessage<char, shouldBe>;
export declare const writeUnexpectedCharacterMessage: <char extends string, shouldBe extends string>(char: char, shouldBe?: shouldBe) => `'${char}' is not allowed here${shouldBe extends "" ? "" : ` (should be ${shouldBe})`}`;
export type writeUnexpectedCharacterMessage<char extends string, shouldBe extends string = ""> = `'${char}' is not allowed here${shouldBe extends "" ? "" : ` (should be ${shouldBe})`}`;

@@ -11,0 +11,0 @@ export declare const incompleteArrayTokenMessage = "Missing expected ']'";

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

import type { RawSchema } from "@arktype/schema";
import type { BaseRoot } from "@arktype/schema";
import { type ErrorMessage } from "@arktype/util";

@@ -19,3 +19,3 @@ import type { inferAstRoot } from "../semantic/infer.js";

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

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

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

import { type BaseMeta, type Morph, type Out, type Predicate, type RawSchema, type distillConstrainableIn, type distillConstrainableOut, type inferIntersection, type inferMorphOut, type inferNarrow } from "@arktype/schema";
import { type BaseMeta, type BaseRoot, type Morph, type Out, type Predicate, type distillConstrainableIn, type distillConstrainableOut, type inferIntersection, type inferMorphOut, type inferNarrow } from "@arktype/schema";
import { type Constructor, type Domain, type ErrorMessage, type array, type conform, type show } from "@arktype/util";

@@ -8,4 +8,4 @@ import type { ParseContext } from "../scope.js";

import type { BaseCompletions } from "./string/string.js";
export declare const parseTuple: (def: array, ctx: ParseContext) => RawSchema;
export declare const parseTupleLiteral: (def: array, ctx: ParseContext) => RawSchema;
export declare const parseTuple: (def: array, ctx: ParseContext) => BaseRoot;
export declare const parseTupleLiteral: (def: array, ctx: ParseContext) => BaseRoot;
type InfixExpression = readonly [unknown, InfixOperator, ...unknown[]];

@@ -16,4 +16,4 @@ export type validateTuple<def extends array, $, args> = def extends IndexZeroExpression ? validatePrefixExpression<def, $, args> : def extends PostfixExpression ? validatePostfixExpression<def, $, args> : def extends InfixExpression ? validateInfixExpression<def, $, args> : def extends (readonly ["", ...unknown[]] | readonly [unknown, "", ...unknown[]]) ? readonly [

] : validateTupleLiteral<def, $, args>;
export type validateTupleLiteral<def extends array, $, args> = Readonly<parseSequence<def, $, args>["validated"]>;
type inferTupleLiteral<def extends array, $, args> = parseSequence<def, $, args>["inferred"];
export type validateTupleLiteral<def extends array, $, args> = parseSequence<def, $, args> extends infer s extends SequenceParseState ? Readonly<s["validated"]> : never;
type inferTupleLiteral<def extends array, $, args> = parseSequence<def, $, args> extends infer s extends SequenceParseState ? s["inferred"] : never;
type SequenceParseState = {

@@ -91,4 +91,4 @@ unscanned: array;

}, $, args> : s;
export declare const writeNonArraySpreadMessage: <operand extends string>(operand: operand) => writeNonArraySpreadMessage<operand>;
type writeNonArraySpreadMessage<operand> = `Spread element must be an array${operand extends string ? `(was ${operand})` : ""}`;
export declare const writeNonArraySpreadMessage: <operand extends string>(operand: operand) => `Spread element must be an array${operand extends string ? ` (was ${operand})` : ""}`;
type writeNonArraySpreadMessage<operand> = `Spread element must be an array${operand extends string ? ` (was ${operand})` : ""}`;
export declare const multipleVariadicMesage = "A tuple may have at most one variadic element";

@@ -118,4 +118,4 @@ type multipleVariadicMessage = typeof multipleVariadicMesage;

export type inferKeyOfExpression<operandDef, $, args> = show<keyof inferDefinition<operandDef, $, args>>;
export type PostfixParser<token extends IndexOneOperator> = (def: IndexOneExpression<token>, ctx: ParseContext) => RawSchema;
export type PrefixParser<token extends IndexZeroOperator> = (def: IndexZeroExpression<token>, ctx: ParseContext) => RawSchema;
export type PostfixParser<token extends IndexOneOperator> = (def: IndexOneExpression<token>, ctx: ParseContext) => BaseRoot;
export type PrefixParser<token extends IndexZeroOperator> = (def: IndexZeroExpression<token>, ctx: ParseContext) => BaseRoot;
export type TupleExpression = IndexZeroExpression | IndexOneExpression;

@@ -128,3 +128,3 @@ export type TupleExpressionOperator = IndexZeroOperator | IndexOneOperator;

export declare const parseMorphTuple: PostfixParser<"=>">;
export declare const writeMalformedFunctionalExpressionMessage: (operator: ":" | "=>", value: unknown) => "Narrow expression requires a function following ':' (was string)" | "Narrow expression requires a function following ':' (was number)" | "Narrow expression requires a function following ':' (was bigint)" | "Narrow expression requires a function following ':' (was boolean)" | "Narrow expression requires a function following ':' (was symbol)" | "Narrow expression requires a function following ':' (was undefined)" | "Narrow expression requires a function following ':' (was object)" | "Narrow expression requires a function following ':' (was function)" | "Narrow expression requires a function following '=>' (was string)" | "Narrow expression requires a function following '=>' (was number)" | "Narrow expression requires a function following '=>' (was bigint)" | "Narrow expression requires a function following '=>' (was boolean)" | "Narrow expression requires a function following '=>' (was symbol)" | "Narrow expression requires a function following '=>' (was undefined)" | "Narrow expression requires a function following '=>' (was object)" | "Narrow expression requires a function following '=>' (was function)" | "Morph expression requires a function following ':' (was string)" | "Morph expression requires a function following ':' (was number)" | "Morph expression requires a function following ':' (was bigint)" | "Morph expression requires a function following ':' (was boolean)" | "Morph expression requires a function following ':' (was symbol)" | "Morph expression requires a function following ':' (was undefined)" | "Morph expression requires a function following ':' (was object)" | "Morph expression requires a function following ':' (was function)" | "Morph expression requires a function following '=>' (was string)" | "Morph expression requires a function following '=>' (was number)" | "Morph expression requires a function following '=>' (was bigint)" | "Morph expression requires a function following '=>' (was boolean)" | "Morph expression requires a function following '=>' (was symbol)" | "Morph expression requires a function following '=>' (was undefined)" | "Morph expression requires a function following '=>' (was object)" | "Morph expression requires a function following '=>' (was function)";
export declare const writeMalformedFunctionalExpressionMessage: (operator: ":" | "=>", value: unknown) => string;
export type parseMorph<inDef, morph, $, args> = morph extends Morph ? (In: distillConstrainableIn<inferDefinition<inDef, $, args>>) => Out<inferMorphOut<morph>> : never;

@@ -134,3 +134,3 @@ export declare const parseNarrowTuple: PostfixParser<":">;

export type IndexZeroExpression<token extends IndexZeroOperator = IndexZeroOperator> = readonly [token, ...unknown[]];
export declare const writeInvalidConstructorMessage: <actual extends Domain | "Array" | "Date" | "Error" | "Function" | "Map" | "RegExp" | "Set" | "String" | "Number" | "Boolean" | "WeakMap" | "WeakSet" | "Promise">(actual: actual) => `Expected a constructor following 'instanceof' operator (was ${actual})`;
export declare const writeInvalidConstructorMessage: <actual extends Domain | keyof import("@arktype/util").builtinConstructors>(actual: actual) => string;
export {};

@@ -45,3 +45,3 @@ import { jsObjects, makeRootAndArrayPropertiesMutable, tsKeywords } from "@arktype/schema";

case "required":
if (base.optional)
if (base.optionals)
// e.g. [string?, number]

@@ -63,3 +63,3 @@ return throwParseError(requiredPostOptionalMessage);

// e.g. [string, number?]
base.optional = append(base.optional, element);
base.optionals = append(base.optionals, element);
return base;

@@ -92,3 +92,3 @@ case "variadic":

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

@@ -95,0 +95,0 @@ spread.postfix.forEach(node => appendElement(base, "required", node));

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

import { type ArkConfig, type GenericProps, type PreparsedNodeResolution, type PrivateDeclaration, type RawSchema, type RawSchemaResolutions, RawSchemaScope, type SchemaScope, type UnknownSchema, type ambient, type arkKind, type destructuredExportContext, type destructuredImportContext, type exportedNameOf, type writeDuplicateAliasError } from "@arktype/schema";
import { type isAnyOrNever, type keyError, type nominal, type show } from "@arktype/util";
import { RawRootScope, type ArkConfig, type BaseRoot, type GenericProps, type PreparsedNodeResolution, type PrivateDeclaration, type RawRootResolutions, type RootScope, type UnknownRoot, type ambient, type arkKind, type destructuredExportContext, type destructuredImportContext, type exportedNameOf, type writeDuplicateAliasError } from "@arktype/schema";
import { type anyOrNever, type keyError, type nominal, type show } from "@arktype/util";
import type { type } from "./ark.js";

@@ -8,4 +8,4 @@ import { Generic } from "./generic.js";

import { type inferDefinition, type validateDefinition } from "./parser/definition.js";
import { type GenericDeclaration, type GenericParamsParseError, parseGenericParams } from "./parser/generic.js";
import { type DeclarationParser, type DefinitionParser, RawTypeParser, type Type, type TypeParser } from "./type.js";
import { parseGenericParams, type GenericDeclaration, type GenericParamsParseError } from "./parser/generic.js";
import { RawTypeParser, type DeclarationParser, type DefinitionParser, type Type, type TypeParser } from "./type.js";
export type ScopeParser = <const def>(def: validateScope<def>, config?: ArkConfig) => Scope<inferBootstrapped<bootstrapAliases<def>>>;

@@ -36,3 +36,5 @@ type validateScope<def> = {

type extractGenericParameters<k> = k extends GenericDeclaration<string, infer params> ? params : never;
export type resolve<reference extends keyof $ | keyof args, $, args> = (reference extends keyof args ? args[reference] : $[reference & keyof $]) extends infer resolution ? isAnyOrNever<resolution> extends true ? resolution : resolution extends Def<infer def> ? inferDefinition<def, $, args> : resolution : never;
export type resolve<reference extends keyof $ | keyof args, $, args> = (reference extends keyof args ? args[reference] : $[reference & keyof $]) extends infer resolution ? [
resolution
] extends [anyOrNever] ? resolution : resolution extends Def<infer def> ? inferDefinition<def, $, args> : resolution : never;
export type moduleKeyOf<$> = {

@@ -46,6 +48,6 @@ [k in keyof $]: $[k] extends {

$: RawScope;
args?: Record<string, UnknownSchema>;
args?: Record<string, UnknownRoot>;
}
export declare const scope: ScopeParser;
export interface Scope<$ = any> extends SchemaScope<$> {
export interface Scope<$ = any> extends RootScope<$> {
type: TypeParser<$>;

@@ -58,3 +60,3 @@ match: MatchParser<$>;

}
export declare class RawScope<$ extends RawSchemaResolutions = RawSchemaResolutions> extends RawSchemaScope<$> {
export declare class RawScope<$ extends RawRootResolutions = RawRootResolutions> extends RawRootScope<$> {
private parseCache;

@@ -69,5 +71,5 @@ constructor(def: Record<string, unknown>, config?: ArkConfig);

preparseRoot(def: unknown): unknown;
parseRoot(def: unknown): RawSchema;
parse(def: unknown, ctx: ParseContext): RawSchema;
parseString(def: string, ctx: ParseContext): RawSchema;
parseRoot(def: unknown): BaseRoot;
parse(def: unknown, ctx: ParseContext): BaseRoot;
parseString(def: string, ctx: ParseContext): BaseRoot;
}

@@ -74,0 +76,0 @@ export declare const writeShallowCycleErrorMessage: (name: string, seen: string[]) => string;

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

import { RawSchemaScope, hasArkKind } from "@arktype/schema";
import { RawRootScope, hasArkKind } from "@arktype/schema";
import { domainOf, hasDomain, isThunk, throwParseError } from "@arktype/util";

@@ -11,3 +11,3 @@ import { Generic } from "./generic.js";

export const scope = ((def, config = {}) => new RawScope(def, config));
export class RawScope extends RawSchemaScope {
export class RawScope extends RawRootScope {
parseCache = {};

@@ -38,3 +38,3 @@ constructor(def, config) {

parseRoot(def) {
// args: { this: {} as RawSchema },
// args: { this: {} as RawRoot },
return this.parse(def, {

@@ -63,5 +63,5 @@ $: this,

parseString(def, ctx) {
return (this.maybeResolveSchema(def) ??
return (this.maybeResolveRoot(def) ??
((def.endsWith("[]") &&
this.maybeResolveSchema(def.slice(0, -2))?.array()) ||
this.maybeResolveRoot(def.slice(0, -2))?.array()) ||
fullStringParse(new DynamicState(def, ctx))));

@@ -68,0 +68,0 @@ }

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

import { ArkErrors, type BaseMeta, type BaseRoot, type Disjoint, type Morph, type NodeDef, type Out, type Predicate, type PrimitiveConstraintKind, RawSchema, type Schema, type ambient, type constrain, type constraintKindOf, type distillConstrainableOut, type distillIn, type distillOut, type includesMorphs, type inferIntersection, type inferMorphOut, type inferNarrow, type inferPipes, type internalImplementationOf } from "@arktype/schema";
import { ArkErrors, BaseRoot, type BaseMeta, type Disjoint, type InnerRoot, type Morph, type NodeSchema, type Out, type Predicate, type PrimitiveConstraintKind, type Root, type ambient, type constrain, type constraintKindOf, type distillConstrainableOut, type distillIn, type distillOut, type includesMorphs, type inferIntersection, type inferMorphOut, type inferNarrow, type inferPipes, type internalImplementationOf } from "@arktype/schema";
import { Callable, type Constructor, type array, type conform } from "@arktype/util";

@@ -18,3 +18,3 @@ import { Generic, type validateParameterString } from "./generic.js";

}
export declare class RawTypeParser extends Callable<(...args: unknown[]) => RawSchema | Generic, TypeParserAttachments> {
export declare class RawTypeParser extends Callable<(...args: unknown[]) => BaseRoot | Generic, TypeParserAttachments> {
constructor($: RawScope);

@@ -25,3 +25,3 @@ }

};
declare class _Type<t = unknown, $ = any> extends BaseRoot<t, $> implements internalImplementationOf<Schema> {
declare class _Type<t = unknown, $ = any> extends InnerRoot<t, $> implements internalImplementationOf<Root> {
$: Scope<$>;

@@ -47,3 +47,3 @@ get in(): Type<this["tIn"], $>;

extends<def>(other: validateTypeRoot<def, $>): this is Type<inferTypeRoot<def>, $>;
constrain<kind extends PrimitiveConstraintKind, const def extends NodeDef<kind>>(kind: conform<kind, constraintKindOf<this["inferIn"]>>, def: def): Type<constrain<t, kind, def>, $>;
constrain<kind extends PrimitiveConstraintKind, const def extends NodeSchema<kind>>(kind: conform<kind, constraintKindOf<this["inferIn"]>>, def: def): Type<constrain<t, kind, def>, $>;
}

@@ -50,0 +50,0 @@ export interface Type<

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

import { ArkErrors, RawSchema } from "@arktype/schema";
import { ArkErrors, BaseRoot } from "@arktype/schema";
import { Callable } from "@arktype/util";

@@ -33,2 +33,2 @@ import { Generic } from "./generic.js";

}
export const Type = RawSchema;
export const Type = BaseRoot;
{
"name": "arktype",
"description": "TypeScript's 1:1 validator, optimized from editor to runtime",
"version": "2.0.0-dev.10",
"version": "2.0.0-dev.11",
"license": "MIT",

@@ -16,8 +16,8 @@ "author": {

"type": "module",
"main": "./out/main.js",
"types": "./out/main.d.ts",
"main": "./out/api.js",
"types": "./out/api.d.ts",
"exports": {
".": {
"types": "./out/main.d.ts",
"default": "./out/main.js"
"types": "./out/api.d.ts",
"default": "./out/api.js"
},

@@ -33,5 +33,3 @@ "./config": {

"files": [
"out",
"!__tests__",
"**/*.ts"
"out"
],

@@ -43,5 +41,5 @@ "scripts": {

"dependencies": {
"@arktype/util": "0.0.36",
"@arktype/schema": "0.1.1"
"@arktype/util": "0.0.38",
"@arktype/schema": "0.1.2"
}
}
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