arktype 2.0.0-rc.1 → 2.0.0-rc.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/config.d.ts +1 -1
- package/out/generic.d.ts +47 -48
- package/out/generic.js +6 -8
- package/out/index.d.ts +4 -4
- package/out/index.js +2 -2
- package/out/keywords/builtins.js +2 -2
- package/out/keywords/constructors/Array.d.ts +2 -2
- package/out/keywords/constructors/Array.js +7 -7
- package/out/keywords/constructors/Date.d.ts +32 -0
- package/out/keywords/constructors/FormData.d.ts +2 -2
- package/out/keywords/constructors/FormData.js +8 -8
- package/out/keywords/constructors/TypedArray.js +2 -2
- package/out/keywords/constructors/constructors.d.ts +0 -1
- package/out/keywords/constructors/constructors.js +2 -2
- package/out/keywords/inference.d.ts +228 -0
- package/out/keywords/keywords.d.ts +62 -0
- package/out/keywords/{ark.js → keywords.js} +11 -8
- package/out/keywords/number/epoch.d.ts +1 -2
- package/out/keywords/number/epoch.js +2 -2
- package/out/keywords/number/integer.js +2 -2
- package/out/keywords/number/number.d.ts +32 -6
- package/out/keywords/number/number.js +17 -5
- package/out/keywords/string/alpha.d.ts +1 -1
- package/out/keywords/string/alphanumeric.d.ts +1 -1
- package/out/keywords/string/capitalize.d.ts +2 -2
- package/out/keywords/string/capitalize.js +4 -4
- package/out/keywords/string/creditCard.d.ts +1 -1
- package/out/keywords/string/creditCard.js +2 -2
- package/out/keywords/string/date.d.ts +4 -8
- package/out/keywords/string/date.js +16 -16
- package/out/keywords/string/digits.d.ts +1 -1
- package/out/keywords/string/email.d.ts +1 -1
- package/out/keywords/string/integer.d.ts +2 -2
- package/out/keywords/string/integer.js +7 -7
- package/out/keywords/string/ip.d.ts +2 -2
- package/out/keywords/string/ip.js +5 -5
- package/out/keywords/string/json.d.ts +3 -2
- package/out/keywords/string/json.js +24 -16
- package/out/keywords/string/lower.d.ts +2 -2
- package/out/keywords/string/lower.js +4 -4
- package/out/keywords/string/normalize.d.ts +23 -27
- package/out/keywords/string/normalize.js +14 -14
- package/out/keywords/string/numeric.d.ts +2 -2
- package/out/keywords/string/numeric.js +7 -7
- package/out/keywords/string/semver.d.ts +1 -1
- package/out/keywords/string/string.d.ts +39 -42
- package/out/keywords/string/string.js +3 -3
- package/out/keywords/string/trim.d.ts +2 -2
- package/out/keywords/string/trim.js +4 -4
- package/out/keywords/string/upper.d.ts +2 -2
- package/out/keywords/string/upper.js +4 -4
- package/out/keywords/string/url.d.ts +2 -2
- package/out/keywords/string/url.js +8 -8
- package/out/keywords/string/uuid.d.ts +11 -11
- package/out/keywords/string/uuid.js +3 -3
- package/out/keywords/ts.d.ts +38 -1
- package/out/keywords/ts.js +20 -4
- package/out/keywords/utils.d.ts +1 -1
- package/out/keywords/utils.js +1 -1
- package/out/{subtypes → methods}/array.d.ts +6 -6
- package/out/methods/base.d.ts +96 -0
- package/out/{subtypes → methods}/date.d.ts +5 -5
- package/out/{subtypes → methods}/instantiate.d.ts +5 -4
- package/out/methods/morph.d.ts +12 -0
- package/out/{subtypes → methods}/number.d.ts +6 -6
- package/out/methods/object.d.ts +81 -0
- package/out/{subtypes → methods}/string.d.ts +7 -7
- package/out/{subtypes → methods}/validator.d.ts +2 -2
- package/out/module.d.ts +2 -2
- package/out/parser/{semantic → ast}/bounds.d.ts +3 -3
- package/out/parser/ast/default.d.ts +8 -0
- package/out/parser/{semantic → ast}/infer.d.ts +11 -11
- package/out/parser/{semantic → ast}/utils.d.ts +1 -1
- package/out/parser/{semantic → ast}/validate.d.ts +6 -6
- package/out/parser/definition.d.ts +8 -9
- package/out/parser/objectLiteral.d.ts +11 -37
- package/out/parser/objectLiteral.js +6 -24
- package/out/parser/{string/reduce → reduce}/dynamic.d.ts +5 -7
- package/out/parser/{string/reduce → reduce}/dynamic.js +5 -6
- package/out/parser/{string/reduce → reduce}/shared.d.ts +1 -1
- package/out/parser/{string/reduce → reduce}/static.d.ts +1 -1
- package/out/parser/{string/shift → shift}/operand/date.d.ts +3 -1
- package/out/parser/{string/shift → shift}/operand/enclosed.d.ts +3 -2
- package/out/parser/{string/shift → shift}/operand/enclosed.js +7 -3
- package/out/parser/{string/shift → shift}/operand/unenclosed.d.ts +3 -3
- package/out/parser/{string/shift → shift}/operand/unenclosed.js +7 -3
- package/out/parser/{string/shift → shift}/operator/bounds.d.ts +3 -3
- package/out/parser/{string/shift → shift}/operator/default.d.ts +3 -6
- package/out/parser/{string/shift → shift}/operator/default.js +1 -6
- package/out/parser/{string/shift → shift}/scanner.d.ts +3 -1
- package/out/parser/{string/shift → shift}/scanner.js +5 -3
- package/out/parser/{string/string.d.ts → string.d.ts} +6 -7
- package/out/parser/{string/string.js → string.js} +2 -0
- package/out/parser/tuple.d.ts +54 -43
- package/out/parser/tuple.js +36 -30
- package/out/scope.d.ts +32 -39
- package/out/scope.js +43 -35
- package/out/type.d.ts +24 -21
- package/out/type.js +14 -10
- package/package.json +3 -3
- package/out/intersect.d.ts +0 -28
- package/out/keys.d.ts +0 -16
- package/out/keywords/ark.d.ts +0 -39
- package/out/keywords/ast.d.ts +0 -193
- package/out/parser/semantic/default.d.ts +0 -9
- package/out/parser/semantic/default.js +0 -1
- package/out/subtypes/base.d.ts +0 -85
- package/out/subtypes/morph.d.ts +0 -13
- package/out/subtypes/object.d.ts +0 -33
- /package/out/{intersect.js → keywords/constructors/Date.js} +0 -0
- /package/out/keywords/{ast.js → inference.js} +0 -0
- /package/out/{subtypes → methods}/array.js +0 -0
- /package/out/{subtypes → methods}/base.js +0 -0
- /package/out/{subtypes → methods}/date.js +0 -0
- /package/out/{subtypes → methods}/instantiate.js +0 -0
- /package/out/{subtypes → methods}/morph.js +0 -0
- /package/out/{subtypes → methods}/number.js +0 -0
- /package/out/{subtypes → methods}/object.js +0 -0
- /package/out/{subtypes → methods}/string.js +0 -0
- /package/out/{subtypes → methods}/validator.js +0 -0
- /package/out/parser/{semantic → ast}/bounds.js +0 -0
- /package/out/{keys.js → parser/ast/default.js} +0 -0
- /package/out/parser/{semantic → ast}/divisor.d.ts +0 -0
- /package/out/parser/{semantic → ast}/divisor.js +0 -0
- /package/out/parser/{semantic → ast}/infer.js +0 -0
- /package/out/parser/{semantic → ast}/keyof.d.ts +0 -0
- /package/out/parser/{semantic → ast}/keyof.js +0 -0
- /package/out/parser/{semantic → ast}/utils.js +0 -0
- /package/out/parser/{semantic → ast}/validate.js +0 -0
- /package/out/parser/{string/reduce → reduce}/shared.js +0 -0
- /package/out/parser/{string/reduce → reduce}/static.js +0 -0
- /package/out/parser/{string/shift → shift}/operand/date.js +0 -0
- /package/out/parser/{string/shift → shift}/operand/genericArgs.d.ts +0 -0
- /package/out/parser/{string/shift → shift}/operand/genericArgs.js +0 -0
- /package/out/parser/{string/shift → shift}/operand/operand.d.ts +0 -0
- /package/out/parser/{string/shift → shift}/operand/operand.js +0 -0
- /package/out/parser/{string/shift → shift}/operator/bounds.js +0 -0
- /package/out/parser/{string/shift → shift}/operator/divisor.d.ts +0 -0
- /package/out/parser/{string/shift → shift}/operator/divisor.js +0 -0
- /package/out/parser/{string/shift → shift}/operator/operator.d.ts +0 -0
- /package/out/parser/{string/shift → shift}/operator/operator.js +0 -0
package/out/type.d.ts
CHANGED
|
@@ -1,24 +1,31 @@
|
|
|
1
|
-
import { ArkErrors, BaseRoot, type MetaSchema, type Morph, type Predicate } from "@ark/schema";
|
|
2
|
-
import { Callable, type Constructor, type array, type conform } from "@ark/util";
|
|
3
|
-
import {
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
1
|
+
import { ArkErrors, BaseRoot, type BaseParseOptions, type MetaSchema, type Morph, type Predicate, type RootSchema } from "@ark/schema";
|
|
2
|
+
import { Callable, Hkt, type Constructor, type array, type conform } from "@ark/util";
|
|
3
|
+
import type { Generic, GenericParser, ParameterString, baseGenericConstraints, parseValidGenericParams, validateParameterString } from "./generic.ts";
|
|
4
|
+
import type { distill } from "./keywords/inference.ts";
|
|
5
|
+
import type { Ark, keywords, type } from "./keywords/keywords.ts";
|
|
6
|
+
import type { BaseType } from "./methods/base.ts";
|
|
7
|
+
import type { instantiateType } from "./methods/instantiate.ts";
|
|
8
|
+
import type { validateDeclared, validateDefinition } from "./parser/definition.ts";
|
|
7
9
|
import type { IndexOneOperator, IndexZeroOperator, TupleInfixOperator } from "./parser/tuple.ts";
|
|
8
10
|
import type { InternalScope, ModuleParser, Scope, ScopeParser, bindThis } from "./scope.ts";
|
|
9
|
-
import type { BaseType } from "./subtypes/base.ts";
|
|
10
|
-
import type { instantiateType } from "./subtypes/instantiate.ts";
|
|
11
11
|
/** The convenience properties attached to `type` */
|
|
12
12
|
export type TypeParserAttachments = Omit<TypeParser, never>;
|
|
13
13
|
export interface TypeParser<$ = {}> extends Ark.boundTypeAttachments<$> {
|
|
14
|
-
<const def, r = Type<
|
|
15
|
-
<params extends ParameterString, const def>(params: validateParameterString<params, $>, def: validateDefinition<def, $, baseGenericConstraints<parseValidGenericParams<params, $>>>): Generic<parseValidGenericParams<params, $>, def, $>;
|
|
16
|
-
<const zero, const one, const rest extends array, r = Type<
|
|
17
|
-
raw(def: unknown): BaseType<any, $>;
|
|
14
|
+
<const def, r = Type<type.infer<def, $>, $>>(def: type.validate<def, $>): r;
|
|
15
|
+
<const params extends ParameterString, const def>(params: validateParameterString<params, $>, def: validateDefinition<def, $, baseGenericConstraints<parseValidGenericParams<params, $>>>): Generic<parseValidGenericParams<params, $>, def, $>;
|
|
16
|
+
<const zero, const one, const rest extends array, r = Type<type.infer<[zero, one, ...rest], $>, $>>(_0: zero extends IndexZeroOperator ? zero : type.validate<zero, $>, _1: zero extends "keyof" ? type.validate<one, $> : zero extends "instanceof" ? conform<one, Constructor> : zero extends "===" ? conform<one, unknown> : conform<one, IndexOneOperator>, ..._2: zero extends "===" ? rest : zero extends "instanceof" ? conform<rest, readonly Constructor[]> : one extends TupleInfixOperator ? one extends ":" ? [Predicate<distill.In<type.infer<zero, $>>>] : one extends "=>" ? [Morph<distill.Out<type.infer<zero, $>>, unknown>] : one extends "@" ? [MetaSchema] : one extends "=" ? [distill.In<type.infer<NoInfer<zero>, $>>] : [type.validate<rest[0], $>] : []): r;
|
|
18
17
|
errors: typeof ArkErrors;
|
|
18
|
+
hkt: typeof Hkt;
|
|
19
|
+
keywords: typeof keywords;
|
|
20
|
+
$: Scope<$>;
|
|
21
|
+
raw(def: unknown): BaseType<any, $>;
|
|
19
22
|
module: ModuleParser;
|
|
20
23
|
scope: ScopeParser;
|
|
21
|
-
|
|
24
|
+
define: DefinitionParser<$>;
|
|
25
|
+
generic: GenericParser<$>;
|
|
26
|
+
schema: SchemaParser<$>;
|
|
27
|
+
unit: UnitTypeParser<$>;
|
|
28
|
+
enumerated: EnumeratedTypeParser<$>;
|
|
22
29
|
}
|
|
23
30
|
export declare class InternalTypeParser extends Callable<(...args: unknown[]) => BaseRoot | Generic, TypeParserAttachments> {
|
|
24
31
|
constructor($: InternalScope);
|
|
@@ -26,14 +33,10 @@ export declare class InternalTypeParser extends Callable<(...args: unknown[]) =>
|
|
|
26
33
|
export type DeclarationParser<$> = <preinferred>() => {
|
|
27
34
|
type: <const def>(def: validateDeclared<preinferred, def, $, bindThis<def>>) => Type<preinferred, $>;
|
|
28
35
|
};
|
|
29
|
-
export type
|
|
30
|
-
export type
|
|
31
|
-
export type
|
|
32
|
-
export type
|
|
33
|
-
export type inferAmbient<def> = inferTypeRoot<def, {}>;
|
|
36
|
+
export type UnitTypeParser<$> = <const t>(value: t) => Type<t, $>;
|
|
37
|
+
export type EnumeratedTypeParser<$> = <const values extends readonly unknown[]>(...values: values) => Type<values[number], $>;
|
|
38
|
+
export type DefinitionParser<$> = <const def>(def: type.validate<def, $>) => def;
|
|
39
|
+
export type SchemaParser<$> = (schema: RootSchema, opts?: BaseParseOptions) => Type<unknown, $>;
|
|
34
40
|
export type Type<t = unknown, $ = {}> = instantiateType<t, $>;
|
|
35
|
-
export declare namespace Type {
|
|
36
|
-
type Any<t = any> = BaseType<t, any>;
|
|
37
|
-
}
|
|
38
41
|
export type TypeConstructor<t = unknown, $ = {}> = new (def: unknown, $: Scope<$>) => Type<t, $>;
|
|
39
42
|
export declare const Type: TypeConstructor;
|
package/out/type.js
CHANGED
|
@@ -1,22 +1,28 @@
|
|
|
1
1
|
import { ArkErrors, BaseRoot, GenericRoot } from "@ark/schema";
|
|
2
|
-
import { Callable } from "@ark/util";
|
|
3
|
-
import { parseGenericParams } from "./generic.js";
|
|
2
|
+
import { Callable, Hkt } from "@ark/util";
|
|
4
3
|
export class InternalTypeParser extends Callable {
|
|
5
4
|
constructor($) {
|
|
6
5
|
const attach = Object.assign({
|
|
7
6
|
errors: ArkErrors,
|
|
8
|
-
|
|
7
|
+
hkt: Hkt,
|
|
8
|
+
$: $,
|
|
9
|
+
raw: $.parse,
|
|
9
10
|
module: $.constructor.module,
|
|
10
11
|
scope: $.constructor.scope,
|
|
12
|
+
define: $.define,
|
|
13
|
+
generic: $.generic,
|
|
14
|
+
schema: $.schema,
|
|
11
15
|
// this won't be defined during bootstrapping, but externally always will be
|
|
12
|
-
|
|
16
|
+
keywords: $.ambient,
|
|
17
|
+
unit: $.unit,
|
|
18
|
+
enumerated: $.enumerated
|
|
13
19
|
},
|
|
14
20
|
// also won't be defined during bootstrapping
|
|
15
21
|
$.ambientAttachments);
|
|
16
22
|
super((...args) => {
|
|
17
23
|
if (args.length === 1) {
|
|
18
24
|
// treat as a simple definition
|
|
19
|
-
return $.
|
|
25
|
+
return $.parse(args[0]);
|
|
20
26
|
}
|
|
21
27
|
if (args.length === 2 &&
|
|
22
28
|
typeof args[0] === "string" &&
|
|
@@ -24,16 +30,14 @@ export class InternalTypeParser extends Callable {
|
|
|
24
30
|
args[0].at(-1) === ">") {
|
|
25
31
|
// if there are exactly two args, the first of which looks like <${string}>,
|
|
26
32
|
// treat as a generic
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
args: {}
|
|
30
|
-
});
|
|
33
|
+
const paramString = args[0].slice(1, -1);
|
|
34
|
+
const params = $.parseGenericParams(paramString, {});
|
|
31
35
|
return new GenericRoot(params, args[1], $, $);
|
|
32
36
|
}
|
|
33
37
|
// otherwise, treat as a tuple expression. technically, this also allows
|
|
34
38
|
// non-expression tuple definitions to be parsed, but it's not a supported
|
|
35
39
|
// part of the API as specified by the associated types
|
|
36
|
-
return $.
|
|
40
|
+
return $.parse(args);
|
|
37
41
|
}, {
|
|
38
42
|
bind: $,
|
|
39
43
|
attach
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arktype",
|
|
3
3
|
"description": "TypeScript's 1:1 validator, optimized from editor to runtime",
|
|
4
|
-
"version": "2.0.0-rc.
|
|
4
|
+
"version": "2.0.0-rc.11",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "David Blass",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"out"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@ark/util": "0.
|
|
38
|
-
"@ark/schema": "0.
|
|
37
|
+
"@ark/util": "0.13.0",
|
|
38
|
+
"@ark/schema": "0.13.0"
|
|
39
39
|
},
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|
package/out/intersect.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { anyOrNever, array, Hkt, intersectArrays, show } from "@ark/util";
|
|
2
|
-
import type { constrain, Constraints, MorphAst, parseConstraints, To } from "./keywords/ast.ts";
|
|
3
|
-
export type inferIntersection<l, r> = _inferIntersection<l, r, false>;
|
|
4
|
-
export type inferPipe<l, r> = _inferIntersection<l, r, true>;
|
|
5
|
-
type _inferIntersection<l, r, piped extends boolean> = [
|
|
6
|
-
l & r
|
|
7
|
-
] extends [infer t extends anyOrNever] ? t : l extends MorphAst<infer lIn, infer lOut> ? r extends MorphAst<any, infer rOut> ? piped extends true ? (In: lIn) => rOut : never : piped extends true ? (In: lIn) => To<r> : (In: _inferIntersection<lIn, r, false>) => lOut : r extends MorphAst<infer rIn, infer rOut> ? (In: _inferIntersection<rIn, l, false>) => rOut : parseConstraints<l> extends ([
|
|
8
|
-
infer lBase,
|
|
9
|
-
infer lConstraints extends Constraints
|
|
10
|
-
]) ? parseConstraints<r> extends ([
|
|
11
|
-
infer rBase,
|
|
12
|
-
infer rConstraints extends Constraints
|
|
13
|
-
]) ? constrain<_inferIntersection<lBase, rBase, piped>, lConstraints & rConstraints> : constrain<_inferIntersection<lBase, r, piped>, lConstraints> : parseConstraints<r> extends ([
|
|
14
|
-
infer rBase,
|
|
15
|
-
infer rConstraints extends Constraints
|
|
16
|
-
]) ? constrain<_inferIntersection<l, rBase, piped>, rConstraints> : [l, r] extends [object, object] ? intersectObjects<l, r, piped> extends infer result ? result : never : l & r;
|
|
17
|
-
interface MorphableIntersection<piped extends boolean> extends Hkt<[unknown, unknown]> {
|
|
18
|
-
body: _inferIntersection<this[0], this[1], piped>;
|
|
19
|
-
}
|
|
20
|
-
type intersectObjects<l, r, piped extends boolean> = [
|
|
21
|
-
l,
|
|
22
|
-
r
|
|
23
|
-
] extends [infer lList extends array, infer rList extends array] ? intersectArrays<lList, rList, MorphableIntersection<piped>> : show<{
|
|
24
|
-
[k in keyof l]: k extends keyof r ? _inferIntersection<l[k], r[k], piped> : l[k];
|
|
25
|
-
} & {
|
|
26
|
-
[k in keyof r]: k extends keyof l ? _inferIntersection<l[k], r[k], piped> : r[k];
|
|
27
|
-
}>;
|
|
28
|
-
export {};
|
package/out/keys.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import type { array, join, Key, NonNegativeIntegerLiteral, typeToString } from "@ark/util";
|
|
2
|
-
import type { type } from "./keywords/ark.ts";
|
|
3
|
-
import type { termOrType } from "./keywords/ast.ts";
|
|
4
|
-
export type toArkKey<o, k extends keyof o> = k extends number ? [
|
|
5
|
-
o,
|
|
6
|
-
number
|
|
7
|
-
] extends [array, k] ? NonNegativeIntegerLiteral : `${k}` : k;
|
|
8
|
-
export type arkKeyOf<o> = o extends array ? (number extends o["length"] ? NonNegativeIntegerLiteral : never) | {
|
|
9
|
-
[k in keyof o]-?: k extends `${infer index extends number}` ? index | k : never;
|
|
10
|
-
}[keyof o & `${number}`] : {
|
|
11
|
-
[k in keyof o]: k extends number ? k | `${k}` : k;
|
|
12
|
-
}[keyof o];
|
|
13
|
-
export type getArkKey<o, k extends arkKeyOf<o>> = o[Extract<k extends NonNegativeIntegerLiteral ? number : k, keyof o>];
|
|
14
|
-
export type TypeKey = termOrType<Key>;
|
|
15
|
-
export type typeKeyToString<k extends TypeKey> = typeToString<k extends type.cast<infer t> ? t : k>;
|
|
16
|
-
export type writeInvalidKeysMessage<o extends string, keys extends array<string>> = `Key${keys["length"] extends 1 ? "" : "s"} ${join<keys, ", ">} ${keys["length"] extends 1 ? "does" : "do"} not exist on ${o}`;
|
package/out/keywords/ark.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { ArkErrors, arkKind } from "@ark/schema";
|
|
2
|
-
import type { inferred } from "@ark/util";
|
|
3
|
-
import type { GenericParser } from "../generic.ts";
|
|
4
|
-
import type { BoundModule, Module } from "../module.ts";
|
|
5
|
-
import { type Scope } from "../scope.ts";
|
|
6
|
-
import type { DeclarationParser, DefinitionParser, TypeParser } from "../type.ts";
|
|
7
|
-
import { arkBuiltins } from "./builtins.ts";
|
|
8
|
-
import { arkPrototypes } from "./constructors/constructors.ts";
|
|
9
|
-
import { number } from "./number/number.ts";
|
|
10
|
-
import { string } from "./string/string.ts";
|
|
11
|
-
import { arkTsGenerics, arkTsKeywords } from "./ts.ts";
|
|
12
|
-
export interface Ark extends Omit<Ark.keywords, keyof Ark.wrapped>, Ark.wrapped {
|
|
13
|
-
}
|
|
14
|
-
export declare namespace Ark {
|
|
15
|
-
interface keywords extends arkTsKeywords.$, arkTsGenerics.$, arkPrototypes.keywords, arkBuiltins.$ {
|
|
16
|
-
}
|
|
17
|
-
interface wrapped extends arkPrototypes.wrapped {
|
|
18
|
-
string: string.submodule;
|
|
19
|
-
number: number.submodule;
|
|
20
|
-
}
|
|
21
|
-
interface typeAttachments extends arkTsKeywords.$ {
|
|
22
|
-
Key: arkBuiltins.$["Key"];
|
|
23
|
-
Record: arkTsGenerics.$["Record"];
|
|
24
|
-
}
|
|
25
|
-
interface boundTypeAttachments<$> extends Omit<BoundModule<typeAttachments, $>, arkKind> {
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
export declare const ambient: Scope<Ark>;
|
|
29
|
-
export declare const ark: Module<Ark>;
|
|
30
|
-
export declare const type: TypeParser<{}>;
|
|
31
|
-
export declare namespace type {
|
|
32
|
-
type cast<t> = {
|
|
33
|
-
[inferred]?: t;
|
|
34
|
-
};
|
|
35
|
-
type errors = ArkErrors;
|
|
36
|
-
}
|
|
37
|
-
export declare const generic: GenericParser<{}>;
|
|
38
|
-
export declare const define: DefinitionParser<{}>;
|
|
39
|
-
export declare const declare: DeclarationParser<{}>;
|
package/out/keywords/ast.d.ts
DELETED
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
import type { ArkError, ArkErrors, Constraint, constraintKindOf, Morph, NodeSchema } from "@ark/schema";
|
|
2
|
-
import { type anyOrNever, type array, type conform, type equals, type leftIfEqual, type Primitive, type show } from "@ark/util";
|
|
3
|
-
import type { inferPipe } from "../intersect.ts";
|
|
4
|
-
import type { Type } from "../type.ts";
|
|
5
|
-
import type { type } from "./ark.ts";
|
|
6
|
-
import type { arkPrototypes } from "./constructors/constructors.ts";
|
|
7
|
-
import type { number } from "./number/number.ts";
|
|
8
|
-
import type { string } from "./string/string.ts";
|
|
9
|
-
export type { arkPrototypes as object } from "./constructors/constructors.ts";
|
|
10
|
-
export type { number } from "./number/number.ts";
|
|
11
|
-
export type { string } from "./string/string.ts";
|
|
12
|
-
export type Comparator = "<" | "<=" | ">" | ">=" | "==";
|
|
13
|
-
export type RegexLiteral<source extends string = string> = `/${source}/`;
|
|
14
|
-
export type DateLiteral<source extends string = string> = `d"${source}"` | `d'${source}'`;
|
|
15
|
-
export type ConstraintSet = Record<PropertyKey, 1>;
|
|
16
|
-
export type Constraints = Record<string, ConstraintSet>;
|
|
17
|
-
export declare const constrained: " arkConstrained";
|
|
18
|
-
export type constrained = typeof constrained;
|
|
19
|
-
export type constrain<base, constraints extends Constraints> = base & {
|
|
20
|
-
[constrained]: constraints;
|
|
21
|
-
};
|
|
22
|
-
export type LimitLiteral = number | DateLiteral;
|
|
23
|
-
export type normalizeLimit<limit> = limit extends DateLiteral<infer source> ? source : limit extends number | string ? limit : never;
|
|
24
|
-
type constraint<rule> = {
|
|
25
|
-
[k in rule & PropertyKey]: 1;
|
|
26
|
-
};
|
|
27
|
-
export type AtLeast<rule> = {
|
|
28
|
-
atLeast: constraint<rule>;
|
|
29
|
-
};
|
|
30
|
-
export type AtMost<rule> = {
|
|
31
|
-
atMost: constraint<rule>;
|
|
32
|
-
};
|
|
33
|
-
export type MoreThan<rule> = {
|
|
34
|
-
moreThan: constraint<rule>;
|
|
35
|
-
};
|
|
36
|
-
export type LessThan<rule> = {
|
|
37
|
-
lessThan: constraint<rule>;
|
|
38
|
-
};
|
|
39
|
-
export type Literal<rule> = {
|
|
40
|
-
literal: constraint<rule>;
|
|
41
|
-
};
|
|
42
|
-
export type DivisibleBy<rule> = {
|
|
43
|
-
divisibleBy: constraint<rule>;
|
|
44
|
-
};
|
|
45
|
-
export type Length<rule> = {
|
|
46
|
-
length: constraint<rule>;
|
|
47
|
-
};
|
|
48
|
-
export type Matching<rule> = {
|
|
49
|
-
matching: constraint<rule>;
|
|
50
|
-
};
|
|
51
|
-
export type Narrowed = {
|
|
52
|
-
predicate: {
|
|
53
|
-
[k in "?"]: 1;
|
|
54
|
-
};
|
|
55
|
-
};
|
|
56
|
-
export type Branded<rule> = {
|
|
57
|
-
predicate: constraint<rule>;
|
|
58
|
-
};
|
|
59
|
-
export type primitiveConstraintKindOf<In> = Extract<Constraint.PrimitiveKind, constraintKindOf<In>>;
|
|
60
|
-
export type AtLeastLength<rule> = {
|
|
61
|
-
atLeastLength: constraint<rule>;
|
|
62
|
-
};
|
|
63
|
-
export type AtMostLength<rule> = {
|
|
64
|
-
atMostLength: constraint<rule>;
|
|
65
|
-
};
|
|
66
|
-
export type MoreThanLength<rule> = {
|
|
67
|
-
moreThanLength: constraint<rule>;
|
|
68
|
-
};
|
|
69
|
-
export type LessThanLength<rule> = {
|
|
70
|
-
lessThanLength: constraint<rule>;
|
|
71
|
-
};
|
|
72
|
-
export type ExactlyLength<rule> = {
|
|
73
|
-
atLeastLength: constraint<rule>;
|
|
74
|
-
atMostLength: constraint<rule>;
|
|
75
|
-
};
|
|
76
|
-
export type AtOrAfter<rule> = {
|
|
77
|
-
atOrAfter: constraint<rule>;
|
|
78
|
-
};
|
|
79
|
-
export type AtOrBefore<rule> = {
|
|
80
|
-
atOrBefore: constraint<rule>;
|
|
81
|
-
};
|
|
82
|
-
export type After<rule> = {
|
|
83
|
-
after: constraint<rule>;
|
|
84
|
-
};
|
|
85
|
-
export type Before<rule> = {
|
|
86
|
-
before: constraint<rule>;
|
|
87
|
-
};
|
|
88
|
-
export declare namespace Date {
|
|
89
|
-
type atOrAfter<rule> = constrain<Date, AtOrAfter<rule>>;
|
|
90
|
-
type after<rule> = constrain<Date, After<rule>>;
|
|
91
|
-
type atOrBefore<rule> = constrain<Date, AtOrBefore<rule>>;
|
|
92
|
-
type before<rule> = constrain<Date, Before<rule>>;
|
|
93
|
-
type narrowed = constrain<Date, Narrowed>;
|
|
94
|
-
type branded<rule> = constrain<Date, Branded<rule>>;
|
|
95
|
-
type literal<rule> = constrain<Date, Literal<rule>>;
|
|
96
|
-
type is<constraints extends Constraints> = constrain<Date, constraints>;
|
|
97
|
-
type parseConstraint<kind extends Constraint.PrimitiveKind, schema extends NodeSchema<kind>> = normalizePrimitiveConstraintRoot<schema> extends infer rule ? kind extends "after" ? schema extends {
|
|
98
|
-
exclusive: true;
|
|
99
|
-
} ? after<normalizeLimit<rule>> : atOrAfter<normalizeLimit<rule>> : kind extends "before" ? schema extends {
|
|
100
|
-
exclusive: true;
|
|
101
|
-
} ? before<normalizeLimit<rule>> : atOrBefore<normalizeLimit<rule>> : narrowed : never;
|
|
102
|
-
}
|
|
103
|
-
export type applyConstraint<t, kind extends Constraint.PrimitiveKind, schema extends NodeSchema<kind>> = t extends MorphAst<infer i, infer o> ? (In: leftIfEqual<i, _applyConstraint<i, kind, schema>>) => o : leftIfEqual<t, _applyConstraint<t, kind, schema>>;
|
|
104
|
-
type _applyConstraint<t, kind extends Constraint.PrimitiveKind, schema extends NodeSchema<kind>> = schemaToConstraint<kind, schema> extends infer constraint ? parseConstraints<t> extends ([
|
|
105
|
-
infer base,
|
|
106
|
-
infer constraints extends Constraints
|
|
107
|
-
]) ? [
|
|
108
|
-
number,
|
|
109
|
-
base
|
|
110
|
-
] extends [base, number] ? number.is<constraint & constraints> : [string, base] extends [base, string] ? string.is<constraint & constraints> : [Date, base] extends [base, Date] ? Date.is<constraint & constraints> : constrain<base, constraints & constraint> : [number, t] extends [t, number] ? number.parseConstraint<kind, schema> : [string, t] extends [t, string] ? string.parseConstraint<kind, schema> : [Date, t] extends [t, Date] ? Date.parseConstraint<kind, schema> : constrain<t, conform<constraint, Constraints>> : never;
|
|
111
|
-
export type parseConstraints<t> = t extends constrain<infer base, infer constraints> ? equals<t, number & {
|
|
112
|
-
[constrained]: constraints;
|
|
113
|
-
}> extends true ? [
|
|
114
|
-
number,
|
|
115
|
-
constraints
|
|
116
|
-
] : equals<t, string & {
|
|
117
|
-
[constrained]: constraints;
|
|
118
|
-
}> extends true ? [
|
|
119
|
-
string,
|
|
120
|
-
constraints
|
|
121
|
-
] : equals<t, Date & {
|
|
122
|
-
[constrained]: constraints;
|
|
123
|
-
}> extends true ? [
|
|
124
|
-
Date,
|
|
125
|
-
constraints
|
|
126
|
-
] : [base, constraints] : null;
|
|
127
|
-
export type normalizePrimitiveConstraintRoot<schema extends NodeSchema<Constraint.PrimitiveKind>> = "rule" extends keyof schema ? conform<schema["rule"], PropertyKey> : conform<schema, PropertyKey>;
|
|
128
|
-
export type schemaToConstraint<kind extends Constraint.PrimitiveKind, schema extends NodeSchema<kind>> = normalizePrimitiveConstraintRoot<schema> extends infer rule ? kind extends "pattern" ? Matching<rule> : kind extends "divisor" ? DivisibleBy<rule> : kind extends "exactLength" ? Length<rule> : kind extends "min" ? schema extends {
|
|
129
|
-
exclusive: true;
|
|
130
|
-
} ? MoreThan<rule> : AtLeast<rule> : kind extends "max" ? schema extends {
|
|
131
|
-
exclusive: true;
|
|
132
|
-
} ? LessThan<rule> : AtMost<rule> : kind extends "minLength" ? schema extends {
|
|
133
|
-
exclusive: true;
|
|
134
|
-
} ? MoreThanLength<rule> : AtLeastLength<rule> : kind extends "maxLength" ? schema extends {
|
|
135
|
-
exclusive: true;
|
|
136
|
-
} ? LessThanLength<rule> : AtMostLength<rule> : kind extends "exactLength" ? ExactlyLength<rule> : kind extends "after" ? schema extends {
|
|
137
|
-
exclusive: true;
|
|
138
|
-
} ? After<normalizeLimit<rule>> : AtOrAfter<normalizeLimit<rule>> : kind extends "before" ? schema extends {
|
|
139
|
-
exclusive: true;
|
|
140
|
-
} ? Before<normalizeLimit<rule>> : AtOrBefore<normalizeLimit<rule>> : Narrowed : never;
|
|
141
|
-
export type distillIn<t> = finalizeDistillation<t, _distill<t, "in", "base">>;
|
|
142
|
-
export type distillOut<t> = finalizeDistillation<t, _distill<t, "out", "base">>;
|
|
143
|
-
export type distillConstrainableIn<t> = finalizeDistillation<t, _distill<t, "in", "constrainable">>;
|
|
144
|
-
export type distillConstrainableOut<t> = finalizeDistillation<t, _distill<t, "out", "constrainable">>;
|
|
145
|
-
export type distillValidatedOut<t> = finalizeDistillation<t, _distill<t, "validatedOut", "constrainable">>;
|
|
146
|
-
type finalizeDistillation<t, distilled> = equals<t, distilled> extends true ? t : distilled;
|
|
147
|
-
export type includesMorphs<t> = [
|
|
148
|
-
_distill<t, "in", "constrainable">,
|
|
149
|
-
_distill<t, "out", "constrainable">
|
|
150
|
-
] extends ([
|
|
151
|
-
_distill<t, "out", "constrainable">,
|
|
152
|
-
_distill<t, "in", "constrainable">
|
|
153
|
-
]) ? false : true;
|
|
154
|
-
type IoKind = "in" | "out" | "validatedOut";
|
|
155
|
-
type DistilledKind = "base" | "constrainable";
|
|
156
|
-
type _distill<t, io extends IoKind, distilledKind extends DistilledKind> = t extends undefined ? t : [t] extends [anyOrNever] ? t : parseConstraints<t> extends ([
|
|
157
|
-
infer base,
|
|
158
|
-
infer constraints extends Constraints
|
|
159
|
-
]) ? distilledKind extends "base" ? _distill<base, io, distilledKind> : constrain<_distill<base, io, distilledKind>, constraints> : t extends TerminallyInferredObjectKind | Primitive ? t : unknown extends t ? unknown : t extends MorphAst<infer i, infer o> ? io extends "in" ? _distill<i, io, distilledKind> : io extends "validatedOut" ? o extends To<infer validatedOut> ? _distill<validatedOut, io, distilledKind> : unknown : _distill<o[1], io, distilledKind> : t extends DefaultableAst<infer t> ? _distill<t, io, distilledKind> : t extends array ? distillArray<t, io, distilledKind, []> : t extends Function ? t : {
|
|
160
|
-
[k in keyof t]: t[k];
|
|
161
|
-
} extends t ? io extends "in" ? show<{
|
|
162
|
-
[k in keyof t as k extends defaultableKeyOf<t> ? never : k]: _distill<t[k], io, distilledKind>;
|
|
163
|
-
} & {
|
|
164
|
-
[k in defaultableKeyOf<t>]?: _distill<t[k], io, distilledKind>;
|
|
165
|
-
}> : {
|
|
166
|
-
[k in keyof t]: _distill<t[k], io, distilledKind>;
|
|
167
|
-
} : t;
|
|
168
|
-
export type defaultableKeyOf<t> = {
|
|
169
|
-
[k in keyof t]: [t[k]] extends [anyOrNever] ? never : t[k] extends DefaultableAst ? k : never;
|
|
170
|
-
}[keyof t];
|
|
171
|
-
type distillArray<t extends array, io extends IoKind, constraints extends DistilledKind, prefix extends array> = _distillArray<t, io, constraints, prefix> extends infer result ? t extends unknown[] ? result : Readonly<t> : never;
|
|
172
|
-
type _distillArray<t extends array, io extends IoKind, constraints extends DistilledKind, prefix extends array> = t extends readonly [infer head, ...infer tail] ? _distillArray<tail, io, constraints, [
|
|
173
|
-
...prefix,
|
|
174
|
-
_distill<head, io, constraints>
|
|
175
|
-
]> : [...prefix, ...distillPostfix<t, io, constraints>];
|
|
176
|
-
type distillPostfix<t extends array, io extends IoKind, constraints extends DistilledKind, postfix extends array = []> = t extends readonly [...infer init, infer last] ? distillPostfix<init, io, constraints, [
|
|
177
|
-
_distill<last, io, constraints>,
|
|
178
|
-
...postfix
|
|
179
|
-
]> : [...{
|
|
180
|
-
[i in keyof t]: _distill<t[i], io, constraints>;
|
|
181
|
-
}, ...postfix];
|
|
182
|
-
/** Objects we don't want to expand during inference like Date or Promise */
|
|
183
|
-
type TerminallyInferredObjectKind = arkPrototypes.instanceOfExcluding<"Array" | "Function"> | ArkEnv.prototypes;
|
|
184
|
-
export type inferPredicate<t, predicate> = predicate extends (data: any, ...args: any[]) => data is infer narrowed ? t extends constrain<unknown, infer constraints> ? applyConstraint<constrain<narrowed, constraints>, "predicate", any> : applyConstraint<narrowed, "predicate", any> : applyConstraint<t, "predicate", any>;
|
|
185
|
-
export type constrainWithPredicate<t> = t extends constrain<unknown, infer constraints> ? applyConstraint<constrain<t, constraints>, "predicate", any> : applyConstraint<t, "predicate", any>;
|
|
186
|
-
export type inferPipes<t, pipes extends Morph[]> = pipes extends [infer head extends Morph, ...infer tail extends Morph[]] ? inferPipes<pipes[0] extends type.cast<infer tPipe> ? inferPipe<t, tPipe> : inferMorphOut<head> extends infer out ? (In: distillConstrainableIn<t>) => Out<out> : never, tail> : t;
|
|
187
|
-
export type inferMorphOut<morph extends Morph> = Exclude<ReturnType<morph>, ArkError | ArkErrors>;
|
|
188
|
-
export type Out<o = any> = ["=>", o, boolean];
|
|
189
|
-
export type To<o = any> = ["=>", o, true];
|
|
190
|
-
export type MorphAst<i = any, o extends Out = Out> = (In: i) => o;
|
|
191
|
-
export type Default<v = any> = ["=", v];
|
|
192
|
-
export type DefaultableAst<t = any, v = any> = (In?: t) => Default<v>;
|
|
193
|
-
export type termOrType<t> = t | Type<t, any>;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { ErrorMessage } from "@ark/util";
|
|
2
|
-
import type { inferAmbient } from "../../type.ts";
|
|
3
|
-
import type { UnitLiteral } from "../string/shift/operator/default.ts";
|
|
4
|
-
import type { inferAstOut } from "./infer.ts";
|
|
5
|
-
import type { astToString } from "./utils.ts";
|
|
6
|
-
import type { validateAst } from "./validate.ts";
|
|
7
|
-
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>>;
|
|
8
|
-
export declare const writeUnassignableDefaultValueMessage: <key extends string, message extends string>(key: key, message: message) => string;
|
|
9
|
-
export type writeUnassignableDefaultValueMessage<baseDef extends string, defaultValue extends string> = `Default value ${defaultValue} is not assignable to ${baseDef}`;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const writeUnassignableDefaultValueMessage = (key, message) => `Default value at ${key} ${message}`;
|
package/out/subtypes/base.d.ts
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import type { ArkErrors, BaseRoot, Disjoint, JsonSchema, MetaSchema, Morph, UndeclaredKeyBehavior } from "@ark/schema";
|
|
2
|
-
import type { anyOrNever, array, Callable, ErrorMessage, inferred, Json, unset } from "@ark/util";
|
|
3
|
-
import type { inferIntersection } from "../intersect.ts";
|
|
4
|
-
import type { distillConstrainableIn, distillConstrainableOut, distillIn, distillOut, distillValidatedOut, inferMorphOut, inferPipes } from "../keywords/ast.ts";
|
|
5
|
-
import type { Scope } from "../scope.ts";
|
|
6
|
-
import type { inferTypeRoot, validateTypeRoot } from "../type.ts";
|
|
7
|
-
import type { ArrayType } from "./array.ts";
|
|
8
|
-
import type { instantiateType } from "./instantiate.ts";
|
|
9
|
-
/** @ts-ignore cast variance */
|
|
10
|
-
interface Type<out t = unknown, $ = {}> extends Callable<(data: unknown) => distillOut<t> | ArkErrors> {
|
|
11
|
-
t: t;
|
|
12
|
-
tIn: distillConstrainableIn<t>;
|
|
13
|
-
tOut: distillConstrainableOut<t>;
|
|
14
|
-
tValidatedOut: distillValidatedOut<t>;
|
|
15
|
-
infer: distillOut<t>;
|
|
16
|
-
inferIn: distillIn<t>;
|
|
17
|
-
[inferred]: t;
|
|
18
|
-
json: Json;
|
|
19
|
-
toJsonSchema(): JsonSchema;
|
|
20
|
-
description: string;
|
|
21
|
-
expression: string;
|
|
22
|
-
internal: BaseRoot;
|
|
23
|
-
$: Scope<$>;
|
|
24
|
-
assert(data: unknown): this["infer"];
|
|
25
|
-
allows(data: unknown): data is this["inferIn"];
|
|
26
|
-
traverse(data: unknown): distillOut<t> | ArkErrors;
|
|
27
|
-
configure(meta: MetaSchema): this;
|
|
28
|
-
describe(description: string): this;
|
|
29
|
-
onUndeclaredKey(behavior: UndeclaredKeyBehavior): this;
|
|
30
|
-
onDeepUndeclaredKey(behavior: UndeclaredKeyBehavior): this;
|
|
31
|
-
from(literal: this["inferIn"]): this["infer"];
|
|
32
|
-
as<t = unset>(...args: validateChainedAsArgs<t>): instantiateType<t, $>;
|
|
33
|
-
get in(): instantiateType<this["tIn"], $>;
|
|
34
|
-
get out(): instantiateType<this["tValidatedOut"], $>;
|
|
35
|
-
intersect<const def, r = inferTypeRoot<def, $>>(def: validateTypeRoot<def, $>): instantiateType<inferIntersection<t, r>, $> | Disjoint;
|
|
36
|
-
and<const def, r = inferTypeRoot<def, $>>(def: validateTypeRoot<def, $>): instantiateType<inferIntersection<t, r>, $>;
|
|
37
|
-
or<const def, r = inferTypeRoot<def, $>>(def: validateTypeRoot<def, $>): instantiateType<t | r, $>;
|
|
38
|
-
array(): ArrayType<t[], $>;
|
|
39
|
-
pipe: ChainedPipes<t, $>;
|
|
40
|
-
equals<def>(def: validateTypeRoot<def, $>): this is instantiateType<inferTypeRoot<def, $>, $>;
|
|
41
|
-
extract<def>(r: validateTypeRoot<def, $>): instantiateType<Extract<t, inferTypeRoot<def, $>>, $>;
|
|
42
|
-
exclude<def>(r: validateTypeRoot<def, $>): instantiateType<Exclude<t, inferTypeRoot<def, $>>, $>;
|
|
43
|
-
extends<def>(other: validateTypeRoot<def, $>): this is instantiateType<inferTypeRoot<def, $>, $>;
|
|
44
|
-
overlaps<def>(r: validateTypeRoot<def, $>): boolean;
|
|
45
|
-
distribute<mapOut, reduceOut = mapOut[]>(mapBranch: (branch: Type, i: number, branches: array<Type>) => mapOut, reduceMapped?: (mappedBranches: mapOut[]) => reduceOut): reduceOut;
|
|
46
|
-
/** @deprecated */
|
|
47
|
-
apply: Function["apply"];
|
|
48
|
-
/** @deprecated */
|
|
49
|
-
bind: Function["bind"];
|
|
50
|
-
/** @deprecated */
|
|
51
|
-
call: Function["call"];
|
|
52
|
-
/** @deprecated */
|
|
53
|
-
caller: Function;
|
|
54
|
-
/** @deprecated */
|
|
55
|
-
length: number;
|
|
56
|
-
/** @deprecated */
|
|
57
|
-
name: string;
|
|
58
|
-
/** @deprecated */
|
|
59
|
-
prototype: Function["prototype"];
|
|
60
|
-
/** @deprecated */
|
|
61
|
-
arguments: Function["arguments"];
|
|
62
|
-
/** @deprecated */
|
|
63
|
-
Symbol: never;
|
|
64
|
-
}
|
|
65
|
-
interface ChainedPipeSignature<t, $> {
|
|
66
|
-
<a extends Morph<distillOut<t>>, r = instantiateType<inferPipes<t, [a]>, $>>(a: a): r;
|
|
67
|
-
<a extends Morph<distillOut<t>>, b extends Morph<inferMorphOut<a>>, r = instantiateType<inferPipes<t, [a, b]>, $>>(a: a, b: b): r;
|
|
68
|
-
<a extends Morph<distillOut<t>>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, r = instantiateType<inferPipes<t, [a, b, c]>, $>>(a: a, b: b, c: c): r;
|
|
69
|
-
<a extends Morph<distillOut<t>>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, d extends Morph<inferMorphOut<c>>, r = instantiateType<inferPipes<t, [a, b, c, d]>, $>>(a: a, b: b, c: c, d: d): r;
|
|
70
|
-
<a extends Morph<distillOut<t>>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, d extends Morph<inferMorphOut<c>>, e extends Morph<inferMorphOut<d>>, r = instantiateType<inferPipes<t, [a, b, c, d, e]>, $>>(a: a, b: b, c: c, d: d, e: e): r;
|
|
71
|
-
<a extends Morph<distillOut<t>>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, d extends Morph<inferMorphOut<c>>, e extends Morph<inferMorphOut<d>>, f extends Morph<inferMorphOut<e>>, r = instantiateType<inferPipes<t, [a, b, c, d, e, f]>, $>>(a: a, b: b, c: c, d: d, e: e, f: f): r;
|
|
72
|
-
<a extends Morph<distillOut<t>>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, d extends Morph<inferMorphOut<c>>, e extends Morph<inferMorphOut<d>>, f extends Morph<inferMorphOut<e>>, g extends Morph<inferMorphOut<f>>, r = instantiateType<inferPipes<t, [a, b, c, d, e, f, g]>, $>>(a: a, b: b, c: c, d: d, e: e, f: f, g: g): r;
|
|
73
|
-
}
|
|
74
|
-
export interface ChainedPipes<t, $> extends ChainedPipeSignature<t, $> {
|
|
75
|
-
try: ChainedPipeSignature<t, $>;
|
|
76
|
-
}
|
|
77
|
-
type validateChainedAsArgs<t> = [
|
|
78
|
-
t
|
|
79
|
-
] extends [unset] ? [
|
|
80
|
-
t
|
|
81
|
-
] extends [anyOrNever] ? [
|
|
82
|
-
] : [
|
|
83
|
-
ErrorMessage<"as requires an explicit type parameter like myType.as<t>()">
|
|
84
|
-
] : [];
|
|
85
|
-
export type { Type as BaseType };
|
package/out/subtypes/morph.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import type { Predicate, PredicateCast } from "@ark/schema";
|
|
2
|
-
import type { inferPipe } from "../intersect.ts";
|
|
3
|
-
import type { applyConstraint, Out, To } from "../keywords/ast.ts";
|
|
4
|
-
import type { inferTypeRoot, validateTypeRoot } from "../type.ts";
|
|
5
|
-
import type { BaseType } from "./base.ts";
|
|
6
|
-
/** @ts-ignore cast variance */
|
|
7
|
-
interface Type<out t = unknown, $ = {}> extends BaseType<t, $> {
|
|
8
|
-
to<const def, r = inferTypeRoot<def, $>>(def: validateTypeRoot<def, $>): Type<inferPipe<t, r>, $>;
|
|
9
|
-
narrow<narrowed extends this["infer"] = never>(predicate: Predicate<this["infer"]> | PredicateCast<this["infer"], narrowed>): Type<([
|
|
10
|
-
narrowed
|
|
11
|
-
] extends [never] ? applyConstraint<this["tOut"], "predicate", Predicate> : narrowed) extends infer o ? this["tValidatedOut"] extends this["tOut"] ? (In: this["tIn"]) => To<o> : (In: this["tIn"]) => Out<o> : never, $>;
|
|
12
|
-
}
|
|
13
|
-
export type { Type as MorphType };
|
package/out/subtypes/object.d.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import type { array, ErrorType, merge } from "@ark/util";
|
|
2
|
-
import type { arkKeyOf, getArkKey, toArkKey } from "../keys.ts";
|
|
3
|
-
import type { type } from "../keywords/ark.ts";
|
|
4
|
-
import type { inferTypeRoot, validateTypeRoot } from "../type.ts";
|
|
5
|
-
import type { ArrayType } from "./array.ts";
|
|
6
|
-
import type { instantiateType } from "./instantiate.ts";
|
|
7
|
-
import type { ValidatorType } from "./validator.ts";
|
|
8
|
-
/** @ts-ignore cast variance */
|
|
9
|
-
interface Type<out t extends object = object, $ = {}> extends ValidatorType<t, $> {
|
|
10
|
-
readonly(): t extends array ? ArrayType<{
|
|
11
|
-
readonly [i in keyof t]: t[i];
|
|
12
|
-
}, $> : Type<{
|
|
13
|
-
readonly [k in keyof t]: t[k];
|
|
14
|
-
}, $>;
|
|
15
|
-
keyof(): instantiateType<keyof t, $>;
|
|
16
|
-
get<k1 extends arkKeyOf<t>, r = instantiateType<getArkKey<t, k1>, $>>(k1: k1 | type.cast<k1>): r;
|
|
17
|
-
get<k1 extends arkKeyOf<t>, k2 extends arkKeyOf<getArkKey<t, k1>>, r = instantiateType<getArkKey<getArkKey<t, k1>, k2>, $>>(k1: k1 | type.cast<k1>, k2: k2 | type.cast<k2>): r;
|
|
18
|
-
get<k1 extends arkKeyOf<t>, k2 extends arkKeyOf<getArkKey<t, k1>>, k3 extends arkKeyOf<getArkKey<getArkKey<t, k1>, k2>>, r = instantiateType<getArkKey<getArkKey<getArkKey<t, k1>, k2>, k3>, $>>(k1: k1 | type.cast<k1>, k2: k2 | type.cast<k2>, k3: k3 | type.cast<k3>): r;
|
|
19
|
-
pick<const key extends arkKeyOf<t> = never>(...keys: (key | type.cast<key>)[]): Type<{
|
|
20
|
-
[k in keyof t as Extract<toArkKey<t, k>, key>]: t[k];
|
|
21
|
-
}, $>;
|
|
22
|
-
omit<const key extends arkKeyOf<t> = never>(...keys: (key | type.cast<key>)[]): Type<{
|
|
23
|
-
[k in keyof t as Exclude<toArkKey<t, k>, key>]: t[k];
|
|
24
|
-
}, $>;
|
|
25
|
-
merge<const def, r = inferTypeRoot<def, $>>(def: validateTypeRoot<def, $> & (r extends object ? unknown : ErrorType<"Merged type must be an object", [actual: r]>)): Type<merge<t, r & object>, $>;
|
|
26
|
-
required(): Type<{
|
|
27
|
-
[k in keyof t]-?: t[k];
|
|
28
|
-
}, $>;
|
|
29
|
-
partial(): Type<{
|
|
30
|
-
[k in keyof t]?: t[k];
|
|
31
|
-
}, $>;
|
|
32
|
-
}
|
|
33
|
-
export type { Type as ObjectType };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|