arktype 2.2.10 → 3.0.0-beta.1
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/README.md +181 -15
- package/out/attributes.d.ts +50 -14
- package/out/checkers.d.ts +172 -0
- package/out/chunk-2U2AWCI3.js +626 -0
- package/out/chunk-4CUA5XIP.js +7 -0
- package/out/chunk-5U2ZMDNI.js +1566 -0
- package/out/chunk-DLWCO4RV.js +18 -0
- package/out/chunk-E3DZXEZK.js +72 -0
- package/out/chunk-EVCML554.js +47 -0
- package/out/chunk-G45P2CLE.js +63 -0
- package/out/chunk-GPNK5353.js +2529 -0
- package/out/chunk-MLKGABMK.js +9 -0
- package/out/chunk-NRIGTMPM.js +7 -0
- package/out/chunk-PRTMQCHS.js +3 -0
- package/out/chunk-R5G57XC7.js +7 -0
- package/out/chunk-RAZ3TXOE.js +313 -0
- package/out/chunk-SWOOCAHN.js +4 -0
- package/out/chunk-TAHPKDNM.js +3 -0
- package/out/chunk-UETB6YE2.js +14 -0
- package/out/chunk-UK5UGFOX.js +254 -0
- package/out/chunk-VV6YDN2D.js +6118 -0
- package/out/codecs.d.ts +21 -0
- package/out/codecs.js +7 -0
- package/out/config.d.ts +8 -3
- package/out/config.js +2 -3
- package/out/declare.d.ts +17 -3
- package/out/deferred.d.ts +10 -0
- package/out/errors.d.ts +1 -0
- package/out/errors.js +2 -0
- package/out/fn.d.ts +1 -1
- package/out/generic.d.ts +3 -3
- package/out/i18n.d.ts +2 -0
- package/out/i18n.js +2 -0
- package/out/index.d.ts +5 -4
- package/out/index.js +8 -9
- package/out/internal.d.ts +70 -0
- package/out/internal.js +17 -0
- package/out/island.d.ts +2 -0
- package/out/island.js +6 -0
- package/out/islandDependency.d.ts +2 -0
- package/out/islandDependency.js +18 -0
- package/out/keywords/Array.d.ts +2 -2
- package/out/keywords/builtins.d.ts +5 -3
- package/out/keywords/constructors.d.ts +9 -1
- package/out/keywords/functions.d.ts +254 -0
- package/out/keywords/keywords.d.ts +8 -9
- package/out/keywords/number.d.ts +2 -8
- package/out/keywords/phrases.d.ts +245 -0
- package/out/keywords/string.d.ts +14 -113
- package/out/keywords/ts.d.ts +35 -33
- package/out/keywords/ts.js +4 -82
- package/out/locale.d.ts +19 -0
- package/out/locales/de.d.ts +2 -0
- package/out/locales/de.js +2 -0
- package/out/locales/en.d.ts +4 -0
- package/out/locales/en.js +5 -0
- package/out/match.d.ts +6 -6
- package/out/module.d.ts +1 -1
- package/out/mutatesInput.js +3 -0
- package/out/parser/ast/generic.d.ts +6 -3
- package/out/parser/ast/infer.d.ts +1 -1
- package/out/parser/ast/validate.d.ts +11 -6
- package/out/parser/definition.d.ts +68 -7
- package/out/parser/objectLiteral.d.ts +40 -12
- package/out/parser/property.d.ts +3 -5
- package/out/parser/reduce/dynamic.d.ts +16 -7
- package/out/parser/reduce/shared.d.ts +4 -0
- package/out/parser/reduce/static.d.ts +13 -13
- package/out/parser/shift/operand/date.d.ts +0 -5
- package/out/parser/shift/operand/operand.d.ts +2 -1
- package/out/parser/shift/operand/unenclosed.d.ts +9 -6
- package/out/parser/shift/operand/unresolvable.d.ts +68 -0
- package/out/parser/shift/operator/bounds.d.ts +9 -4
- package/out/parser/shift/operator/brand.d.ts +2 -2
- package/out/parser/shift/operator/default.d.ts +2 -2
- package/out/parser/shift/operator/divisor.d.ts +2 -2
- package/out/parser/shift/operator/operator.d.ts +1 -1
- package/out/parser/shift/tokens.d.ts +9 -2
- package/out/parser/string.d.ts +61 -7
- package/out/parser/tupleExpressions.d.ts +7 -3
- package/out/precompiled.d.ts +1 -0
- package/out/precompiled.js +2 -0
- package/out/runtime.d.ts +181 -0
- package/out/runtime.js +4 -0
- package/out/runtimeDevelopment.d.ts +1 -0
- package/out/runtimeDevelopment.js +133 -0
- package/out/runtimeExports.d.ts +1 -0
- package/out/scope.d.ts +40 -11
- package/out/standalone/artifact.d.ts +265 -0
- package/out/standalone/baking.d.ts +201 -0
- package/out/standalone/combinators.d.ts +13 -0
- package/out/standalone/compilers.d.ts +23 -0
- package/out/standalone/creators.d.ts +41 -0
- package/out/standalone/fallbacks.d.ts +48 -0
- package/out/standalone/keys.d.ts +31 -0
- package/out/standalone/modules.d.ts +26 -0
- package/out/standalone/sites.d.ts +52 -0
- package/out/standalone/units.d.ts +31 -0
- package/out/standalone/values.d.ts +60 -0
- package/out/standalone.d.ts +16 -0
- package/out/type.d.ts +45 -6
- package/out/variants/array.d.ts +1 -1
- package/out/variants/base.d.ts +47 -27
- package/out/variants/date.d.ts +1 -1
- package/out/variants/instantiate.d.ts +4 -2
- package/out/variants/number.d.ts +1 -1
- package/out/variants/object.d.ts +17 -12
- package/out/variants/string.d.ts +1 -1
- package/package.json +169 -8
- package/skills/arktype/SKILL.md +278 -43
- package/skills/arktype/references/migrating.md +1296 -0
- package/skills/arktype/references/precompile.md +191 -0
- package/out/attributes.js +0 -3
- package/out/fn.js +0 -58
- package/out/generic.js +0 -37
- package/out/keywords/Array.js +0 -21
- package/out/keywords/FormData.js +0 -40
- package/out/keywords/TypedArray.js +0 -16
- package/out/keywords/builtins.js +0 -11
- package/out/keywords/constructors.js +0 -16
- package/out/keywords/keywords.js +0 -48
- package/out/keywords/number.js +0 -49
- package/out/keywords/string.js +0 -467
- package/out/match.js +0 -95
- package/out/module.js +0 -3
- package/out/nary.js +0 -1
- package/out/parser/ast/bounds.js +0 -1
- package/out/parser/ast/default.js +0 -1
- package/out/parser/ast/divisor.js +0 -1
- package/out/parser/ast/generic.js +0 -1
- package/out/parser/ast/infer.js +0 -1
- package/out/parser/ast/keyof.js +0 -1
- package/out/parser/ast/utils.js +0 -1
- package/out/parser/ast/validate.js +0 -3
- package/out/parser/definition.js +0 -78
- package/out/parser/objectLiteral.js +0 -113
- package/out/parser/property.js +0 -16
- package/out/parser/reduce/dynamic.js +0 -153
- package/out/parser/reduce/shared.js +0 -25
- package/out/parser/reduce/static.js +0 -1
- package/out/parser/shift/operand/date.js +0 -23
- package/out/parser/shift/operand/enclosed.js +0 -82
- package/out/parser/shift/operand/genericArgs.js +0 -16
- package/out/parser/shift/operand/operand.js +0 -16
- package/out/parser/shift/operand/unenclosed.js +0 -59
- package/out/parser/shift/operator/bounds.js +0 -91
- package/out/parser/shift/operator/brand.js +0 -6
- package/out/parser/shift/operator/default.js +0 -29
- package/out/parser/shift/operator/divisor.js +0 -13
- package/out/parser/shift/operator/operator.js +0 -28
- package/out/parser/shift/tokens.js +0 -37
- package/out/parser/string.js +0 -42
- package/out/parser/tupleExpressions.js +0 -75
- package/out/parser/tupleLiteral.js +0 -128
- package/out/scope.js +0 -106
- package/out/type.js +0 -55
- package/out/variants/array.js +0 -1
- package/out/variants/base.js +0 -1
- package/out/variants/date.js +0 -1
- package/out/variants/instantiate.js +0 -1
- package/out/variants/number.js +0 -1
- package/out/variants/object.js +0 -1
- package/out/variants/string.js +0 -1
- /package/out/{declare.js → mutatesInput.d.ts} +0 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ToJsonSchema, type BaseRoot, type UnionJsonSchemaWriters } from "@ark/schema";
|
|
2
|
+
type Ref = {
|
|
3
|
+
hole: number;
|
|
4
|
+
} | {
|
|
5
|
+
object: number;
|
|
6
|
+
} | {
|
|
7
|
+
value: unknown;
|
|
8
|
+
};
|
|
9
|
+
type Entry = {
|
|
10
|
+
key: string;
|
|
11
|
+
ref: Ref;
|
|
12
|
+
} | {
|
|
13
|
+
spread: number;
|
|
14
|
+
};
|
|
15
|
+
type States = Entry[][];
|
|
16
|
+
type Changes = [id: number, entries: Entry[]][];
|
|
17
|
+
type Step = {
|
|
18
|
+
call: number;
|
|
19
|
+
code: string;
|
|
20
|
+
ctx: number;
|
|
21
|
+
changes: Changes;
|
|
22
|
+
} | {
|
|
23
|
+
write: keyof UnionJsonSchemaWriters;
|
|
24
|
+
hole: number;
|
|
25
|
+
args: Ref[];
|
|
26
|
+
changes: Changes;
|
|
27
|
+
} | {
|
|
28
|
+
set: number;
|
|
29
|
+
key: string;
|
|
30
|
+
ref: Ref;
|
|
31
|
+
changes: Changes;
|
|
32
|
+
} | {
|
|
33
|
+
delete: number;
|
|
34
|
+
key: string;
|
|
35
|
+
changes: Changes;
|
|
36
|
+
};
|
|
37
|
+
export interface FallbackTrace {
|
|
38
|
+
steps: Step[];
|
|
39
|
+
result: Ref;
|
|
40
|
+
changes: Changes;
|
|
41
|
+
states: States;
|
|
42
|
+
arrays: boolean[];
|
|
43
|
+
}
|
|
44
|
+
export declare const traceFallbacks: (root: BaseRoot, write: (fallback: ToJsonSchema.UniversalFallback, writers: UnionJsonSchemaWriters) => unknown, printsResults?: true) => FallbackTrace | undefined;
|
|
45
|
+
export type WriteHandler = (code: string, call?: number) => string | undefined;
|
|
46
|
+
export declare const writeReplay: (trace: FallbackTrace, writeValue: (value: unknown) => string, handlerOf: WriteHandler, read: (text: string, isLocal?: boolean) => string) => string | undefined;
|
|
47
|
+
export declare const fallbackCodes: ToJsonSchema.Code[];
|
|
48
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type BaseNode, type BaseRoot, type BaseScope } from "@ark/schema";
|
|
2
|
+
import { InternalTypedFn } from "../fn.ts";
|
|
3
|
+
import type { Foldable } from "./baking.ts";
|
|
4
|
+
import { type CollectedDefault } from "./units.ts";
|
|
5
|
+
export type ScopeAlias = [scope: BaseScope, alias: string];
|
|
6
|
+
export type Key = [
|
|
7
|
+
id: string,
|
|
8
|
+
holes: unknown[],
|
|
9
|
+
refusal: [path: string, reason: string] | undefined,
|
|
10
|
+
thunks: readonly [...ScopeAlias, path: string][]
|
|
11
|
+
];
|
|
12
|
+
export declare const keyOf: (value: Foldable) => Key;
|
|
13
|
+
export declare const bindingsOf: (node: BaseNode) => BaseNode[];
|
|
14
|
+
export declare const originalOf: (node: BaseNode) => BaseNode;
|
|
15
|
+
export declare const contentKeyOf: (node: BaseNode) => string;
|
|
16
|
+
export declare const contentNodesOf: (root: BaseNode) => Set<BaseNode>;
|
|
17
|
+
export declare const writeId: (id: string) => string;
|
|
18
|
+
export declare const traversalKeyOf: (root: BaseRoot) => Key;
|
|
19
|
+
type KeyMode = "definition" | "value" | "config";
|
|
20
|
+
export declare const encodeKey: (start: unknown, defaultsByMorph?: ReadonlyMap<unknown, CollectedDefault>, mode?: KeyMode) => Key;
|
|
21
|
+
export declare const appendPath: (path: string, rest: string) => string;
|
|
22
|
+
export declare const isTypedFn: (value: unknown) => value is InternalTypedFn;
|
|
23
|
+
export declare const kindNameOf: (value: unknown) => string;
|
|
24
|
+
export declare const printablePrimitive: (value: unknown) => string;
|
|
25
|
+
export type ComposedString = "expression" | "description";
|
|
26
|
+
export declare const partsOf: (root: BaseRoot, kind: ComposedString) => (string | BaseRoot)[];
|
|
27
|
+
export declare const receiverPrefix = "receive";
|
|
28
|
+
export declare const registeredNameAt: (hash: string, i: number) => string | undefined;
|
|
29
|
+
export declare const holeNamePattern: RegExp;
|
|
30
|
+
export declare const printedHoleNamePattern: RegExp;
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { StandaloneOptions } from "./baking.ts";
|
|
2
|
+
export declare const runtimeImport = "import * as runtime from \"arktype/runtime\"";
|
|
3
|
+
export interface SharedModule {
|
|
4
|
+
readsRuntime: boolean;
|
|
5
|
+
imports: Record<string, string[]>;
|
|
6
|
+
declarations: string[];
|
|
7
|
+
exports: string[];
|
|
8
|
+
scope?: UnitScope | undefined;
|
|
9
|
+
}
|
|
10
|
+
export interface UnitScope {
|
|
11
|
+
name: string;
|
|
12
|
+
dependencies: Record<string, string[]>;
|
|
13
|
+
params: string[];
|
|
14
|
+
args: string[];
|
|
15
|
+
statements: string[];
|
|
16
|
+
returned: string[];
|
|
17
|
+
nodes: Record<string, string>;
|
|
18
|
+
declaresOnlyRefs: boolean;
|
|
19
|
+
}
|
|
20
|
+
export declare const mergeUnits: (shared: Record<string, SharedModule>, imports: Record<string, string[]>, opts: StandaloneOptions) => void;
|
|
21
|
+
export declare const writeModule: ({ readsRuntime, imports, declarations, exports }: SharedModule) => string;
|
|
22
|
+
export declare const writeDependencies: (namesBySource: Record<string, string[]>, shortest: boolean) => [params: string[], args: string[]];
|
|
23
|
+
export declare const noInlineOf: (shortest: boolean) => string;
|
|
24
|
+
export declare const writeScope: (params: string[], statements: string[], returned: string[]) => string;
|
|
25
|
+
export declare const writeSections: (sections: string[]) => string;
|
|
26
|
+
export declare const writeImports: (imports: Record<string, string[]>) => string;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type ArkErrorCode, type BaseNode, type BaseRoot, type RootUnit } from "@ark/schema";
|
|
2
|
+
import { type FailureSite, type SiteContext, type UnionSite } from "@ark/schema/internal";
|
|
3
|
+
import { type Fn } from "@ark/util";
|
|
4
|
+
import type { IssueFeatures } from "./baking.ts";
|
|
5
|
+
declare const describingKeys: readonly ["expected", "actual", "message"];
|
|
6
|
+
export declare const assertDescribed: (root: BaseRoot) => void;
|
|
7
|
+
export declare const addIssueFeatures: (features: IssueFeatures, units: readonly RootUnit[], written: readonly BaseNode[]) => void;
|
|
8
|
+
export declare const failureSites: WeakSet<object>;
|
|
9
|
+
export declare const issueSite: <site extends object>(site: site) => site;
|
|
10
|
+
export declare const isInlineSite: (site: object) => site is IssueContext;
|
|
11
|
+
export declare const isLiteralSite: (value: unknown, emitted: string) => boolean;
|
|
12
|
+
export declare const withoutStrings: (code: string) => string;
|
|
13
|
+
export declare const writeSiteOf: ({ code, description, message, c }: IssueContext, emit: (s: string) => string, writer?: string, missing?: string) => string;
|
|
14
|
+
export declare const missingDescriptionOf: (site: object) => string | undefined;
|
|
15
|
+
export interface TextContext {
|
|
16
|
+
code: ArkErrorCode;
|
|
17
|
+
description?: string | undefined;
|
|
18
|
+
/** a required key's: its value's brief, which the missing key expects */
|
|
19
|
+
missingValueDescription?: string | undefined;
|
|
20
|
+
/** a required key's: its value's meta, whose message the missing key says */
|
|
21
|
+
valueMeta?: ArkEnv.meta | undefined;
|
|
22
|
+
meta?: ArkEnv.meta | undefined;
|
|
23
|
+
}
|
|
24
|
+
type DescribingKey = (typeof describingKeys)[number];
|
|
25
|
+
export declare class ConfiguredWriter {
|
|
26
|
+
code: ArkErrorCode;
|
|
27
|
+
k: DescribingKey;
|
|
28
|
+
constructor(code: ArkErrorCode, k: DescribingKey);
|
|
29
|
+
}
|
|
30
|
+
export type Writer = string | Fn | ConfiguredWriter | undefined;
|
|
31
|
+
type Custom = 1 | 2;
|
|
32
|
+
export interface IssueContext extends SiteContext {
|
|
33
|
+
message?: string;
|
|
34
|
+
c?: Custom | undefined;
|
|
35
|
+
written?: {
|
|
36
|
+
context: object;
|
|
37
|
+
writers: Writer[];
|
|
38
|
+
keeps: number;
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
export declare const issueContextOf: (context: TextContext) => IssueContext;
|
|
42
|
+
export declare const raisingKeys: {
|
|
43
|
+
Traversal: {};
|
|
44
|
+
FirstIssueTraversal: {};
|
|
45
|
+
};
|
|
46
|
+
export declare const raisedWritersByCode: () => [code: ArkErrorCode, writers: Writer[], keeps: number][];
|
|
47
|
+
export declare const isDescribed: (context: IssueContext) => boolean;
|
|
48
|
+
export declare const issueSiteOf: (site: FailureSite | UnionSite) => object;
|
|
49
|
+
export declare const unionKeySiteOf: (union: UnionSite, missing: TextContext) => object;
|
|
50
|
+
export declare const isKeyword: (predicate: unknown) => boolean;
|
|
51
|
+
export declare const raisesNothing: (predicate: Fn) => boolean;
|
|
52
|
+
export {};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type BaseNode, type BaseRoot, type IntersectionNode, type Optional, type RootUnit, type Sequence, type UnitMember } from "@ark/schema";
|
|
2
|
+
import { type Baking, type IssueFeatures } from "./baking.ts";
|
|
3
|
+
import { type HoleCells } from "./values.ts";
|
|
4
|
+
export interface Written {
|
|
5
|
+
issues: IssueFeatures;
|
|
6
|
+
metas: Set<object>;
|
|
7
|
+
keyLookups: Set<object>;
|
|
8
|
+
patternInstances: Set<RegExp>;
|
|
9
|
+
defaultsByMorph: Map<unknown, CollectedDefault>;
|
|
10
|
+
objectUnits: Set<unknown>;
|
|
11
|
+
}
|
|
12
|
+
export declare const writtenByUnits: WeakMap<readonly RootUnit[], Written>;
|
|
13
|
+
export declare const readWritten: (units: readonly RootUnit[], nodes: readonly BaseNode[]) => Written;
|
|
14
|
+
export type CollectedDefault = [
|
|
15
|
+
key: PropertyKey,
|
|
16
|
+
value: BaseRoot,
|
|
17
|
+
defaultValue: unknown
|
|
18
|
+
];
|
|
19
|
+
export declare const defaultedNodeKeys: ["alters", "hasAlias", "allowsCtx", "ctxMorph", "tfs"];
|
|
20
|
+
export declare const collectDefaults: (node: Optional.Node | Sequence.Node, defaultsByMorph: Map<unknown, CollectedDefault>) => void;
|
|
21
|
+
export declare const calledMembersOf: (members: readonly UnitMember[], readers: readonly string[]) => UnitMember[];
|
|
22
|
+
export declare const forwardedOf: (members: readonly UnitMember[]) => Map<string, string>;
|
|
23
|
+
export declare const returnedOf: (unit: RootUnit, baking: Baking) => string[];
|
|
24
|
+
export declare const namesReadBy: (unit: RootUnit, returned: string[]) => Set<string>;
|
|
25
|
+
export declare const isWriting: (member: string) => boolean;
|
|
26
|
+
export declare const isVariadicArray: (root: BaseRoot) => root is IntersectionNode;
|
|
27
|
+
export declare const isSharedUnit: (unit: RootUnit, cells?: HoleCells) => boolean;
|
|
28
|
+
export declare const writtenSelectedOf: (units: readonly RootUnit[], selects: (node: BaseNode) => boolean) => readonly BaseNode[];
|
|
29
|
+
export declare const holdsObjectMeta: (node: BaseNode) => boolean;
|
|
30
|
+
export declare const holdsDefaults: (node: BaseNode) => boolean;
|
|
31
|
+
export declare const declares: (root: BaseRoot, predicate: (node: BaseNode) => boolean) => boolean;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { type BaseRoot } from "@ark/schema";
|
|
2
|
+
import type { IntrospectionMember } from "../runtime.ts";
|
|
3
|
+
export declare const defaultBakedLimit: number;
|
|
4
|
+
export interface DataPartModule {
|
|
5
|
+
name: string;
|
|
6
|
+
value: string;
|
|
7
|
+
imports: Record<string, string[]>;
|
|
8
|
+
held: DataPart[];
|
|
9
|
+
}
|
|
10
|
+
export interface DataPart {
|
|
11
|
+
text: string;
|
|
12
|
+
refs: number;
|
|
13
|
+
local: boolean;
|
|
14
|
+
size?: number;
|
|
15
|
+
module?: DataPartModule;
|
|
16
|
+
isDeclared?: boolean;
|
|
17
|
+
}
|
|
18
|
+
export declare class DataParts {
|
|
19
|
+
private parts;
|
|
20
|
+
private ids;
|
|
21
|
+
private written;
|
|
22
|
+
writtenAs(value: object): string | undefined;
|
|
23
|
+
at(reference: string): DataPart;
|
|
24
|
+
add(text: string, value?: object, local?: boolean): string;
|
|
25
|
+
private repeats;
|
|
26
|
+
private sizeOf;
|
|
27
|
+
write(text: string, read: (part: DataPart) => string | undefined): string;
|
|
28
|
+
}
|
|
29
|
+
export type BakedLengths = Partial<Record<IntrospectionMember, number>>;
|
|
30
|
+
export declare const totalBaked: (lengths: BakedLengths) => number;
|
|
31
|
+
export declare const writeBakedLimitMessage: (lengths: BakedLengths, limit: number) => string;
|
|
32
|
+
export declare const runtimePathsByValue: Map<unknown, string>;
|
|
33
|
+
export declare const runtimeKeyOf: (value: object | symbol | string) => string | undefined;
|
|
34
|
+
export declare const assertBakeableJsonSchema: (root: BaseRoot) => void;
|
|
35
|
+
export declare const isPlainLiteral: (value: object) => boolean;
|
|
36
|
+
export declare const isHole: (value: unknown) => boolean;
|
|
37
|
+
export declare const keywordMetas: () => Set<object>;
|
|
38
|
+
export declare const holeNameIn: (json: unknown, seen?: Set<object>) => string | undefined;
|
|
39
|
+
export interface HoleCell {
|
|
40
|
+
name: string;
|
|
41
|
+
text?: string | undefined;
|
|
42
|
+
imports?: Record<string, string[]> | undefined;
|
|
43
|
+
rejects?: string | undefined;
|
|
44
|
+
}
|
|
45
|
+
export interface HoleCells {
|
|
46
|
+
comparedIds: ReadonlySet<string>;
|
|
47
|
+
byHole: Map<unknown, HoleCell>;
|
|
48
|
+
byPlaceholder: Map<string, HoleCell>;
|
|
49
|
+
defaults: ReadonlyMap<unknown, string>;
|
|
50
|
+
keyOf: (value: object | symbol | string) => string | undefined;
|
|
51
|
+
isDefaultShared: (morph: unknown) => boolean;
|
|
52
|
+
}
|
|
53
|
+
export declare const cellPrefix = "~arktype/cell/";
|
|
54
|
+
export declare const heldSpecifier = "~arktype/held";
|
|
55
|
+
export declare const cellSpecifierOf: (cell: HoleCell) => string;
|
|
56
|
+
export declare const cellSetterOf: (cell: HoleCell) => string;
|
|
57
|
+
export declare const isReadByName: (ref: unknown, cells: HoleCells | undefined) => boolean;
|
|
58
|
+
export declare const holdsLocal: (value: unknown, cells?: HoleCells, seen?: Set<unknown>) => boolean;
|
|
59
|
+
export declare const writeUnprecompilableMessage: <value extends string>(value: value) => writeUnprecompilableMessage<value>;
|
|
60
|
+
export type writeUnprecompilableMessage<value extends string> = `${value} can't be precompiled to a standalone validator`;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import "./mutatesInput.ts";
|
|
2
|
+
import { type StandaloneExport, type StandaloneModules, type StandaloneOptions } from "./standalone/baking.ts";
|
|
3
|
+
export * from "./standalone/artifact.ts";
|
|
4
|
+
export * from "./standalone/baking.ts";
|
|
5
|
+
export * from "./standalone/combinators.ts";
|
|
6
|
+
export * from "./standalone/creators.ts";
|
|
7
|
+
export * from "./standalone/fallbacks.ts";
|
|
8
|
+
export * from "./standalone/keys.ts";
|
|
9
|
+
export * from "./standalone/compilers.ts";
|
|
10
|
+
export * from "./standalone/modules.ts";
|
|
11
|
+
export * from "./standalone/sites.ts";
|
|
12
|
+
export * from "./standalone/units.ts";
|
|
13
|
+
export * from "./standalone/values.ts";
|
|
14
|
+
/** an ES module of getters and factories for each export */
|
|
15
|
+
export declare const precompileStandalone: (exports: Record<string, StandaloneExport>, opts?: StandaloneOptions) => StandaloneModules;
|
|
16
|
+
export declare const precompileStandaloneModules: (exports: Record<string, StandaloneExport>, opts?: StandaloneOptions) => StandaloneModules;
|
package/out/type.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ArkErrors, BaseRoot, type BaseParseOptions, type Morph, type NodeSelector, type
|
|
1
|
+
import { ArkErrors, BaseRoot, type BaseParseOptions, type Morph, type NodeSelector, type RootSchema, type TypeMeta } from "@ark/schema";
|
|
2
2
|
import { Callable, Hkt, type Constructor, type array, type conform } from "@ark/util";
|
|
3
3
|
import type { distill } from "./attributes.ts";
|
|
4
4
|
import type { DeclarationParser } from "./declare.ts";
|
|
@@ -7,10 +7,49 @@ import type { Generic, GenericParser, ParameterString, baseGenericConstraints, p
|
|
|
7
7
|
import type { Ark, keywords, type } from "./keywords/keywords.ts";
|
|
8
8
|
import type { MatchParser } from "./match.ts";
|
|
9
9
|
import type { NaryIntersectionParser, NaryMergeParser, NaryPipeParser, NaryUnionParser } from "./nary.ts";
|
|
10
|
-
import type {
|
|
11
|
-
import type {
|
|
10
|
+
import type { validateDefinition } from "./parser/definition.ts";
|
|
11
|
+
import type { ArgTwoOperator, IndexZeroOperator, TupleInfixOperator, validatePredicate } from "./parser/tupleExpressions.ts";
|
|
12
|
+
import { type bindThis, type InternalScope, type ModuleParser, type Scope, type ScopeParser } from "./scope.ts";
|
|
12
13
|
import type { BaseType } from "./variants/base.ts";
|
|
13
14
|
import type { instantiateType } from "./variants/instantiate.ts";
|
|
15
|
+
/**
|
|
16
|
+
* What the arguments of `type`'s second signature are checked against, wherever
|
|
17
|
+
* that has to be computed from them.
|
|
18
|
+
*
|
|
19
|
+
* It's an interface with annotated variance for the reason
|
|
20
|
+
* `validateDefinitionArgument` goes through one: completing a string
|
|
21
|
+
* argument has TypeScript infer from each parameter's type to itself, and an
|
|
22
|
+
* alias met there with a type parameter among its arguments has its variance
|
|
23
|
+
* measured. `validateParameterString`, `parseValidGenericParams` and
|
|
24
|
+
* `type.infer` each reach the whole string parser that way, at 450-670ms a
|
|
25
|
+
* completion on TypeScript 6. Indexed by a key that's deferred until `zero` is
|
|
26
|
+
* known, nothing in here is visited.
|
|
27
|
+
*
|
|
28
|
+
* The rest parameter's tuples are properties too, rather than written around
|
|
29
|
+
* an indexed property in the signature. The first call of that form then costs
|
|
30
|
+
* fewer instantiations than it did without any of this (about 2,500 against
|
|
31
|
+
* 3,000 for `type("string", "|>", "unknown")`, and against 13,500 with a morph),
|
|
32
|
+
* where a tuple in the signature costs more (3,600). Each later call costs 20 to
|
|
33
|
+
* 95 more, the price of the interface. Their elements are indexed again because
|
|
34
|
+
* TypeScript also infers to a tuple's element type from the string being
|
|
35
|
+
* completed.
|
|
36
|
+
*/
|
|
37
|
+
export interface ValidatedArgs<in out zero, in out one, in out rest extends array, in out $> {
|
|
38
|
+
params: zero extends ParameterString ? validateParameterString<zero, $> : never;
|
|
39
|
+
body: zero extends ParameterString ? validateDefinition<one, $, baseGenericConstraints<parseValidGenericParams<zero, $>>> : never;
|
|
40
|
+
predicate: validatePredicate<type.infer<zero, $>, distill.In<type.infer<zero, $>>>;
|
|
41
|
+
morph: Morph<distill.Out<type.infer<zero, $>>, unknown>;
|
|
42
|
+
operand: validateDefinition<rest[0], $, bindThis<rest[0]>>;
|
|
43
|
+
predicateRest: [
|
|
44
|
+
ValidatedArgs<zero, one, rest, $>[zero extends unknown ? "predicate" : never]
|
|
45
|
+
];
|
|
46
|
+
morphRest: [
|
|
47
|
+
ValidatedArgs<zero, one, rest, $>[zero extends unknown ? "morph" : never]
|
|
48
|
+
];
|
|
49
|
+
operandRest: [
|
|
50
|
+
ValidatedArgs<zero, one, rest, $>[zero extends unknown ? "operand" : never]
|
|
51
|
+
];
|
|
52
|
+
}
|
|
14
53
|
/** The convenience properties attached to `type` */
|
|
15
54
|
export type TypeParserAttachments = Omit<TypeParser, never>;
|
|
16
55
|
export interface TypeParser<$ = {}> extends Ark.boundTypeAttachments<$> {
|
|
@@ -22,7 +61,7 @@ export interface TypeParser<$ = {}> extends Ark.boundTypeAttachments<$> {
|
|
|
22
61
|
<const def, r = type.instantiate<def, $>>(def: type.validate<def, $>): r extends infer _ ? _ : never;
|
|
23
62
|
/**
|
|
24
63
|
* Create a {@link Generic} from a parameter string and body definition, or a
|
|
25
|
-
* {@link Type} from a [tuple expression](
|
|
64
|
+
* {@link Type} from a [tuple expression](https://arktype.io/docs/expressions)
|
|
26
65
|
* spread as this function's arguments.
|
|
27
66
|
*
|
|
28
67
|
* @param params A string like "<t, n extends number>" specifying the
|
|
@@ -35,7 +74,7 @@ export interface TypeParser<$ = {}> extends Ark.boundTypeAttachments<$> {
|
|
|
35
74
|
* @example const BoxOf = type("<t extends string | number>", { contents: "t" })
|
|
36
75
|
* @example type("string", "|", { foo: "number" })
|
|
37
76
|
*/
|
|
38
|
-
<const zero, const one, const rest extends array, r = zero extends ParameterString ? Generic<parseValidGenericParams<zero, $>, one, $> : type.instantiate<[zero, one, ...rest], $>>(_0: zero extends ParameterString ?
|
|
77
|
+
<const zero, const one, const rest extends array, r = zero extends ParameterString ? Generic<parseValidGenericParams<zero, $>, one, $> : type.instantiate<[zero, one, ...rest], $>>(_0: zero extends ParameterString ? ValidatedArgs<zero, one, rest, $>[zero extends unknown ? "params" : never] : zero extends IndexZeroOperator ? zero : type.validate<zero, $>, _1: zero extends ParameterString ? ValidatedArgs<zero, one, rest, $>[zero extends unknown ? "body" : never] : zero extends "keyof" ? type.validate<one, $> : zero extends "instanceof" ? conform<one, Constructor> : zero extends "===" ? conform<one, unknown> : conform<one, ArgTwoOperator>, ..._2: zero extends ParameterString ? [] : zero extends "===" ? rest : zero extends "instanceof" ? conform<rest, readonly Constructor[]> : one extends TupleInfixOperator ? one extends ":" ? ValidatedArgs<zero, one, rest, $>[zero extends unknown ? "predicateRest" : never] : one extends "=>" ? ValidatedArgs<zero, one, rest, $>[zero extends unknown ? "morphRest" : never] : one extends "@" ? [TypeMeta.MappableInput, NodeSelector?] : ValidatedArgs<zero, one, rest, $>[zero extends unknown ? "operandRest" : never] : []): r extends infer _ ? _ : never;
|
|
39
78
|
/**
|
|
40
79
|
* An alias of the {@link ArkErrors} class, an instance of which is returned when a {@link Type}
|
|
41
80
|
* is invoked with invalid input.
|
|
@@ -121,7 +160,7 @@ export interface TypeParser<$ = {}> extends Ark.boundTypeAttachments<$> {
|
|
|
121
160
|
* const len = type.fn("string | unknown[]", ":", "number")(s => s.length)
|
|
122
161
|
* len("foo") // 3
|
|
123
162
|
* // TypeScript: boolean is not assignable to string | unknown[]
|
|
124
|
-
* // Runtime (throws): must be a string or an
|
|
163
|
+
* // Runtime (throws): [0] must be a string or an array
|
|
125
164
|
* len(true)
|
|
126
165
|
*/
|
|
127
166
|
fn: FnParser<$>;
|
package/out/variants/array.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { ExactLength, ExclusiveNumericRangeSchema, InclusiveNumericRangeSch
|
|
|
2
2
|
import type { ObjectType } from "./object.ts";
|
|
3
3
|
interface Type<
|
|
4
4
|
/** @ts-ignore cast variance */
|
|
5
|
-
out t extends readonly unknown[] = readonly unknown[], $ = {}> extends ObjectType<t, $> {
|
|
5
|
+
out t extends readonly unknown[] = readonly unknown[], in out $ = {}> extends ObjectType<t, $> {
|
|
6
6
|
atLeastLength(schema: InclusiveNumericRangeSchema): this;
|
|
7
7
|
atMostLength(schema: InclusiveNumericRangeSchema): this;
|
|
8
8
|
moreThanLength(schema: ExclusiveNumericRangeSchema): this;
|
package/out/variants/base.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ import type { Scope } from "../scope.ts";
|
|
|
8
8
|
import type { ArrayType } from "./array.ts";
|
|
9
9
|
import type { instantiateType } from "./instantiate.ts";
|
|
10
10
|
/** @ts-ignore cast variance */
|
|
11
|
-
export interface Inferred<out t = unknown, $ = {}> {
|
|
11
|
+
export interface Inferred<out t = unknown, in out $ = {}> {
|
|
12
12
|
internal: BaseRoot;
|
|
13
13
|
[inferred]: t;
|
|
14
14
|
/**
|
|
@@ -50,7 +50,7 @@ export interface Inferred<out t = unknown, $ = {}> {
|
|
|
50
50
|
*
|
|
51
51
|
* @example
|
|
52
52
|
* const parseNumber = type("string").pipe(s => Number.parseInt(s))
|
|
53
|
-
* type ParsedNumber = typeof parseNumber.
|
|
53
|
+
* type ParsedNumber = typeof parseNumber.inferOut // number
|
|
54
54
|
*/
|
|
55
55
|
inferOut: distill.Out<t>;
|
|
56
56
|
/**
|
|
@@ -162,8 +162,8 @@ export interface Inferred<out t = unknown, $ = {}> {
|
|
|
162
162
|
* @example
|
|
163
163
|
* const NotOdd = type("number % 2").configure({ description: "not odd" })
|
|
164
164
|
* // all constraints at the root are affected
|
|
165
|
-
* const odd = NotOdd(3) // must be not odd
|
|
166
|
-
* const nonNumber = NotOdd("two") // must be not odd
|
|
165
|
+
* const odd = NotOdd(3) // must be not odd
|
|
166
|
+
* const nonNumber = NotOdd("two") // must be not odd
|
|
167
167
|
*
|
|
168
168
|
* const NotOddBox = type({
|
|
169
169
|
* // we should have referenced notOdd or added meta here
|
|
@@ -171,9 +171,9 @@ export interface Inferred<out t = unknown, $ = {}> {
|
|
|
171
171
|
* // but instead chained from the root object
|
|
172
172
|
* }).configure({ description: "not odd" })
|
|
173
173
|
* // error message at path notOdd is not affected
|
|
174
|
-
* const oddProp = NotOddBox({ notOdd: 3 }) // notOdd must be even
|
|
174
|
+
* const oddProp = NotOddBox({ notOdd: 3 }) // notOdd must be even
|
|
175
175
|
* // error message at root is affected, leading to a misleading description
|
|
176
|
-
* const nonObject = NotOddBox(null) // must be not odd
|
|
176
|
+
* const nonObject = NotOddBox(null) // must be not odd
|
|
177
177
|
*/
|
|
178
178
|
configure: NodeSelector.SelectableFn<TypeMeta.MappableInput, this>;
|
|
179
179
|
/**
|
|
@@ -185,7 +185,7 @@ export interface Inferred<out t = unknown, $ = {}> {
|
|
|
185
185
|
* @example
|
|
186
186
|
* const AToZ = type(/^a.*z$/).describe("a string like 'a...z'")
|
|
187
187
|
* const good = AToZ("alcatraz") // "alcatraz"
|
|
188
|
-
* // ArkErrors: must be a string like 'a...z'
|
|
188
|
+
* // ArkErrors: must be a string like 'a...z'
|
|
189
189
|
* const badPattern = AToZ("albatross")
|
|
190
190
|
*/
|
|
191
191
|
describe: NodeSelector.SelectableFn<string, this>;
|
|
@@ -193,16 +193,16 @@ export interface Inferred<out t = unknown, $ = {}> {
|
|
|
193
193
|
* #### apply undeclared key behavior
|
|
194
194
|
*
|
|
195
195
|
* - `"ignore"` (default) - allow and preserve extra properties
|
|
196
|
-
* - `"reject"` - disallow extra
|
|
197
|
-
* - `"delete"` -
|
|
196
|
+
* - `"reject"` - disallow extra string keys
|
|
197
|
+
* - `"delete"` - output only declared keys
|
|
198
198
|
*/
|
|
199
199
|
onUndeclaredKey(behavior: UndeclaredKeyBehavior): this;
|
|
200
200
|
/**
|
|
201
201
|
* #### deeply apply undeclared key behavior
|
|
202
202
|
*
|
|
203
203
|
* - `"ignore"` (default) - allow and preserve extra properties
|
|
204
|
-
* - `"reject"` - disallow extra
|
|
205
|
-
* - `"delete"` -
|
|
204
|
+
* - `"reject"` - disallow extra string keys
|
|
205
|
+
* - `"delete"` - output only declared keys
|
|
206
206
|
*/
|
|
207
207
|
onDeepUndeclaredKey(behavior: UndeclaredKeyBehavior): this;
|
|
208
208
|
/**
|
|
@@ -210,7 +210,7 @@ export interface Inferred<out t = unknown, $ = {}> {
|
|
|
210
210
|
*
|
|
211
211
|
* @example
|
|
212
212
|
* const T = type({ foo: "string" });
|
|
213
|
-
* // TypeScript:
|
|
213
|
+
* // TypeScript: Type 'number' is not assignable to type 'string'
|
|
214
214
|
* const data = T.from({ foo: 5 });
|
|
215
215
|
*/
|
|
216
216
|
from(literal: this["inferIn"]): this["infer"];
|
|
@@ -250,13 +250,28 @@ export interface Inferred<out t = unknown, $ = {}> {
|
|
|
250
250
|
* })
|
|
251
251
|
*
|
|
252
252
|
* // Type<{ keyword: number; unvalidated: unknown; validated: string }>
|
|
253
|
-
* const
|
|
253
|
+
* const Out = T.out
|
|
254
254
|
*/
|
|
255
255
|
get out(): instantiateType<this["inferIntrospectableOut"], $>;
|
|
256
|
+
/**
|
|
257
|
+
* #### deeply invert morphs to encode output as input
|
|
258
|
+
*
|
|
259
|
+
* ⚠️ requires `import "arktype/codecs"`, and throws if a morph has no inverse
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* const EpochMs = codec("number.integer", "Date", {
|
|
263
|
+
* decode: n => new Date(n),
|
|
264
|
+
* encode: d => d.getTime()
|
|
265
|
+
* })
|
|
266
|
+
* const Event = type({ name: "string", at: EpochMs })
|
|
267
|
+
* // { name: "launch", at: 0 }
|
|
268
|
+
* const encoded = Event.encode({ name: "launch", at: new Date(0) })
|
|
269
|
+
*/
|
|
270
|
+
get encode(): instantiateType<inferEncoder<t>, $>;
|
|
256
271
|
/**
|
|
257
272
|
* #### add a compile-time brand to output
|
|
258
273
|
*
|
|
259
|
-
* 🥸 inference-only function that does nothing runtime
|
|
274
|
+
* 🥸 inference-only function that does nothing at runtime
|
|
260
275
|
*
|
|
261
276
|
* @example
|
|
262
277
|
* const Palindrome = type("string")
|
|
@@ -277,7 +292,7 @@ export interface Inferred<out t = unknown, $ = {}> {
|
|
|
277
292
|
/**
|
|
278
293
|
* #### {@link https://arktype.io/docs/objects#properties-optional | optional definition}
|
|
279
294
|
*
|
|
280
|
-
* ⚠️ unlike most other methods, this creates a definition rather than a Type
|
|
295
|
+
* ⚠️ unlike most other methods, this creates a definition rather than a Type
|
|
281
296
|
*
|
|
282
297
|
* @example
|
|
283
298
|
* const Prop = type({ foo: "number" })
|
|
@@ -290,7 +305,7 @@ export interface Inferred<out t = unknown, $ = {}> {
|
|
|
290
305
|
*
|
|
291
306
|
* ✅ object defaults can be returned from a function
|
|
292
307
|
* ⚠️ throws if the default value is not allowed
|
|
293
|
-
* ⚠️ unlike most other methods, this creates a definition rather than a Type
|
|
308
|
+
* ⚠️ unlike most other methods, this creates a definition rather than a Type
|
|
294
309
|
*
|
|
295
310
|
* @example
|
|
296
311
|
* // Type<{ count: Default<number, 0> }>
|
|
@@ -329,11 +344,11 @@ export interface Inferred<out t = unknown, $ = {}> {
|
|
|
329
344
|
* @example
|
|
330
345
|
* const Palindrome = type("string").narrow(s => s === [...s].reverse().join(""))
|
|
331
346
|
*
|
|
332
|
-
* const
|
|
333
|
-
* date.getFullYear() ===
|
|
347
|
+
* const ThisYear = type("string.date.parse").narrow((date, ctx) =>
|
|
348
|
+
* date.getFullYear() === new Date().getFullYear() || ctx.mustBe("the current year")
|
|
334
349
|
* )
|
|
335
350
|
* // Type<`${string}.tsx`>
|
|
336
|
-
* const WithPredicate = type("string").narrow((s): s is `${string}.tsx` =>
|
|
351
|
+
* const WithPredicate = type("string").narrow((s): s is `${string}.tsx` => s.endsWith(".tsx"))
|
|
337
352
|
*/
|
|
338
353
|
narrow<narrowed extends this["infer"] = never, r = instantiateType<[
|
|
339
354
|
narrowed
|
|
@@ -344,8 +359,8 @@ export interface Inferred<out t = unknown, $ = {}> {
|
|
|
344
359
|
* @example
|
|
345
360
|
* const User = type({ name: "string" })
|
|
346
361
|
*
|
|
347
|
-
* // parse a string and validate
|
|
348
|
-
* const parseUser = type("string").pipe(s => JSON.parse(s),
|
|
362
|
+
* // parse a string and validate the result as a User
|
|
363
|
+
* const parseUser = type("string").pipe(s => JSON.parse(s), User)
|
|
349
364
|
*/
|
|
350
365
|
pipe: ChainedPipeParser<$, t>;
|
|
351
366
|
/**
|
|
@@ -354,7 +369,7 @@ export interface Inferred<out t = unknown, $ = {}> {
|
|
|
354
369
|
* 🔗 `to({ name: "string" })` is equivalent to `.pipe(type({ name: "string" }))`
|
|
355
370
|
*
|
|
356
371
|
* @example
|
|
357
|
-
* // parse a string and validate
|
|
372
|
+
* // parse a string and validate the result as a user
|
|
358
373
|
* const parseUser = type("string").pipe(s => JSON.parse(s)).to({ name: "string" })
|
|
359
374
|
*/
|
|
360
375
|
to<const def, r = instantiateType<inferPipe<t, type.infer<def, $>>, $>>(def: type.validate<def, $>): r extends infer _ ? _ : never;
|
|
@@ -370,11 +385,11 @@ export interface Inferred<out t = unknown, $ = {}> {
|
|
|
370
385
|
select: BaseNode["select"];
|
|
371
386
|
}
|
|
372
387
|
/** @ts-ignore cast variance */
|
|
373
|
-
interface Type<out t = unknown, $ = {}> extends Callable<(data: unknown) => distill.Out<t> | ArkEnv.onFail>, Inferred<t, $> {
|
|
388
|
+
interface Type<out t = unknown, in out $ = {}> extends Callable<(data: unknown) => distill.Out<t> | ArkEnv.onFail>, Inferred<t, $> {
|
|
374
389
|
/**
|
|
375
390
|
* #### cast the way this is inferred
|
|
376
391
|
*
|
|
377
|
-
* 🥸 inference-only function that does nothing runtime
|
|
392
|
+
* 🥸 inference-only function that does nothing at runtime
|
|
378
393
|
*
|
|
379
394
|
* @example
|
|
380
395
|
* // Type<`LEEEEEEEE${string}ROY`>
|
|
@@ -405,11 +420,13 @@ interface Type<out t = unknown, $ = {}> extends Callable<(data: unknown) => dist
|
|
|
405
420
|
* #### intersect the parsed Type, returning an introspectable {@link Disjoint} if the result is unsatisfiable
|
|
406
421
|
*
|
|
407
422
|
* @example
|
|
408
|
-
*
|
|
423
|
+
* import { Type } from "arktype"
|
|
424
|
+
*
|
|
425
|
+
* // Type<{ foo: number; bar: string }> | Disjoint
|
|
409
426
|
* const T = type({ foo: "number" }).intersect({ bar: "string" })
|
|
410
427
|
* const Bad = type("number > 10").intersect("number < 5")
|
|
411
428
|
* // logs "Intersection of > 10 and < 5 results in an unsatisfiable type"
|
|
412
|
-
* if (Bad instanceof
|
|
429
|
+
* if (!(Bad instanceof Type)) console.log(Bad.summary)
|
|
413
430
|
*/
|
|
414
431
|
intersect<const def, r = instantiateType<inferIntersection<t, type.infer<def, $>>, $>>(def: type.validate<def, $>): r extends infer _ ? _ | Disjoint : never;
|
|
415
432
|
/**
|
|
@@ -459,7 +476,7 @@ interface Type<out t = unknown, $ = {}> extends Callable<(data: unknown) => dist
|
|
|
459
476
|
*
|
|
460
477
|
* @example
|
|
461
478
|
* const N = type(Math.random() > 0.5 ? "true" : "0") // Type<0 | true>
|
|
462
|
-
* const Ez = N.ifExtends("boolean") // Type<
|
|
479
|
+
* const Ez = N.ifExtends("boolean") // Type<boolean> | undefined
|
|
463
480
|
*/
|
|
464
481
|
ifExtends<const def, r = type.instantiate<def, $>>(other: type.validate<def, $>): r extends infer _ ? _ | undefined : never;
|
|
465
482
|
/**
|
|
@@ -528,6 +545,9 @@ interface Type<out t = unknown, $ = {}> extends Callable<(data: unknown) => dist
|
|
|
528
545
|
/** @deprecated */
|
|
529
546
|
Symbol: never;
|
|
530
547
|
}
|
|
548
|
+
type inferEncoder<t> = {
|
|
549
|
+
encode(In: distill.Out<t>): To<distill.In<t>>;
|
|
550
|
+
}["encode"];
|
|
531
551
|
export interface ChainedPipeParser<$, t> extends NaryPipeParser<$, t> {
|
|
532
552
|
try: NaryPipeParser<$, t>;
|
|
533
553
|
}
|
package/out/variants/date.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ExclusiveDateRangeSchema, InclusiveDateRangeSchema } from "@ark/schema";
|
|
2
2
|
import type { ObjectType } from "./object.ts";
|
|
3
3
|
/** @ts-ignore cast variance */
|
|
4
|
-
interface Type<out t extends globalThis.Date = globalThis.Date, $ = {}> extends ObjectType<t, $> {
|
|
4
|
+
interface Type<out t extends globalThis.Date = globalThis.Date, in out $ = {}> extends ObjectType<t, $> {
|
|
5
5
|
atOrAfter(schema: InclusiveDateRangeSchema): this;
|
|
6
6
|
atOrBefore(schema: InclusiveDateRangeSchema): this;
|
|
7
7
|
laterThan(schema: ExclusiveDateRangeSchema): this;
|
|
@@ -7,6 +7,8 @@ import type { ObjectType } from "./object.ts";
|
|
|
7
7
|
import type { StringType } from "./string.ts";
|
|
8
8
|
export type instantiateType<t, $> = [
|
|
9
9
|
t
|
|
10
|
-
] extends [anyOrNever] ? BaseType<t, $> : [t] extends [object] ? [
|
|
10
|
+
] extends [anyOrNever] ? BaseType<t, $> : [t] extends [object] ? instantiateObjectType<t, $> : [t] extends [string] ? StringType<t, $> : [t] extends [number] ? NumberType<t, $> : BaseType<t, $>;
|
|
11
|
+
type instantiateObjectType<t extends object, $> = [
|
|
11
12
|
t
|
|
12
|
-
] extends [array] ? ArrayType<t, $> : [t] extends [Date] ? DateType<t, $> : ObjectType<t,
|
|
13
|
+
] extends [array] ? ArrayType<t, $> : [t] extends [Date] ? DateType<t, $> : ObjectType<t, $>;
|
|
14
|
+
export {};
|
package/out/variants/number.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Divisor, ExclusiveNumericRangeSchema, InclusiveNumericRangeSchema } from "@ark/schema";
|
|
2
2
|
import type { BaseType } from "./base.ts";
|
|
3
3
|
/** @ts-ignore cast variance */
|
|
4
|
-
interface Type<out t extends number = number, $ = {}> extends BaseType<t, $> {
|
|
4
|
+
interface Type<out t extends number = number, in out $ = {}> extends BaseType<t, $> {
|
|
5
5
|
divisibleBy(schema: Divisor.Schema): this;
|
|
6
6
|
atLeast(schema: InclusiveNumericRangeSchema): this;
|
|
7
7
|
atMost(schema: InclusiveNumericRangeSchema): this;
|