arktype 2.0.0-rc.15 → 2.0.0-rc.16
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/{keywords/inference.d.ts → attributes.d.ts} +143 -54
- package/out/attributes.js +2 -0
- package/out/keywords/constructors/Array.d.ts +1 -1
- package/out/keywords/constructors/Date.d.ts +23 -18
- package/out/keywords/constructors/FormData.d.ts +1 -1
- package/out/keywords/keywords.d.ts +4 -4
- package/out/keywords/number/epoch.d.ts +2 -1
- package/out/keywords/number/number.d.ts +28 -28
- package/out/keywords/string/alpha.d.ts +2 -2
- package/out/keywords/string/alphanumeric.d.ts +2 -2
- package/out/keywords/string/base64.d.ts +3 -3
- package/out/keywords/string/capitalize.d.ts +2 -2
- package/out/keywords/string/creditCard.d.ts +2 -2
- package/out/keywords/string/date.d.ts +4 -4
- package/out/keywords/string/digits.d.ts +2 -2
- package/out/keywords/string/email.d.ts +2 -2
- package/out/keywords/string/integer.d.ts +2 -2
- package/out/keywords/string/ip.d.ts +4 -4
- package/out/keywords/string/json.d.ts +2 -2
- package/out/keywords/string/lower.d.ts +2 -2
- package/out/keywords/string/normalize.d.ts +5 -5
- package/out/keywords/string/numeric.d.ts +2 -2
- package/out/keywords/string/semver.d.ts +2 -2
- package/out/keywords/string/string.d.ts +26 -7
- package/out/keywords/string/trim.d.ts +2 -2
- package/out/keywords/string/upper.d.ts +2 -2
- package/out/keywords/string/url.d.ts +2 -2
- package/out/keywords/string/uuid.d.ts +10 -10
- package/out/keywords/ts.d.ts +1 -1
- package/out/methods/array.d.ts +6 -6
- package/out/methods/base.d.ts +16 -27
- package/out/methods/date.d.ts +5 -5
- package/out/methods/instantiate.d.ts +1 -1
- package/out/methods/morph.d.ts +1 -1
- package/out/methods/number.d.ts +6 -6
- package/out/methods/object.d.ts +3 -3
- package/out/methods/string.d.ts +7 -7
- package/out/parser/ast/bounds.d.ts +1 -1
- package/out/parser/ast/infer.d.ts +8 -7
- package/out/parser/objectLiteral.d.ts +1 -1
- package/out/parser/reduce/dynamic.d.ts +1 -1
- package/out/parser/reduce/shared.d.ts +1 -1
- package/out/parser/reduce/static.d.ts +1 -1
- package/out/parser/shift/operand/date.d.ts +1 -1
- package/out/parser/shift/operand/enclosed.d.ts +2 -2
- package/out/parser/shift/operator/bounds.d.ts +1 -1
- package/out/parser/shift/operator/default.d.ts +1 -1
- package/out/parser/tuple.d.ts +4 -4
- package/out/scope.d.ts +6 -1
- package/out/scope.js +3 -1
- package/out/type.d.ts +1 -1
- package/package.json +3 -3
- package/out/keywords/inference.js +0 -2
- package/out/keywords/string/brands.d.ts +0 -17
- package/out/keywords/string/brands.js +0 -1
package/out/parser/tuple.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type BaseParseContext, type BaseRoot, type MetaSchema, type Morph, type Predicate } from "@ark/schema";
|
|
2
|
-
import { type anyOrNever, type array, type BuiltinObjectKind, type conform, type Constructor, type Domain, type ErrorMessage, type show } from "@ark/util";
|
|
3
|
-
import type {
|
|
2
|
+
import { type anyOrNever, type array, type BuiltinObjectKind, type conform, type Constructor, type Domain, type ErrorMessage, type show, type Thunk } from "@ark/util";
|
|
3
|
+
import type { associateAttributes, Default, DefaultFor, distill, inferIntersection, inferMorphOut, inferPredicate, InferredOptional, Optional, Out } from "../attributes.ts";
|
|
4
4
|
import type { type } from "../keywords/keywords.ts";
|
|
5
5
|
import type { PostfixExpression } from "./ast/infer.ts";
|
|
6
6
|
import type { inferDefinition, validateDefinition } from "./definition.ts";
|
|
@@ -111,7 +111,7 @@ type optionalPostVariadicMessage = typeof optionalPostVariadicMessage;
|
|
|
111
111
|
export declare const spreadOptionalMessage = "A spread element cannot be optional";
|
|
112
112
|
type spreadOptionalMessage = typeof optionalPostVariadicMessage;
|
|
113
113
|
export type inferTuple<def extends array, $, args> = def extends TupleExpression ? inferTupleExpression<def, $, args> : inferTupleLiteral<def, $, args>;
|
|
114
|
-
export type inferTupleExpression<def extends TupleExpression, $, args> = def[1] extends "[]" ? inferDefinition<def[0], $, args>[] : def[1] extends "&" ? inferIntersection<inferDefinition<def[0], $, args>, inferDefinition<def[2], $, args>> : def[1] extends "|" ? inferDefinition<def[0], $, args> | inferDefinition<def[2], $, args> : def[1] extends ":" ? inferPredicate<inferDefinition<def[0], $, args>, def[2]> : def[1] extends "=>" ? parseMorph<def[0], def[2], $, args> : def[1] extends "@" ? inferDefinition<def[0], $, args> : def[1] extends "=" ?
|
|
114
|
+
export type inferTupleExpression<def extends TupleExpression, $, args> = def[1] extends "[]" ? inferDefinition<def[0], $, args>[] : def[1] extends "&" ? inferIntersection<inferDefinition<def[0], $, args>, inferDefinition<def[2], $, args>> : def[1] extends "|" ? inferDefinition<def[0], $, args> | inferDefinition<def[2], $, args> : def[1] extends ":" ? inferPredicate<inferDefinition<def[0], $, args>, def[2]> : def[1] extends "=>" ? parseMorph<def[0], def[2], $, args> : def[1] extends "@" ? inferDefinition<def[0], $, args> : def[1] extends "=" ? associateAttributes<inferDefinition<def[0], $, args>, Default<def[2] extends Thunk<infer returnValue> ? returnValue : def[2]>> : def[1] extends "?" ? associateAttributes<inferDefinition<def[0], $, args>, Optional> : def extends readonly ["===", ...infer values] ? values[number] : def extends (readonly ["instanceof", ...infer constructors extends Constructor[]]) ? InstanceType<constructors[number]> : def[0] extends "keyof" ? inferKeyOfExpression<def[1], $, args> : never;
|
|
115
115
|
export type validatePrefixExpression<def extends IndexZeroExpression, $, args> = def["length"] extends 1 ? readonly [writeMissingRightOperandMessage<def[0]>] : def[0] extends "keyof" ? readonly [def[0], validateDefinition<def[1], $, args>] : def[0] extends "===" ? readonly [def[0], ...unknown[]] : def[0] extends "instanceof" ? readonly [def[0], ...Constructor[]] : never;
|
|
116
116
|
export type validatePostfixExpression<def extends PostfixExpression, $, args> = conform<def, readonly [validateDefinition<def[0], $, args>, "[]" | "?"]>;
|
|
117
117
|
export type validateInfixExpression<def extends InfixExpression, $, args> = def["length"] extends 2 ? readonly [def[0], writeMissingRightOperandMessage<def[1]>] : readonly [
|
|
@@ -136,7 +136,7 @@ export type TupleInfixOperator = "&" | "|" | "=>" | ":" | "@" | "=";
|
|
|
136
136
|
export type IndexOneExpression<token extends IndexOneOperator = IndexOneOperator> = readonly [unknown, token, ...unknown[]];
|
|
137
137
|
export declare const parseMorphTuple: IndexOneParser<"=>">;
|
|
138
138
|
export declare const writeMalformedFunctionalExpressionMessage: (operator: ":" | "=>", value: unknown) => string;
|
|
139
|
-
export type parseMorph<inDef, morph, $, args> = morph extends Morph ? inferMorphOut<morph> extends infer out ? (In: distill.
|
|
139
|
+
export type parseMorph<inDef, morph, $, args> = morph extends Morph ? inferMorphOut<morph> extends infer out ? (In: distill.withAttributes.In<inferDefinition<inDef, $, args>>) => Out<out> : never : never;
|
|
140
140
|
export declare const parseNarrowTuple: IndexOneParser<":">;
|
|
141
141
|
export type IndexZeroOperator = "keyof" | "instanceof" | "===";
|
|
142
142
|
export type IndexZeroExpression<token extends IndexZeroOperator = IndexZeroOperator> = readonly [token, ...unknown[]];
|
package/out/scope.d.ts
CHANGED
|
@@ -7,7 +7,12 @@ import type { BoundModule, Module, Submodule, instantiateExport } from "./module
|
|
|
7
7
|
import type { DefAst, InferredAst } from "./parser/ast/infer.ts";
|
|
8
8
|
import { type inferDefinition, type validateDefinition } from "./parser/definition.ts";
|
|
9
9
|
import { InternalTypeParser, type DeclarationParser, type DefinitionParser, type EnumeratedTypeParser, type SchemaParser, type TypeParser, type UnitTypeParser } from "./type.ts";
|
|
10
|
-
|
|
10
|
+
/** The convenience properties attached to `scope` */
|
|
11
|
+
export type ScopeParserAttachments = Omit<ScopeParser, never>;
|
|
12
|
+
export interface ScopeParser {
|
|
13
|
+
<const def>(def: scope.validate<def>, config?: ArkScopeConfig): Scope<scope.infer<def>>;
|
|
14
|
+
define: <const def>(def: scope.validate<def>) => def;
|
|
15
|
+
}
|
|
11
16
|
export type ModuleParser = <const def>(def: scope.validate<def>, config?: ArkScopeConfig) => scope.infer<def> extends infer $ ? Module<{
|
|
12
17
|
[k in exportedNameOf<$>]: $[k];
|
|
13
18
|
}> : never;
|
package/out/scope.js
CHANGED
|
@@ -100,6 +100,8 @@ export class InternalScope extends BaseScope {
|
|
|
100
100
|
static scope = ((def, config = {}) => new InternalScope(def, config));
|
|
101
101
|
static module = ((def, config = {}) => this.scope(def, config).export());
|
|
102
102
|
}
|
|
103
|
-
export const scope = InternalScope.scope
|
|
103
|
+
export const scope = Object.assign(InternalScope.scope, {
|
|
104
|
+
define: def => def
|
|
105
|
+
});
|
|
104
106
|
export const module = InternalScope.module;
|
|
105
107
|
export const Scope = InternalScope;
|
package/out/type.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ArkErrors, BaseRoot, type BaseParseOptions, type MetaSchema, type Morph, type Predicate, type RootSchema } from "@ark/schema";
|
|
2
2
|
import { Callable, Hkt, type Constructor, type array, type conform } from "@ark/util";
|
|
3
|
+
import type { DefaultFor, distill } from "./attributes.ts";
|
|
3
4
|
import type { Generic, GenericParser, ParameterString, baseGenericConstraints, parseValidGenericParams, validateParameterString } from "./generic.ts";
|
|
4
|
-
import type { DefaultFor, distill } from "./keywords/inference.ts";
|
|
5
5
|
import type { Ark, keywords, type } from "./keywords/keywords.ts";
|
|
6
6
|
import type { BaseType } from "./methods/base.ts";
|
|
7
7
|
import type { instantiateType } from "./methods/instantiate.ts";
|
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.16",
|
|
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.18.0",
|
|
38
|
+
"@ark/schema": "0.18.0"
|
|
39
39
|
},
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { AtLeastLength, AtMostLength, Default, ExactlyLength, LessThanLength, MoreThanLength, Narrowed, Optional, Predicate, brand } from "../inference.ts";
|
|
2
|
-
import type { Matching } from "./string.ts";
|
|
3
|
-
declare namespace string {
|
|
4
|
-
type atLeastLength<rule> = brand<string, AtLeastLength<rule>>;
|
|
5
|
-
type moreThanLength<rule> = brand<string, MoreThanLength<rule>>;
|
|
6
|
-
type atMostLength<rule> = brand<string, AtMostLength<rule>>;
|
|
7
|
-
type lessThanLength<rule> = brand<string, LessThanLength<rule>>;
|
|
8
|
-
type exactlyLength<rule> = brand<string, ExactlyLength<rule>>;
|
|
9
|
-
type matching<rule> = brand<string, Matching<rule>>;
|
|
10
|
-
type narrowed = brand<string, Narrowed>;
|
|
11
|
-
type optional = brand<string, Optional>;
|
|
12
|
-
type defaultsTo<rule> = brand<string, Default<rule>>;
|
|
13
|
-
type branded<rule> = brand<string, Predicate<rule>>;
|
|
14
|
-
type is<attributes> = brand<string, attributes>;
|
|
15
|
-
type applyBrand<attribute> = attribute extends ExactlyLength<infer rule> ? exactlyLength<rule> : attribute extends MoreThanLength<infer rule> ? moreThanLength<rule> : attribute extends AtLeastLength<infer rule> ? atLeastLength<rule> : attribute extends AtMostLength<infer rule> ? atMostLength<rule> : attribute extends LessThanLength<infer rule> ? lessThanLength<rule> : attribute extends Matching<infer rule> ? matching<rule> : attribute extends Optional ? optional : attribute extends Default<infer rule> ? defaultsTo<rule> : attribute extends Predicate<infer rule> ? branded<rule> : never;
|
|
16
|
-
}
|
|
17
|
-
export type { string as brandedString };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|