Socket
Socket
Sign inDemoInstall

arktype

Package Overview
Dependencies
Maintainers
1
Versions
100
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

arktype - npm Package Compare versions

Comparing version 2.0.0-rc.0 to 2.0.0-rc.1

out/keywords/builtins.d.ts

15

out/generic.d.ts

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

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 { GenericRoot, type arkKind, type GenericAst, type GenericParamAst, type GenericParamDef, type genericParamNames, type LazyGenericBody } from "@ark/schema";
import { type array, type Callable, type conform, type ErrorMessage, type ErrorType, type Hkt, type Json, type WhiteSpaceToken } from "@ark/util";
import type { inferDefinition, validateDefinition } from "./parser/definition.ts";

@@ -121,3 +121,6 @@ import type { inferAstRoot } from "./parser/semantic/infer.ts";

internal: GenericRoot;
json: Json;
}
export type GenericConstructor<params extends array<GenericParamAst> = array<GenericParamAst>, bodyDef = unknown, $ = {}, arg$ = {}> = new () => Generic<params, bodyDef, $, arg$>;
export declare const Generic: GenericConstructor;
export type GenericDeclaration<name extends string = string, params extends ParameterString = ParameterString> = `${name}${params}`;

@@ -130,10 +133,10 @@ export type parseValidGenericParams<def extends ParameterString, $> = conform<parseGenericParams<extractParams<def>, $>, array<GenericParamAst>>;

], $>;
type ParamsTerminator = WhiteSpaceToken | "," | ":";
type ParamsTerminator = WhiteSpaceToken | ",";
declare const parseName: (scanner: Scanner, result: GenericParamDef[], ctx: ParseContext) => GenericParamDef[];
type parseName<unscanned extends string, result extends array<GenericParamAst>, $> = parseNextNameChar<Scanner.skipWhitespace<unscanned>, "", result, $>;
type parseNextNameChar<unscanned extends string, name extends string, result extends array<GenericParamAst>, $> = unscanned extends `${infer lookahead}${infer nextUnscanned}` ? lookahead extends ParamsTerminator ? name extends "" ? ErrorMessage<emptyGenericParameterMessage> : lookahead extends "," ? parseName<nextUnscanned, [...result, [name, unknown]], $> : lookahead extends ":" | WhiteSpaceToken ? _parseOptionalConstraint<unscanned, name, result, $> : never : parseNextNameChar<nextUnscanned, `${name}${lookahead}`, result, $> : name extends "" ? result : [...result, [name, unknown]];
type parseNextNameChar<unscanned extends string, name extends string, result extends array<GenericParamAst>, $> = unscanned extends `${infer lookahead}${infer nextUnscanned}` ? lookahead extends ParamsTerminator ? name extends "" ? ErrorMessage<emptyGenericParameterMessage> : lookahead extends "," ? parseName<nextUnscanned, [...result, [name, unknown]], $> : lookahead extends WhiteSpaceToken ? _parseOptionalConstraint<nextUnscanned, name, result, $> : never : parseNextNameChar<nextUnscanned, `${name}${lookahead}`, result, $> : name extends "" ? result : [...result, [name, unknown]];
declare const extendsToken = "extends ";
type ConstrainingToken = ":" | typeof extendsToken;
type extendsToken = typeof extendsToken;
declare const _parseOptionalConstraint: (scanner: Scanner, name: string, result: GenericParamDef[], ctx: ParseContext) => GenericParamDef[];
type _parseOptionalConstraint<unscanned extends string, name extends string, result extends array<GenericParamAst>, $> = Scanner.skipWhitespace<unscanned> extends (`${ConstrainingToken}${infer nextUnscanned}`) ? parseUntilFinalizer<state.initialize<nextUnscanned>, $, {}> extends (infer finalArgState extends StaticState) ? validateAst<finalArgState["root"], $, {}> extends (infer e extends ErrorMessage) ? e : parseName<finalArgState["unscanned"], [
type _parseOptionalConstraint<unscanned extends string, name extends string, result extends array<GenericParamAst>, $> = Scanner.skipWhitespace<unscanned> extends (`${extendsToken}${infer nextUnscanned}`) ? parseUntilFinalizer<state.initialize<nextUnscanned>, $, {}> extends (infer finalArgState extends StaticState) ? validateAst<finalArgState["root"], $, {}> extends (infer e extends ErrorMessage) ? e : parseName<finalArgState["unscanned"], [
...result,

@@ -140,0 +143,0 @@ [name, inferAstRoot<finalArgState["root"], $, {}>]

6

out/generic.js

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

import { GenericRoot } from "@ark/schema";
import { throwParseError } from "@ark/util";

@@ -5,2 +6,3 @@ import { DynamicState } from "./parser/string/reduce/dynamic.js";

import { parseUntilFinalizer } from "./parser/string/string.js";
export const Generic = GenericRoot;
export const emptyGenericParameterMessage = "An empty string is not a valid generic parameter name";

@@ -24,5 +26,3 @@ export const parseGenericParams = (def, ctx) => parseName(new Scanner(def), [], ctx);

scanner.shiftUntilNonWhitespace();
if (scanner.lookahead === ":")
scanner.shift();
else if (scanner.unscanned.startsWith(extendsToken))
if (scanner.unscanned.startsWith(extendsToken))
scanner.jumpForward(extendsToken.length);

@@ -29,0 +29,0 @@ else {

export { ArkError, ArkErrors, type ArkConfig, type ArkScopeConfig, type JsonSchema } from "@ark/schema";
export { Hkt } from "@ark/util";
export type { Generic } from "./generic.ts";
export { ambient, ark, declare, define, generic, type } from "./keywords/ark.ts";
export { Generic } from "./generic.ts";
export { ambient, ark, declare, define, generic, type, type Ark } from "./keywords/ark.ts";
export { Module, type BoundModule, type Submodule } from "./module.ts";
export { module, 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 { Generic } from "./generic.js";
export { ambient, ark, declare, define, generic, type } from "./keywords/ark.js";

@@ -4,0 +5,0 @@ export { Module } from "./module.js";

@@ -1,21 +0,27 @@

import type { ArkErrors } from "@ark/schema";
import type { ArkErrors, arkKind } from "@ark/schema";
import type { inferred } from "@ark/util";
import type { GenericParser } from "../generic.ts";
import type { Module } from "../module.ts";
import type { BoundModule, Module } from "../module.ts";
import { type Scope } from "../scope.ts";
import type { DeclarationParser, DefinitionParser, TypeParser } from "../type.ts";
import { arkBuiltin } from "./builtin.ts";
import { arkBuiltins } from "./builtins.ts";
import { arkPrototypes } from "./constructors/constructors.ts";
import { number } from "./number/number.ts";
import { string } from "./string/string.ts";
import { arkTs } from "./ts.ts";
export interface Ark extends Omit<Ark.keywords, keyof Ark.Wrapped>, Ark.Wrapped {
import { arkTsGenerics, arkTsKeywords } from "./ts.ts";
export interface Ark extends Omit<Ark.keywords, keyof Ark.wrapped>, Ark.wrapped {
}
export declare namespace Ark {
interface keywords extends arkTs, arkPrototypes, arkBuiltin {
interface keywords extends arkTsKeywords.$, arkTsGenerics.$, arkPrototypes.keywords, arkBuiltins.$ {
}
interface Wrapped {
interface wrapped extends arkPrototypes.wrapped {
string: string.submodule;
number: number.submodule;
}
interface typeAttachments extends arkTsKeywords.$ {
Key: arkBuiltins.$["Key"];
Record: arkTsGenerics.$["Record"];
}
interface boundTypeAttachments<$> extends Omit<BoundModule<typeAttachments, $>, arkKind> {
}
}

@@ -22,0 +28,0 @@ export declare const ambient: Scope<Ark>;

@@ -1,11 +0,17 @@

import { scope } from "../scope.js";
import { arkBuiltin } from "./builtin.js";
import { $arkTypeRegistry, scope } from "../scope.js";
import { arkBuiltins } from "./builtins.js";
import { arkPrototypes } from "./constructors/constructors.js";
import { number } from "./number/number.js";
import { string } from "./string/string.js";
import { arkTs } from "./ts.js";
import { arkTsGenerics, arkTsKeywords } from "./ts.js";
$arkTypeRegistry.typeAttachments = {
...arkTsKeywords,
Key: arkBuiltins.Key,
Record: arkTsGenerics.Record
};
export const ambient = scope({
...arkTs,
...arkTsKeywords,
...arkTsGenerics,
...arkPrototypes,
...arkBuiltin,
...arkBuiltins,
string,

@@ -12,0 +18,0 @@ number

@@ -8,10 +8,14 @@ import { Hkt, liftArray, type Digit } from "@ark/util";

declare const liftFrom: import("@ark/schema").GenericRoot<readonly [["element", unknown]], liftFromHkt>;
export declare const ArrayModule: Module<ArrayModule>;
export type ArrayModule = Submodule<{
$root: unknown[];
readonly: readonly unknown[];
index: NonNegativeIntegerString;
liftFrom: typeof liftFrom.t;
}>;
export declare const arkArray: arkArray.module;
export declare namespace arkArray {
type module = Module<submodule>;
type submodule = Submodule<$>;
type $ = {
$root: unknown[];
readonly: readonly unknown[];
index: NonNegativeIntegerString;
liftFrom: typeof liftFrom.t;
};
}
export type NonNegativeIntegerString = `${Digit}` | (`${Exclude<Digit, 0>}${string}` & `${bigint}`);
export {};

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

}, liftFromHkt);
export const ArrayModule = submodule({
export const arkArray = submodule({
$root: intrinsic.Array,

@@ -17,0 +17,0 @@ readonly: "$root",

@@ -0,41 +1,31 @@

import { type EcmascriptObjects, type PlatformObjects } from "@ark/util";
import type { Module, Submodule } from "../../module.ts";
import { ArrayModule } from "./Array.ts";
import { FormDataModule } from "./FormData.ts";
import { arkArray } from "./Array.ts";
import { arkFormData } from "./FormData.ts";
import { TypedArray } from "./TypedArray.ts";
export declare const arkPrototypes: Module<arkPrototypes>;
export type arkPrototypes = arkPrototypes.submodule;
declare const omittedPrototypes: {
Boolean: 1;
Number: 1;
String: 1;
};
export declare const arkPrototypes: arkPrototypes.module;
export declare namespace arkPrototypes {
type module = Module<submodule>;
type submodule = Submodule<$>;
interface $ extends Omit<ecmascript, keyof Wrapped>, platform, Wrapped {
interface keywords extends ecmascript, platform {
}
interface Wrapped {
Array: ArrayModule;
TypedArray: TypedArray;
interface $ extends Omit<keywords, keyof wrapped>, wrapped {
}
type ecmascript = {
Array: Array<unknown>;
Date: Date;
Error: Error;
Function: Function;
Map: Map<unknown, unknown>;
RegExp: RegExp;
Set: Set<unknown>;
WeakMap: WeakMap<object, unknown>;
WeakSet: WeakSet<object>;
Promise: Promise<unknown>;
};
type platform = {
ArrayBuffer: ArrayBuffer;
Blob: Blob;
File: File;
FormData: FormDataModule;
Headers: Headers;
Request: Request;
Response: Response;
URL: URL;
};
interface instances extends ecmascript, platform, TypedArray {
interface wrapped {
Array: arkArray.submodule;
TypedArray: TypedArray.submodule;
FormData: arkFormData.submodule;
}
type ecmascript = Omit<EcmascriptObjects, keyof typeof omittedPrototypes>;
type platform = PlatformObjects;
interface instances extends ecmascript, platform {
}
type instanceOf<name extends keyof instances = keyof instances> = instances[name];
type instanceOfExcluding<name extends keyof instances = keyof instances> = instances[Exclude<keyof instances, name>];
}
export {};

@@ -1,31 +0,16 @@

import { registry } from "@ark/util";
import { ecmascriptConstructors, flatMorph, platformConstructors } from "@ark/util";
import { submodule } from "../utils.js";
import { ArrayModule } from "./Array.js";
import { FormDataModule } from "./FormData.js";
import { arkArray } from "./Array.js";
import { arkFormData } from "./FormData.js";
import { TypedArray } from "./TypedArray.js";
const omittedPrototypes = {
Boolean: 1,
Number: 1,
String: 1
};
export const arkPrototypes = submodule({
// ECMAScript Objects
// See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects
Array: ArrayModule,
Date: ["instanceof", Date],
Error: ["instanceof", Error],
Function: ["instanceof", Function],
Map: ["instanceof", Map],
RegExp: ["instanceof", RegExp],
Set: ["instanceof", Set],
WeakMap: ["instanceof", WeakMap],
WeakSet: ["instanceof", WeakSet],
Promise: ["instanceof", Promise],
...flatMorph({ ...ecmascriptConstructors, ...platformConstructors }, (k, v) => (k in omittedPrototypes ? [] : [k, ["instanceof", v]])),
Array: arkArray,
TypedArray,
// Platform APIs
// See https://developer.mozilla.org/en-US/docs/Web/API
// Must be implemented in Node etc. as well as the browser to include here
ArrayBuffer: ["instanceof", ArrayBuffer],
Blob: ["instanceof", Blob],
File: ["instanceof", registry.FileConstructor],
FormData: FormDataModule,
Headers: ["instanceof", Headers],
Request: ["instanceof", Request],
Response: ["instanceof", Response],
URL: ["instanceof", URL]
FormData: arkFormData
});
import type { Module, Submodule } from "../../module.ts";
import type { Out } from "../ast.ts";
import type { To } from "../ast.ts";
export type FormDataValue = string | File;
export type ParsedFormData = Record<string, FormDataValue | FormDataValue[]>;
export declare const FormDataModule: Module<FormDataModule>;
export type FormDataModule = Submodule<{
$root: FormData;
parse: (In: FormData) => Out<ParsedFormData>;
}>;
export declare const arkFormData: arkFormData.module;
export declare namespace arkFormData {
type module = Module<submodule>;
type submodule = Submodule<$>;
type $ = {
$root: FormData;
value: FormDataValue;
parse: (In: FormData) => To<ParsedFormData>;
parsed: ParsedFormData;
};
}
import { rootNode } from "@ark/schema";
import { registry } from "@ark/util";
import { submodule } from "../utils.js";
export const FormDataModule = submodule({
const value = rootNode(["string", registry.FileConstructor]);
const parsedFormDataValue = value.or(value.array());
const parsed = rootNode({
meta: "an object representing parsed form data",
domain: "object",
index: {
signature: "string",
value: parsedFormDataValue
}
});
export const arkFormData = submodule({
$root: ["instanceof", FormData],
value,
parsed,
parse: rootNode({

@@ -23,4 +35,5 @@ in: FormData,

return result;
}
},
declaredOut: parsed
})
});
import type { Module, Submodule } from "../../module.ts";
export declare const TypedArray: Module<TypedArray>;
export type TypedArray = Submodule<{
Int8: Int8Array;
Uint8: Uint8Array;
Uint8Clamped: Uint8ClampedArray;
Int16: Int16Array;
Uint16: Uint16Array;
Int32: Int32Array;
Uint32: Uint32Array;
Float32: Float32Array;
Float64: Float64Array;
BigInt64: BigInt64Array;
BigUint64: BigUint64Array;
}>;
export declare const TypedArray: TypedArray.module;
export declare namespace TypedArray {
type module = Module<TypedArray.$>;
type submodule = Submodule<$>;
type $ = {
Int8: Int8Array;
Uint8: Uint8Array;
Uint8Clamped: Uint8ClampedArray;
Int16: Int16Array;
Uint16: Uint16Array;
Int32: Int32Array;
Uint32: Uint32Array;
Float32: Float32Array;
Float64: Float64Array;
BigInt64: BigInt64Array;
BigUint64: BigUint64Array;
};
}

@@ -6,3 +6,3 @@ import { type Constraint, type NodeSchema } from "@ark/schema";

import { integer } from "./integer.ts";
export declare const number: Module<number.submodule>;
export declare const number: number.module;
export declare namespace number {

@@ -22,7 +22,9 @@ type atLeast<rule> = constrain<number, AtLeast<rule>>;

} ? lessThan<rule> : atMost<rule> : kind extends "divisor" ? divisibleBy<rule> : narrowed : never;
type submodule = Submodule<{
type module = Module<submodule>;
type submodule = Submodule<$>;
type $ = {
$root: number;
epoch: epoch;
integer: integer;
}>;
};
}

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

import type { Submodule } from "../../module.ts";
import type { Module, Submodule } from "../../module.ts";
import type { Branded, constrain, To } from "../ast.ts";

@@ -6,10 +6,11 @@ declare namespace string {

}
export type capitalize = Submodule<{
$root: (In: string) => To<string.capitalized>;
preformatted: string.capitalized;
}>;
export declare const capitalize: import("../../module.ts").Module<{
$root: object;
preformatted: object;
}>;
export declare const capitalize: capitalize.module;
export declare namespace capitalize {
type module = Module<submodule>;
type submodule = Submodule<$>;
type $ = {
$root: (In: string) => To<string.capitalized>;
preformatted: string.capitalized;
};
}
export {};

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

import type { Submodule } from "../../module.ts";
import type { Module, Submodule } from "../../module.ts";
import type { type } from "../ark.ts";
import type { Branded, To, constrain } from "../ast.ts";

@@ -23,14 +24,2 @@ type DayDelimiter = "." | "/" | "-";

export declare const tryParseDatePattern: (data: string, opts?: DateOptions) => Date | string;
export declare const date: import("../../module.ts").Module<{
$root: object;
epoch: Submodule<{
$root: object;
parse: object;
}>;
parse: object;
iso: Submodule<{
$root: object;
parse: object;
}>;
}>;
declare namespace string {

@@ -43,14 +32,30 @@ type date = constrain<string, Branded<"date">>;

}
export type date = Submodule<{
$root: string.date;
parse: (In: string.date) => To<Date>;
iso: Submodule<{
$root: string.date.iso;
parse: (In: string.date.iso) => To<Date>;
}>;
epoch: Submodule<{
$root: string.date.epoch;
parse: (In: string.date.epoch) => To<Date>;
}>;
}>;
export declare const stringDate: stringDate.module;
export declare namespace stringDate {
type module = Module<stringDate.submodule>;
type submodule = Submodule<$>;
type $ = {
$root: string.date;
parse: (In: string.date) => To<Date>;
iso: iso.submodule;
epoch: epoch.submodule;
};
type shallowResolutions = {
[k in keyof $ as `string.date.${k}`]: $[k] extends type.cast<infer t> ? t : $[k];
};
namespace iso {
type submodule = Submodule<$>;
type $ = {
$root: string.date.iso;
parse: (In: string.date.iso) => To<Date>;
};
}
namespace epoch {
type submodule = Submodule<$>;
type $ = {
$root: string.date.epoch;
parse: (In: string.date.epoch) => To<Date>;
};
}
}
export {};

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

});
export const date = submodule({
export const stringDate = submodule({
$root: parsableDate,

@@ -86,0 +86,0 @@ parse: rootNode({

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

import type { Submodule } from "../../module.ts";
import type { Module, Submodule } from "../../module.ts";
import type { Branded, constrain, To } from "../ast.ts";

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

}
export declare const integer: import("../../module.ts").Module<{
$root: object;
parse: object;
}>;
export type integer = Submodule<{
$root: string.integer;
parse: (In: string.integer) => To<number.divisibleBy<1>>;
}>;
export declare const integer: stringInteger.module;
export declare namespace stringInteger {
type module = Module<submodule>;
type submodule = Submodule<$>;
type $ = {
$root: string.integer;
parse: (In: string.integer) => To<number.divisibleBy<1>>;
};
}
export {};

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

import type { Submodule } from "../../module.ts";
import type { Module, Submodule } from "../../module.ts";
import type { Branded, constrain } from "../ast.ts";

@@ -10,12 +10,12 @@ declare namespace string {

}
export declare const ip: import("../../module.ts").Module<{
$root: unknown;
v4: object;
v6: object;
}>;
export type ip = Submodule<{
$root: string.ip;
v4: string.ip.v4;
v6: string.ip.v6;
}>;
export declare const ip: ip.module;
export declare namespace ip {
type module = Module<submodule>;
type submodule = Submodule<$>;
type $ = {
$root: string.ip;
v4: string.ip.v4;
v6: string.ip.v6;
};
}
export {};

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

import type { Submodule } from "../../module.ts";
import type { Module, Submodule } from "../../module.ts";
import type { Branded, To, constrain } from "../ast.ts";

@@ -6,10 +6,11 @@ declare namespace string {

}
export declare const json: import("../../module.ts").Module<{
$root: object;
parse: object;
}>;
export type json = Submodule<{
$root: string.json;
parse: (In: string.json) => To<object>;
}>;
export declare const json: stringJson.module;
export declare namespace stringJson {
type module = Module<submodule>;
type submodule = Submodule<$>;
type $ = {
$root: string.json;
parse: (In: string.json) => To<object>;
};
}
export {};

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

import type { Submodule } from "../../module.ts";
import type { Module, Submodule } from "../../module.ts";
import type { Branded, constrain, To } from "../ast.ts";

@@ -6,10 +6,11 @@ declare namespace string {

}
export type lower = Submodule<{
$root: (In: string) => To<string.lowercase>;
preformatted: string.lowercase;
}>;
export declare const lower: import("../../module.ts").Module<{
$root: object;
preformatted: object;
}>;
export declare const lower: lower.module;
export declare namespace lower {
type module = Module<submodule>;
type submodule = Submodule<$>;
type $ = {
$root: (In: string) => To<string.lowercase>;
preformatted: string.lowercase;
};
}
export {};

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

import type { Submodule } from "../../module.ts";
import type { Module, Submodule } from "../../module.ts";
import type { type } from "../ark.ts";
import type { Branded, constrain, To } from "../ast.ts";

@@ -14,35 +15,19 @@ declare namespace string {

export type NormalizedForm = (typeof normalizedForms)[number];
export type NFC = Submodule<{
$root: (In: string) => To<string.normalized.NFC>;
preformatted: string.normalized.NFC;
}>;
export declare const NFC: import("../../module.ts").Module<{
export declare const NFC: Module<{
$root: object;
preformatted: object;
}>;
export type NFD = Submodule<{
$root: (In: string) => To<string.normalized.NFD>;
preformatted: string.normalized.NFD;
}>;
export declare const NFD: import("../../module.ts").Module<{
export declare const NFD: Module<{
$root: object;
preformatted: object;
}>;
export type NFKC = Submodule<{
$root: (In: string) => To<string.normalized.NFKC>;
preformatted: string.normalized.NFKC;
}>;
export declare const NFKC: import("../../module.ts").Module<{
export declare const NFKC: Module<{
$root: object;
preformatted: object;
}>;
export type NFKD = Submodule<{
$root: (In: string) => To<string.normalized.NFKD>;
preformatted: string.normalized.NFKD;
}>;
export declare const NFKD: import("../../module.ts").Module<{
export declare const NFKD: Module<{
$root: object;
preformatted: object;
}>;
export declare const normalize: import("../../module.ts").Module<{
export declare const normalize: Module<{
$root: object;

@@ -66,9 +51,44 @@ NFC: Submodule<{

}>;
export type normalize = Submodule<{
$root: (In: string) => To<string.normalized.NFC>;
NFC: NFC;
NFD: NFD;
NFKC: NFKC;
NFKD: NFKD;
}>;
export declare namespace normalize {
type module = Module<submodule>;
type submodule = Submodule<$>;
type $ = {
$root: (In: string) => To<string.normalized.NFC>;
NFC: NFC.submodule;
NFD: NFD.submodule;
NFKC: NFKC.submodule;
NFKD: NFKD.submodule;
};
type shallowResolutions = {
[k in keyof $ as `string.normalize.${k}`]: $[k] extends type.cast<infer t> ? t : $[k];
};
namespace NFC {
type submodule = Submodule<$>;
type $ = {
$root: (In: string) => To<string.normalized.NFC>;
preformatted: string.normalized.NFC;
};
}
namespace NFD {
type submodule = Submodule<$>;
type $ = {
$root: (In: string) => To<string.normalized.NFD>;
preformatted: string.normalized.NFD;
};
}
namespace NFKC {
type submodule = Submodule<$>;
type $ = {
$root: (In: string) => To<string.normalized.NFKC>;
preformatted: string.normalized.NFKC;
};
}
namespace NFKD {
type submodule = Submodule<$>;
type $ = {
$root: (In: string) => To<string.normalized.NFKD>;
preformatted: string.normalized.NFKD;
};
}
}
export {};

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

import type { Submodule } from "../../module.ts";
import type { Module, Submodule } from "../../module.ts";
import type { Branded, constrain, To } from "../ast.ts";

@@ -6,10 +6,11 @@ declare namespace string {

}
export declare const numeric: import("../../module.ts").Module<{
$root: object;
parse: object;
}>;
export type numeric = Submodule<{
$root: string.numeric;
parse: (In: string.numeric) => To<number>;
}>;
export declare const numeric: stringNumeric.module;
export declare namespace stringNumeric {
type module = Module<submodule>;
type submodule = Submodule<$>;
type $ = {
$root: string.numeric;
parse: (In: string.numeric) => To<number>;
};
}
export {};
import { type Constraint, type NodeSchema } from "@ark/schema";
import type { Module, Submodule } from "../../module.ts";
import type { type } from "../ark.ts";
import type { AtLeastLength, AtMostLength, Branded, Constraints, ExactlyLength, LessThanLength, Matching, MoreThanLength, Narrowed, constrain, normalizePrimitiveConstraintRoot } from "../ast.ts";

@@ -8,16 +9,65 @@ import { alpha } from "./alpha.ts";

import { creditCard } from "./creditCard.ts";
import { date } from "./date.ts";
import { stringDate } from "./date.ts";
import { digits } from "./digits.ts";
import { email } from "./email.ts";
import { integer } from "./integer.ts";
import { type stringInteger } from "./integer.ts";
import { ip } from "./ip.ts";
import { json } from "./json.ts";
import { type stringJson } from "./json.ts";
import { lower } from "./lower.ts";
import { normalize } from "./normalize.ts";
import { numeric } from "./numeric.ts";
import { type stringNumeric } from "./numeric.ts";
import { semver } from "./semver.ts";
import { trim } from "./trim.ts";
import { upper } from "./upper.ts";
import { url } from "./url.ts";
import { uuid } from "./uuid.ts";
export declare const string: Module<string.submodule>;
export declare const string: Module<{
trim: Submodule<trim.submodule>;
normalize: Submodule<{
$root: object;
NFC: Submodule<{
$root: object;
preformatted: object;
}>;
NFD: Submodule<{
$root: object;
preformatted: object;
}>;
NFKC: Submodule<{
$root: object;
preformatted: object;
}>;
NFKD: Submodule<{
$root: object;
preformatted: object;
}>;
}>;
json: Submodule<stringJson.submodule>;
$root: object;
integer: Submodule<stringInteger.submodule>;
alpha: object;
alphanumeric: object;
digits: object;
numeric: Submodule<stringNumeric.submodule>;
creditCard: object;
email: object;
uuid: Submodule<{
$root: string.matching<string> | "00000000-0000-0000-0000-000000000000" | "ffffffff-ffff-ffff-ffff-ffffffffffff";
v4: object;
v6: object;
v1: object;
v2: object;
v3: object;
v5: object;
v7: object;
v8: object;
}>;
semver: object;
ip: Submodule<ip.submodule>;
date: Submodule<stringDate.submodule>;
capitalize: Submodule<capitalize.submodule>;
lower: Submodule<lower.submodule>;
upper: Submodule<upper.submodule>;
url: Submodule<url.submodule>;
}>;
export declare namespace string {

@@ -38,3 +88,5 @@ type atLeastLength<rule> = constrain<string, AtLeastLength<rule>>;

} ? lessThanLength<rule> : atMostLength<rule> : kind extends "pattern" ? matching<rule & string> : kind extends "exactLength" ? exactlyLength<rule> : narrowed : never;
type submodule = Submodule<{
type module = Module<string.submodule>;
type submodule = Submodule<$>;
type $ = {
$root: string;

@@ -44,17 +96,20 @@ alpha: alpha;

digits: digits;
numeric: numeric;
integer: integer;
numeric: stringNumeric.submodule;
integer: stringInteger.submodule;
creditCard: creditCard;
email: email;
uuid: uuid;
uuid: uuid.submodule;
semver: semver;
ip: ip;
json: json;
date: date;
trim: trim;
normalize: normalize;
capitalize: capitalize;
lower: lower;
upper: upper;
}>;
ip: ip.submodule;
json: stringJson.submodule;
date: stringDate.submodule;
trim: trim.submodule;
normalize: normalize.submodule;
capitalize: capitalize.submodule;
lower: lower.submodule;
upper: upper.submodule;
};
type shallowResolutions = {
[k in keyof $ as `string.${k}`]: $[k] extends type.cast<infer t> ? t : $[k];
};
}

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

import { creditCard } from "./creditCard.js";
import { date } from "./date.js";
import { stringDate } from "./date.js";
import { digits } from "./digits.js";

@@ -41,3 +41,3 @@ import { email } from "./email.js";

capitalize,
date
date: stringDate
});

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

import type { Submodule } from "../../module.ts";
import type { Module, Submodule } from "../../module.ts";
import type { Branded, constrain, To } from "../ast.ts";

@@ -6,10 +6,11 @@ declare namespace string {

}
export type trim = Submodule<{
$root: (In: string) => To<string.trimmed>;
preformatted: string.trimmed;
}>;
export declare const trim: import("../../module.ts").Module<{
$root: object;
preformatted: object;
}>;
export declare const trim: trim.module;
export declare namespace trim {
type module = Module<submodule>;
type submodule = Submodule<$>;
type $ = {
$root: (In: string) => To<string.trimmed>;
preformatted: string.trimmed;
};
}
export {};

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

import type { Submodule } from "../../module.ts";
import type { Module, Submodule } from "../../module.ts";
import type { Branded, constrain, To } from "../ast.ts";

@@ -6,10 +6,11 @@ declare namespace string {

}
export type upper = Submodule<{
$root: (In: string) => To<string.uppercase>;
preformatted: string.uppercase;
}>;
export declare const upper: import("../../module.ts").Module<{
$root: object;
preformatted: object;
}>;
export declare const upper: upper.module;
export declare namespace upper {
type module = Module<submodule>;
type submodule = Submodule<$>;
type $ = {
$root: (In: string) => To<string.uppercase>;
preformatted: string.uppercase;
};
}
export {};

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

import type { Submodule } from "../../module.ts";
import type { Module, Submodule } from "../../module.ts";
import type { Branded, constrain, To } from "../ast.ts";

@@ -6,10 +6,11 @@ declare namespace string {

}
export declare const url: import("../../module.ts").Module<{
$root: object;
parse: object;
}>;
export type url = Submodule<{
$root: string.url;
parse: (In: string.url) => To<URL>;
}>;
export declare const url: url.module;
export declare namespace url {
type module = Module<submodule>;
type submodule = Submodule<$>;
type $ = {
$root: string.url;
parse: (In: string.url) => To<URL>;
};
}
export {};

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

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

@@ -27,13 +27,17 @@ v4: object;

}
export type uuid = Submodule<{
$root: string.uuid;
v1: string.uuid.v1;
v2: string.uuid.v2;
v3: string.uuid.v3;
v4: string.uuid.v4;
v5: string.uuid.v5;
v6: string.uuid.v6;
v7: string.uuid.v7;
v8: string.uuid.v8;
}>;
export declare namespace uuid {
type module = Module<submodule>;
type submodule = Submodule<$>;
type $ = {
$root: string.uuid;
v1: string.uuid.v1;
v2: string.uuid.v2;
v3: string.uuid.v3;
v4: string.uuid.v4;
v5: string.uuid.v5;
v6: string.uuid.v6;
v7: string.uuid.v7;
v8: string.uuid.v8;
};
}
export {};
import { Hkt, type Key, type omit, type pick, type show } from "@ark/util";
import type { Module, Submodule } from "../module.ts";
export declare const arkTsKeywords: arkTsKeywords;
export type arkTsKeywords = Module<arkTsKeywords.$>;
export declare namespace arkTsKeywords {
type submodule = Submodule<$>;
type $ = {
bigint: bigint;
boolean: boolean;
false: false;
never: never;
null: null;
number: number;
object: object;
string: string;
symbol: symbol;
true: true;
unknown: unknown;
undefined: undefined;
};
}
declare class RecordHkt extends Hkt<[Key, unknown]> {

@@ -31,24 +50,16 @@ body: Record<this[0], this[1]>;

declare const Extract: import("@ark/schema").GenericRoot<readonly [["T", unknown], ["U", unknown]], ExtractHkt>;
export declare const arkTs: Module<arkTs>;
export type arkTs = Submodule<{
bigint: bigint;
boolean: boolean;
false: false;
never: never;
null: null;
number: number;
object: object;
string: string;
symbol: symbol;
true: true;
unknown: unknown;
undefined: undefined;
Record: typeof Record.t;
Pick: typeof Pick.t;
Omit: typeof Omit.t;
Exclude: typeof Exclude.t;
Extract: typeof Extract.t;
Partial: typeof Partial.t;
Required: typeof Required.t;
}>;
export declare const arkTsGenerics: arkTsGenerics.module;
export declare namespace arkTsGenerics {
type module = Module<arkTsGenerics.$>;
type submodule = Submodule<$>;
type $ = {
Record: typeof Record.t;
Pick: typeof Pick.t;
Omit: typeof Omit.t;
Exclude: typeof Exclude.t;
Extract: typeof Extract.t;
Partial: typeof Partial.t;
Required: typeof Required.t;
};
}
export {};
import { genericNode, intrinsic } from "@ark/schema";
import { Hkt } from "@ark/util";
import { submodule } from "./utils.js";
export const arkTsKeywords = submodule({
bigint: intrinsic.bigint,
boolean: intrinsic.boolean,
false: intrinsic.false,
never: intrinsic.never,
null: intrinsic.null,
number: intrinsic.number,
object: intrinsic.object,
string: intrinsic.string,
symbol: intrinsic.symbol,
true: intrinsic.true,
unknown: intrinsic.unknown,
undefined: intrinsic.undefined
});
class RecordHkt extends Hkt {

@@ -31,15 +45,3 @@ }

const Extract = genericNode("T", "U")(args => args.T.extract(args.U), ExtractHkt);
export const arkTs = submodule({
bigint: intrinsic.bigint,
boolean: intrinsic.boolean,
false: intrinsic.false,
never: intrinsic.never,
null: intrinsic.null,
number: intrinsic.number,
object: intrinsic.object,
string: intrinsic.string,
symbol: intrinsic.symbol,
true: intrinsic.true,
unknown: intrinsic.unknown,
undefined: intrinsic.undefined,
export const arkTsGenerics = submodule({
Record,

@@ -46,0 +48,0 @@ Pick,

import { type BaseRoot } from "@ark/schema";
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 ErrorMessage, type Fn, type Primitive, type anyOrNever, type array, type defined, type equals, type ifEmptyObjectLiteral, type objectKindOrDomainOf, type optionalKeyOf, type requiredKeyOf, type show } from "@ark/util";
import type { type } from "../keywords/ark.ts";

@@ -13,5 +13,3 @@ import type { string } from "../keywords/string/string.ts";

def
] extends [anyOrNever] ? def : def extends type.cast<infer t> ? {} extends t ? [
t
] extends [anyOrNever] ? t : object : t : def extends 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;
] extends [anyOrNever] ? def : def extends type.cast<infer t> ? ifEmptyObjectLiteral<t, object, t> : def extends 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 ? ErrorMessage<writeBadDefinitionTypeMessage<objectKindOrDomainOf<def>>> : unknown extends def ? BaseCompletions<$, args> | {} : validateObjectLiteral<def, $, args>;

@@ -18,0 +16,0 @@ export type validateDeclared<declared, def, $, args> = def extends validateDefinition<def, $, args> ? validateInference<def, declared, $, args> : validateDefinition<def, $, args>;

@@ -25,3 +25,15 @@ import { type BaseRoot, type Index, type Optional, type Required, type UndeclaredKeyBehavior, type writeInvalidPropertyKeyMessage } from "@ark/schema";

};
type validateDefaultableValue<def, k extends keyof def, $, args> = def[k] extends DefaultValueTuple ? validateDefaultValueTuple<def[k], k, $, args> : validateDefinition<def[k], $, args>;
type validateDefaultableValue<def, k extends keyof def, $, args> = def[k] extends DefaultValueTuple ? [
def[k]
] extends [anyOrNever] ?
/** this extra [anyOrNever] check is required to ensure that nested `type` invocations
* like the following are not prematurely validated by the outer call:
*
* ```ts
* type({
* "test?": type("string").pipe(x => x === "true")
* })
* ```
*/
def[k] : validateDefaultValueTuple<def[k], k, $, args> : validateDefinition<def[k], $, args>;
type DefaultValueTuple<baseDef = unknown, defaultValue = unknown> = readonly [

@@ -28,0 +40,0 @@ baseDef,

@@ -9,3 +9,5 @@ import type { writeUnboundableMessage } from "@ark/schema";

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>;
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<typeToString<bounded>>> : never;

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

import type { ErrorMessage } from "@ark/util";
import type { inferAmbient } from "../../type.ts";
import type { UnitLiteral } from "../string/shift/operator/default.ts";
import type { inferAstOut, inferTerminal } from "./infer.ts";
import type { inferAstOut } 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 type validateDefault<baseAst, unitLiteral extends UnitLiteral, $, args> = validateAst<baseAst, $, args> extends infer e extends ErrorMessage ? e : inferAmbient<unitLiteral> extends inferAstOut<baseAst, $, args> ? undefined : ErrorMessage<writeUnassignableDefaultValueMessage<astToString<baseAst>, unitLiteral>>;
export declare const writeUnassignableDefaultValueMessage: <key extends string, message extends string>(key: key, message: message) => string;
export type writeUnassignableDefaultValueMessage<baseDef extends string, defaultValue extends string> = `Default value ${defaultValue} is not assignable to ${baseDef}`;
import type { GenericAst } from "@ark/schema";
import type { BigintLiteral, Hkt, array } from "@ark/util";
import type { ArkAmbient } from "../../config.ts";
import type { Hkt, array } from "@ark/util";
import type { inferIntersection } from "../../intersect.ts";
import type { Date, DateLiteral, Default, LimitLiteral, RegexLiteral, applyConstraint, distillIn, distillOut, normalizeLimit } from "../../keywords/ast.ts";
import type { string } from "../../keywords/string/string.ts";
import type { UnparsedScope, resolve, tryInferSubmoduleReference } from "../../scope.ts";
import type { Date, Default, LimitLiteral, applyConstraint, distillIn, distillOut, normalizeLimit } from "../../keywords/ast.ts";
import type { UnparsedScope } from "../../scope.ts";
import type { inferAmbient } from "../../type.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>;
export type inferAstRoot<ast, $, args> = ast extends array ? inferExpression<ast, $, args> : never;
export type inferAstIn<ast, $, args> = distillIn<inferAstRoot<ast, $, args>>;
export type inferAstOut<ast, $, args> = distillOut<inferAstRoot<ast, $, args>>;
export type inferConstrainableAst<ast, $, args> = ast extends array ? inferExpression<ast, $, args> : ast extends string ? inferTerminal<ast, $, args> : never;
export type DefAst<def = unknown, alias extends string = string> = [
def,
"def",
alias
];
export type InferredAst<t = unknown, def extends string = string> = [
t,
"inferred",
def
];
export type GenericInstantiationAst<generic extends GenericAst = GenericAst, argAsts extends unknown[] = unknown[]> = [generic, "<>", argAsts];
type resolveScope<g$, $> = g$ extends UnparsedScope ? $ : g$;
export type inferExpression<ast extends array, $, args> = ast extends GenericInstantiationAst<infer g, infer argAsts> ? g["bodyDef"] extends Hkt ? Hkt.apply<g["bodyDef"], {
[i in keyof argAsts]: inferConstrainableAst<argAsts[i], $, args>;
export type inferExpression<ast, $, args> = ast extends array ? ast extends InferredAst<infer resolution> ? resolution : ast extends DefAst<infer def> ? inferDefinition<def, $, args> : ast extends GenericInstantiationAst<infer g, infer argAsts> ? g["bodyDef"] extends Hkt ? Hkt.apply<g["bodyDef"], {
[i in keyof argAsts]: inferExpression<argAsts[i], $, args>;
}> : inferDefinition<g["bodyDef"], resolveScope<g["$"], $>, {
[i in keyof g["names"] & `${number}` as g["names"][i]]: inferConstrainableAst<argAsts[i & keyof argAsts], resolveScope<g["arg$"], $>, args>;
}> : 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 "=" ? inferTerminal<ast[2] & string, $, args> extends infer defaultValue ? (In?: inferConstrainableAst<ast[0], $, args>) => Default<defaultValue> : never : 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 "%" ? applyConstraint<inferConstrainableAst<ast[0], $, args>, "divisor", ast[2] & number> : ast[0] extends "keyof" ? keyof inferConstrainableAst<ast[1], $, args> : never;
export type constrainBound<constrainableIn, comparator extends Comparator, limit> = distillIn<constrainableIn> extends infer In ? comparator extends "==" ? In extends number ? limit : In extends Date ? Date.literal<normalizeLimit<limit>> : applyConstraint<constrainableIn, "exactLength", limit & number> : applyConstraint<constrainableIn, In extends number ? comparator extends MinComparator ? "min" : "max" : In extends string | array ? comparator extends MinComparator ? "minLength" : "maxLength" : comparator extends MinComparator ? "after" : "before", {
[i in keyof g["names"] & `${number}` as g["names"][i]]: inferExpression<argAsts[i & keyof argAsts], resolveScope<g["arg$"], $>, args>;
}> : ast[1] extends "[]" ? inferExpression<ast[0], $, args>[] : ast[1] extends "|" ? inferExpression<ast[0], $, args> | inferExpression<ast[2], $, args> : ast[1] extends "&" ? inferIntersection<inferExpression<ast[0], $, args>, inferExpression<ast[2], $, args>> : ast[1] extends "=" ? inferAmbient<ast[2]> extends infer defaultValue ? (In?: inferExpression<ast[0], $, args>) => Default<defaultValue> : never : ast[1] extends Comparator ? ast[0] extends LimitLiteral ? constrainBound<inferExpression<ast[2], $, args>, ast[1], ast[0]> : constrainBound<inferExpression<ast[0], $, args>, ast[1], ast[2] & LimitLiteral> : ast[1] extends "%" ? applyConstraint<inferExpression<ast[0], $, args>, "divisor", ast[2] & number> : ast[0] extends "keyof" ? keyof inferExpression<ast[1], $, args> : never : never;
export type constrainBound<constrainableIn, comparator extends Comparator, limit extends LimitLiteral> = distillIn<constrainableIn> extends infer In ? comparator extends "==" ? In extends number ? limit : In extends Date ? Date.literal<normalizeLimit<limit>> : applyConstraint<constrainableIn, "exactLength", limit & number> : applyConstraint<constrainableIn, In extends number ? comparator extends MinComparator ? "min" : "max" : In extends string | array ? comparator extends MinComparator ? "minLength" : "maxLength" : comparator extends MinComparator ? "after" : "before", {
rule: normalizeLimit<limit>;

@@ -32,3 +39,2 @@ exclusive: comparator extends ">" | "<" ? true : false;

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 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 { Stringifiable } from "@ark/util";
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 { DefAst, InferredAst, InfixExpression, PostfixExpression } from "./infer.ts";
export type astToString<ast> = ast extends InferredAst | DefAst ? ast[2] : 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 { anyOrNever, array, BigintLiteral, charsAfterFirst, Completion, ErrorMessage, NumberLiteral, typeToString, writeMalformedNumericLiteralMessage } from "@ark/util";
import type { Generic } from "../../generic.ts";

@@ -11,6 +11,6 @@ import type { Comparator } from "../string/reduce/shared.ts";

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

@@ -22,10 +22,7 @@ };

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 $ ? [
$[alias]
] extends [anyOrNever] ? def : def extends PrivateDeclaration ? ErrorMessage<writePrefixedPrivateReferenceMessage<def>> : $[alias] extends Generic ? ErrorMessage<writeInvalidGenericArgCountMessage<def, $[alias]["names"], []>> : $[alias] extends {
type validateInferredAst<inferred, def extends string> = def extends NumberLiteral ? number extends inferred ? ErrorMessage<writeMalformedNumericLiteralMessage<def, "number">> : undefined : def extends BigintLiteral ? bigint extends inferred ? ErrorMessage<writeMalformedNumericLiteralMessage<def, "bigint">> : undefined : [inferred] extends [anyOrNever] ? undefined : def extends PrivateDeclaration ? ErrorMessage<writePrefixedPrivateReferenceMessage<def>> : inferred extends Generic ? ErrorMessage<writeInvalidGenericArgCountMessage<def, inferred["names"], []>> : inferred extends {
[arkKind]: "module";
} ? "$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;
} ? "$root" extends keyof inferred ? undefined : ErrorMessage<writeMissingSubmoduleAccessMessage<def>> : def extends ErrorMessage ? def : undefined;
export type validateString<def extends string, $, args> = validateAst<parseString<def, $, args>, $, args> extends (infer result extends ErrorMessage) ? result extends Completion<infer text> ? text : result : def;
type validateInfix<ast extends InfixExpression, $, args> = validateAst<ast[0], $, args> extends infer e extends ErrorMessage ? e : validateAst<ast[2], $, args> extends infer e extends ErrorMessage ? e : undefined;
export {};

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

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

@@ -8,3 +10,3 @@ import type { StaticState, state } from "../../reduce/static.ts";

export declare const parseEnclosed: (s: DynamicState, enclosing: EnclosingStartToken) => void;
export type parseEnclosed<s extends StaticState, enclosingStart extends EnclosingStartToken, unscanned extends string> = Scanner.shiftUntil<unscanned, EnclosingTokens[enclosingStart]> extends (Scanner.shiftResult<infer scanned, infer nextUnscanned>) ? nextUnscanned extends "" ? state.error<writeUnterminatedEnclosedMessage<scanned, enclosingStart>> : state.setRoot<s, `${enclosingStart}${scanned}${EnclosingTokens[enclosingStart]}`, nextUnscanned extends Scanner.shift<string, infer unscanned> ? unscanned : ""> : never;
export type parseEnclosed<s extends StaticState, enclosingStart extends EnclosingStartToken, unscanned extends string> = Scanner.shiftUntil<unscanned, EnclosingTokens[enclosingStart]> extends (Scanner.shiftResult<infer scanned, infer nextUnscanned>) ? nextUnscanned extends "" ? state.error<writeUnterminatedEnclosedMessage<scanned, enclosingStart>> : state.setRoot<s, InferredAst<enclosingStart extends EnclosingQuote ? scanned : enclosingStart extends "/" ? string.matching<scanned> : Date.literal<scanned>, `${enclosingStart}${scanned}${EnclosingTokens[enclosingStart]}`>, nextUnscanned extends Scanner.shift<string, infer unscanned> ? unscanned : ""> : never;
export declare const enclosingQuote: {

@@ -11,0 +13,0 @@ readonly "'": 1;

import { writeUnresolvableMessage, type BaseRoot, type GenericAst, type GenericRoot, type arkKind, type genericParamNames, type resolvableReferenceIn, type writeNonSubmoduleDotMessage } from "@ark/schema";
import { type BigintLiteral, type anyOrNever, type join, type lastOf } from "@ark/util";
import { type BigintLiteral, type NumberLiteral, type join, type lastOf } from "@ark/util";
import type { ArkAmbient } from "../../../../config.ts";
import type { GenericInstantiationAst } from "../../../semantic/infer.ts";
import type { resolutionToAst } from "../../../../scope.ts";
import type { GenericInstantiationAst, InferredAst } from "../../../semantic/infer.ts";
import type { DynamicState } from "../../reduce/dynamic.ts";

@@ -12,13 +13,11 @@ import type { StaticState, state } from "../../reduce/static.ts";

export type parseUnenclosed<s extends StaticState, $, args> = Scanner.shiftUntilNextTerminator<s["unscanned"]> extends (Scanner.shiftResult<infer token, infer unscanned>) ? tryResolve<s, unscanned, token, $, args> extends state.from<infer s> ? s : never : never;
type parseResolution<s extends StaticState, unscanned extends string, alias extends string, resolution, $, args> = [
resolution
] extends [anyOrNever] ? state.setRoot<s, alias, unscanned> : resolution extends GenericAst ? parseGenericInstantiation<alias, resolution, state.scanTo<s, unscanned>, $, args> : state.setRoot<s, alias, unscanned>;
type parseResolution<s extends StaticState, unscanned extends string, alias extends string, resolution, $, args> = resolutionToAst<alias, resolution> extends infer ast ? ast extends GenericAst ? parseGenericInstantiation<alias, ast, state.scanTo<s, unscanned>, $, args> : state.setRoot<s, ast, unscanned> : never;
export declare const parseGenericInstantiation: (name: string, g: GenericRoot, s: DynamicState) => BaseRoot;
export type parseGenericInstantiation<name extends string, g extends GenericAst, s extends StaticState, $, args> = Scanner.skipWhitespace<s["unscanned"]> extends `<${infer unscanned}` ? parseGenericArgs<name, g, unscanned, $, args> extends infer result ? result extends ParsedArgs<infer argAsts, infer nextUnscanned> ? state.setRoot<s, GenericInstantiationAst<g, argAsts>, nextUnscanned> : result : never : state.error<writeInvalidGenericArgCountMessage<name, genericParamNames<g["paramsAst"]>, [
]>>;
type tryResolve<s extends StaticState, unscanned extends string, token extends string, $, args> = token extends keyof args ? parseResolution<s, unscanned, token, args[token], $, args> : token extends keyof $ ? parseResolution<s, unscanned, token, $[token], $, args> : `#${token}` extends keyof $ ? parseResolution<s, unscanned, token, $[`#${token}`], $, args> : token extends keyof ArkAmbient.$ ? parseResolution<s, unscanned, token, ArkAmbient.$[token], $, args> : token extends `${number}` ? state.setRoot<s, token, unscanned> : token extends (`${infer submodule extends keyof $ & string}.${infer reference}`) ? tryResolveSubmodule<token, $[submodule], reference, s, unscanned, $, args, [
type tryResolve<s extends StaticState, unscanned extends string, token extends string, $, args> = token extends keyof args ? parseResolution<s, unscanned, token, args[token], $, args> : token extends keyof $ ? parseResolution<s, unscanned, token, $[token], $, args> : `#${token}` extends keyof $ ? parseResolution<s, unscanned, token, $[`#${token}`], $, args> : token extends keyof ArkAmbient.$ ? parseResolution<s, unscanned, token, ArkAmbient.$[token], $, args> : token extends NumberLiteral<infer n> ? state.setRoot<s, InferredAst<n, token>, unscanned> : token extends (`${infer submodule extends keyof $ & string}.${infer reference}`) ? tryResolveSubmodule<token, $[submodule], reference, s, unscanned, $, args, [
submodule
]> : token extends (`${infer submodule extends keyof ArkAmbient.$ & string}.${infer reference}`) ? tryResolveSubmodule<token, ArkAmbient.$[submodule], reference, s, unscanned, $, args, [
submodule
]> : token extends BigintLiteral ? state.setRoot<s, token, unscanned> : token extends "keyof" ? state.addPrefix<s, "keyof", unscanned> : unresolvableState<s, token, $, args, []>;
]> : token extends BigintLiteral<infer b> ? state.setRoot<s, InferredAst<b, token>, unscanned> : token extends "keyof" ? state.addPrefix<s, "keyof", unscanned> : unresolvableState<s, token, $, args, []>;
type tryResolveSubmodule<token extends string, resolution, reference extends string, s extends StaticState, unscanned extends string, $, args, submodulePath extends string[]> = resolution extends {

@@ -25,0 +24,0 @@ [arkKind]: "module";

import { type BaseRoot, type BoundKind } from "@ark/schema";
import { type keySet } from "@ark/util";
import type { LimitLiteral } from "../../../../keywords/ast.ts";
import type { DateLiteral } from "../../../../keywords/ast.ts";
import type { InferredAst } from "../../../semantic/infer.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 { state, StaticState } 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;
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 (InferredAst<Date | number, `${infer limit extends number | DateLiteral}`>) ? state.reduceLeftBound<s, limit, comparator, nextUnscanned> : parseRightBound<state.scanTo<s, nextUnscanned>, comparator, $, args> : shiftResultOrError : never;
type OneCharComparator = ">" | "<";

@@ -18,5 +19,5 @@ export type ComparatorStartChar = Comparator extends `${infer char}${string}` ? char : never;

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 getBoundKinds: (comparator: Comparator, limit: number | DateLiteral, root: BaseRoot, boundKind: BoundExpressionKind) => BoundKind[];
export declare const parseRightBound: (s: DynamicStateWithRoot, comparator: Comparator) => void;
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 type parseRightBound<s extends StaticState, comparator extends Comparator, $, args> = parseOperand<s, $, args> extends infer nextState extends StaticState ? nextState["root"] extends (InferredAst<unknown, `${infer limit extends number | DateLiteral}`>) ? 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 Comparator, limit extends string | number, boundKind extends BoundExpressionKind>(comparator: comparator, limit: limit, boundKind: boundKind) => writeInvalidLimitMessage<comparator, limit, boundKind>;

@@ -23,0 +24,0 @@ 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})`;

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

import { isKeyOf } from "@ark/util";
import { isKeyOf, whiteSpaceTokens } from "@ark/util";
import { Scanner } from "../scanner.js";

@@ -18,3 +18,3 @@ import { comparatorStartChars, parseBound } from "./bounds.js";

: lookahead === "%" ? parseDivisor(s)
: lookahead === " " ? parseOperator(s)
: lookahead in whiteSpaceTokens ? parseOperator(s)
: s.error(writeUnexpectedCharacterMessage(lookahead)));

@@ -21,0 +21,0 @@ };

@@ -24,2 +24,5 @@ import { type Dict, type EscapeToken, type WhiteSpaceToken } from "@ark/util";

static terminatingChars: {
readonly " ": true;
readonly "\n": true;
readonly "\t": true;
readonly "<": true;

@@ -33,3 +36,2 @@ readonly ">": true;

readonly "%": true;
readonly " ": true;
readonly ",": true;

@@ -36,0 +38,0 @@ readonly ":": true;

@@ -75,5 +75,5 @@ import { escapeToken, isKeyOf, whiteSpaceTokens } from "@ark/util";

"%": true,
" ": true,
",": true,
":": true
":": true,
...whiteSpaceTokens
};

@@ -80,0 +80,0 @@ static finalizingLookaheads = {

import type { BaseRoot, resolvableReferenceIn } from "@ark/schema";
import { type ErrorMessage } from "@ark/util";
import type { ArkAmbient } from "../../config.ts";
import type { resolutionToAst } from "../../scope.ts";
import type { inferAstRoot } from "../semantic/infer.ts";

@@ -15,4 +16,4 @@ import type { DynamicState, DynamicStateWithRoot } from "./reduce/dynamic.ts";

*/
export type parseString<def extends string, $, args> = def extends keyof $ ? def : def extends `${infer child}[]` ? child extends keyof $ ? [
child,
export type parseString<def extends string, $, args> = def extends keyof $ ? resolutionToAst<def, $[def]> : def extends `${infer child}[]` ? child extends keyof $ ? [
resolutionToAst<child, $[child]>,
"[]"

@@ -19,0 +20,0 @@ ] : fullStringParse<state.initialize<def>, $, args> : fullStringParse<state.initialize<def>, $, args>;

import { BaseScope, type AliasDefEntry, type ArkScopeConfig, type BaseNode, type BaseRoot, type GenericArgResolutions, type GenericAst, type GenericParamAst, type NodeKind, type NodeParseOptions, type NodeSchema, type PreparsedNodeResolution, type PrivateDeclaration, type RootKind, type RootSchema, type arkKind, type exportedNameOf, type nodeOfKind, type reducibleKindOf, type toInternalScope, type writeDuplicateAliasError } from "@ark/schema";
import { type ErrorType, type Json, type anyOrNever, type array, type flattenListable, type inferred, type noSuggest, type nominal } from "@ark/util";
import type { ArkAmbient } from "./config.ts";
import type { ArkAmbient, ArkSchemaRegistry } from "./config.ts";
import { parseGenericParams, type GenericDeclaration, type GenericParser, type ParameterString, type baseGenericConstraints, type parseValidGenericParams } from "./generic.ts";
import type { type } from "./keywords/ark.ts";
import type { Ark, 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 { DefAst, InferredAst } from "./parser/semantic/infer.ts";
import type { ParsedDefault } from "./parser/string/shift/operator/default.ts";

@@ -42,7 +43,14 @@ import { InternalTypeParser, type DeclarationParser, type DefinitionParser, type Type, type TypeParser } from "./type.ts";

type extractGenericParameters<k> = k extends `${string}<${infer params}>` ? ParameterString<params> : never;
export type resolve<reference extends keyof $ | keyof args, $, args> = (reference extends keyof args ? args[reference] : $[reference & keyof $]) extends infer resolution ? [
export type resolve<reference extends keyof $ | keyof args, $, args> = inferResolution<reference extends keyof args ? args[reference] : $[reference & keyof $], $, args>;
export type resolutionToAst<alias extends string, resolution> = [
resolution
] extends [anyOrNever] ? InferredAst<resolution, alias> : resolution extends Def<infer def> ? DefAst<def, alias> : resolution extends {
[arkKind]: "module";
$root: infer root;
} ? InferredAst<root, alias> : resolution extends GenericAst ? resolution : InferredAst<resolution, alias>;
export type inferResolution<resolution, $, args> = [
resolution
] extends [anyOrNever] ? resolution : resolution extends {
[inferred]: infer t;
} ? t : resolution extends Def<infer def> ? inferDefinition<def, $, args> : resolution : never;
} ? t : resolution extends Def<infer def> ? inferDefinition<def, $, args> : resolution;
export type moduleKeyOf<$> = {

@@ -57,2 +65,6 @@ [k in keyof $]: $[k] extends {

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 ArkTypeRegistry extends ArkSchemaRegistry {
typeAttachments?: Ark.boundTypeAttachments<any>;
}
export declare const $arkTypeRegistry: ArkTypeRegistry;
export interface ParseContext extends TypeParseOptions {

@@ -70,3 +82,5 @@ $: InternalScope;

preparseAlias(k: string, v: unknown): AliasDefEntry;
protected cacheGetter<name extends keyof this>(name: name, value: this[name]): this[name];
preparseRoot(def: unknown): unknown;
get ambientAttachments(): Ark.boundTypeAttachments<$> | undefined;
parse<defaultable extends boolean = false>(def: unknown, ctx: ParseContext, defaultable?: defaultable): BaseRoot | (defaultable extends false ? never : ParsedDefault);

@@ -73,0 +87,0 @@ parseString<defaultable extends boolean>(def: string, ctx: ParseContext, defaultable: defaultable): BaseRoot | (defaultable extends false ? never : ParsedDefault);

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

import { BaseScope, hasArkKind, parseGeneric } from "@ark/schema";
import { domainOf, hasDomain, isThunk, throwParseError } from "@ark/util";
import { $ark, BaseScope, hasArkKind, parseGeneric } from "@ark/schema";
import { domainOf, flatMorph, hasDomain, isThunk, throwParseError } from "@ark/util";
import { parseGenericParams } from "./generic.js";

@@ -10,2 +10,3 @@ import { parseObject, writeBadDefinitionTypeMessage } from "./parser/definition.js";

import { InternalTypeParser } from "./type.js";
export const $arkTypeRegistry = $ark;
export class InternalScope extends BaseScope {

@@ -36,2 +37,6 @@ parseCache = {};

}
cacheGetter(name, value) {
Object.defineProperty(this, name, { value });
return value;
}
preparseRoot(def) {

@@ -42,2 +47,10 @@ if (isThunk(def) && !hasArkKind(def, "generic"))

}
get ambientAttachments() {
if (!$arkTypeRegistry.typeAttachments)
return;
return this.cacheGetter("ambientAttachments", flatMorph($arkTypeRegistry.typeAttachments, (k, v) => [
k,
v.bindScope(this)
]));
}
parse(def, ctx, defaultable = false) {

@@ -44,0 +57,0 @@ if (typeof def === "string") {

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 { anyOrNever, array, Callable, ErrorMessage, inferred, Json, unset } from "@ark/util";
import type { inferIntersection } from "../intersect.ts";

@@ -45,2 +45,3 @@ import type { distillConstrainableIn, distillConstrainableOut, distillIn, distillOut, distillValidatedOut, inferMorphOut, inferPipes } from "../keywords/ast.ts";

overlaps<def>(r: validateTypeRoot<def, $>): boolean;
distribute<mapOut, reduceOut = mapOut[]>(mapBranch: (branch: Type, i: number, branches: array<Type>) => mapOut, reduceMapped?: (mappedBranches: mapOut[]) => reduceOut): reduceOut;
/** @deprecated */

@@ -47,0 +48,0 @@ apply: Function["apply"];

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 Generic, type ParameterString, type baseGenericConstraints, type parseValidGenericParams, type validateParameterString } from "./generic.ts";
import type { Ark, ark } from "./keywords/ark.ts";
import type { distillIn, distillOut } from "./keywords/ast.ts";

@@ -12,3 +13,3 @@ import type { inferDefinition, validateDeclared, validateDefinition } from "./parser/definition.ts";

export type TypeParserAttachments = Omit<TypeParser, never>;
export interface TypeParser<$ = {}> {
export interface TypeParser<$ = {}> extends Ark.boundTypeAttachments<$> {
<const def, r = Type<inferTypeRoot<def, $>, $>>(def: validateTypeRoot<def, $>): r;

@@ -21,2 +22,3 @@ <params extends ParameterString, const def>(params: validateParameterString<params, $>, def: validateDefinition<def, $, baseGenericConstraints<parseValidGenericParams<params, $>>>): Generic<parseValidGenericParams<params, $>, def, $>;

scope: ScopeParser;
ark: typeof ark;
}

@@ -23,0 +25,0 @@ export declare class InternalTypeParser extends Callable<(...args: unknown[]) => BaseRoot | Generic, TypeParserAttachments> {

@@ -6,2 +6,12 @@ import { ArkErrors, BaseRoot, GenericRoot } from "@ark/schema";

constructor($) {
const attach = Object.assign({
errors: ArkErrors,
raw: $.parseRoot,
module: $.constructor.module,
scope: $.constructor.scope,
// this won't be defined during bootstrapping, but externally always will be
ark: $.ambient
},
// also won't be defined during bootstrapping
$.ambientAttachments);
super((...args) => {

@@ -30,8 +40,3 @@ if (args.length === 1) {

bind: $,
attach: {
errors: ArkErrors,
raw: $.parseRoot,
module: $.constructor.module,
scope: $.constructor.scope
}
attach
});

@@ -38,0 +43,0 @@ }

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

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

"dependencies": {
"@ark/util": "0.3.0",
"@ark/schema": "0.4.0"
"@ark/util": "0.5.0",
"@ark/schema": "0.5.0"
},

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc