arktype 2.0.0-rc.1 → 2.0.0-rc.3

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/generic.d.ts CHANGED
@@ -152,7 +152,9 @@ export type genericParamDefsToAst<defs extends array<GenericParamDef>, $> = [
152
152
  [i in keyof defs]: genericParamDefToAst<defs[i], $>;
153
153
  }
154
154
  ];
155
- export type GenericParser<$ = {}> = <const paramsDef extends array<GenericParamDef>>(...params: paramsDef) => GenericBodyParser<genericParamDefsToAst<paramsDef, $>, $>;
155
+ export type GenericParser<$ = {}> = <const paramsDef extends array<GenericParamDef>>(...params: {
156
+ [i in keyof paramsDef]: paramsDef[i] extends (readonly [infer name, infer def]) ? readonly [name, validateTypeRoot<def, $>] : paramsDef[i];
157
+ }) => GenericBodyParser<genericParamDefsToAst<paramsDef, $>, $>;
156
158
  interface GenericBodyParser<params extends array<GenericParamAst>, $> {
157
159
  <const body>(body: validateDefinition<body, $, baseGenericConstraints<params>>): Generic<params, body, $, $>;
158
160
  <hkt extends Hkt.constructor>(instantiateDef: LazyGenericBody<baseGenericResolutions<params, $>>, hkt: hkt): Generic<params, InstanceType<hkt>, $, $>;
@@ -46,10 +46,14 @@ export declare const string: Module<{
46
46
  integer: Submodule<stringInteger.submodule>;
47
47
  alpha: object;
48
48
  alphanumeric: object;
49
- digits: object;
50
- numeric: Submodule<stringNumeric.submodule>;
51
49
  creditCard: object;
50
+ date: Submodule<stringDate.submodule>;
51
+ digits: object;
52
52
  email: object;
53
+ ip: Submodule<ip.submodule>;
54
+ numeric: Submodule<stringNumeric.submodule>;
55
+ semver: object;
56
+ url: Submodule<url.submodule>;
53
57
  uuid: Submodule<{
54
58
  $root: string.matching<string> | "00000000-0000-0000-0000-000000000000" | "ffffffff-ffff-ffff-ffff-ffffffffffff";
55
59
  v4: object;
@@ -61,13 +65,9 @@ export declare const string: Module<{
61
65
  v7: object;
62
66
  v8: object;
63
67
  }>;
64
- semver: object;
65
- ip: Submodule<ip.submodule>;
66
- date: Submodule<stringDate.submodule>;
67
- capitalize: Submodule<capitalize.submodule>;
68
- lower: Submodule<lower.submodule>;
69
68
  upper: Submodule<upper.submodule>;
70
- url: Submodule<url.submodule>;
69
+ lower: Submodule<lower.submodule>;
70
+ capitalize: Submodule<capitalize.submodule>;
71
71
  }>;
72
72
  export declare namespace string {
73
73
  type atLeastLength<rule> = constrain<string, AtLeastLength<rule>>;
package/out/scope.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { BaseScope, type AliasDefEntry, type ArkScopeConfig, type BaseNode, type BaseRoot, type GenericArgResolutions, type GenericAst, type GenericParamAst, type NodeKind, type NodeParseOptions, type NodeSchema, type PreparsedNodeResolution, type PrivateDeclaration, type RootKind, type RootSchema, type arkKind, type exportedNameOf, type nodeOfKind, type reducibleKindOf, type toInternalScope, type writeDuplicateAliasError } from "@ark/schema";
2
- import { type ErrorType, type Json, type anyOrNever, type array, type flattenListable, type inferred, type noSuggest, type nominal } from "@ark/util";
3
- import type { ArkAmbient, ArkSchemaRegistry } from "./config.ts";
2
+ import { type ErrorType, type Json, type anyOrNever, type array, type flattenListable, type noSuggest, type nominal } from "@ark/util";
3
+ import type { ArkSchemaRegistry } from "./config.ts";
4
4
  import { parseGenericParams, type GenericDeclaration, type GenericParser, type ParameterString, type baseGenericConstraints, type parseValidGenericParams } from "./generic.ts";
5
- import type { Ark, type } from "./keywords/ark.ts";
5
+ import type { Ark } from "./keywords/ark.ts";
6
6
  import type { BoundModule, Module, Submodule, instantiateExport } from "./module.ts";
7
7
  import { type inferDefinition, type validateDefinition } from "./parser/definition.ts";
8
8
  import type { DefAst, InferredAst } from "./parser/semantic/infer.ts";
@@ -26,9 +26,9 @@ type PreparsedResolution = PreparsedNodeResolution;
26
26
  type bootstrapAliases<def> = {
27
27
  [k in Exclude<keyof def, GenericDeclaration>]: def[k] extends (PreparsedResolution) ? def[k] extends {
28
28
  t: infer g extends GenericAst;
29
- } ? g : def[k] extends Module<infer $> ? Submodule<$> : def[k] : def[k] extends (() => infer thunkReturn extends PreparsedResolution) ? thunkReturn extends {
29
+ } ? g : def[k] extends Module<infer $> | BoundModule<infer $, any> ? Submodule<$> : def[k] : def[k] extends (() => infer thunkReturn extends PreparsedResolution) ? thunkReturn extends {
30
30
  t: infer g extends GenericAst;
31
- } ? g : thunkReturn extends Module<infer $> ? Submodule<$> : thunkReturn : Def<def[k]>;
31
+ } ? g : thunkReturn extends Module<infer $> | BoundModule<infer $, any> ? Submodule<$> : thunkReturn : Def<def[k]>;
32
32
  } & {
33
33
  [k in keyof def & GenericDeclaration as extractGenericName<k>]: GenericAst<parseValidGenericParams<extractGenericParameters<k>, bootstrapAliases<def>>, def[k], UnparsedScope>;
34
34
  };
@@ -40,18 +40,12 @@ type inferBootstrapped<$> = {
40
40
  export type bindGenericToScope<g extends GenericAst, $> = GenericAst<g["paramsAst"], g["bodyDef"], g["$"] extends UnparsedScope ? $ : g["$"], $>;
41
41
  type extractGenericName<k> = k extends GenericDeclaration<infer name> ? name : never;
42
42
  type extractGenericParameters<k> = k extends `${string}<${infer params}>` ? ParameterString<params> : never;
43
- export type resolve<reference extends keyof $ | keyof args, $, args> = inferResolution<reference extends keyof args ? args[reference] : $[reference & keyof $], $, args>;
44
43
  export type resolutionToAst<alias extends string, resolution> = [
45
44
  resolution
46
45
  ] extends [anyOrNever] ? InferredAst<resolution, alias> : resolution extends Def<infer def> ? DefAst<def, alias> : resolution extends {
47
46
  [arkKind]: "module";
48
47
  $root: infer root;
49
48
  } ? InferredAst<root, alias> : resolution extends GenericAst ? resolution : InferredAst<resolution, alias>;
50
- export type inferResolution<resolution, $, args> = [
51
- resolution
52
- ] extends [anyOrNever] ? resolution : resolution extends {
53
- [inferred]: infer t;
54
- } ? t : resolution extends Def<infer def> ? inferDefinition<def, $, args> : resolution;
55
49
  export type moduleKeyOf<$> = {
56
50
  [k in keyof $]: $[k] extends {
57
51
  [arkKind]: "module";
@@ -59,8 +53,6 @@ export type moduleKeyOf<$> = {
59
53
  $[k]
60
54
  ] extends [anyOrNever] ? never : k & string : never;
61
55
  }[keyof $];
62
- type unwrapPreinferred<t> = t extends type.cast<infer inferred> ? inferred : t;
63
- export type tryInferSubmoduleReference<$, token> = token extends `${infer submodule extends moduleKeyOf<$>}.${infer subalias}` ? subalias extends keyof $[submodule] ? unwrapPreinferred<$[submodule][subalias]> : tryInferSubmoduleReference<$[submodule], subalias> : token extends (`${infer submodule extends moduleKeyOf<ArkAmbient.$>}.${infer subalias}`) ? subalias extends keyof ArkAmbient.$[submodule] ? unwrapPreinferred<ArkAmbient.$[submodule][subalias]> : tryInferSubmoduleReference<ArkAmbient.$[submodule], subalias> : never;
64
56
  export interface ArkTypeRegistry extends ArkSchemaRegistry {
65
57
  typeAttachments?: Ark.boundTypeAttachments<any>;
66
58
  }
package/out/type.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ArkErrors, BaseRoot, type MetaSchema, type Morph, type Predicate } from "@ark/schema";
2
2
  import { Callable, type Constructor, type array, type conform } from "@ark/util";
3
- import { type Generic, type ParameterString, type baseGenericConstraints, type parseValidGenericParams, type validateParameterString } from "./generic.ts";
3
+ import { type Generic, type GenericParser, type ParameterString, type baseGenericConstraints, type parseValidGenericParams, type validateParameterString } from "./generic.ts";
4
4
  import type { Ark, ark } from "./keywords/ark.ts";
5
5
  import type { distillIn, distillOut } from "./keywords/ast.ts";
6
6
  import type { inferDefinition, validateDeclared, validateDefinition } from "./parser/definition.ts";
@@ -18,6 +18,7 @@ export interface TypeParser<$ = {}> extends Ark.boundTypeAttachments<$> {
18
18
  errors: typeof ArkErrors;
19
19
  module: ModuleParser;
20
20
  scope: ScopeParser;
21
+ generic: GenericParser<$>;
21
22
  ark: typeof ark;
22
23
  }
23
24
  export declare class InternalTypeParser extends Callable<(...args: unknown[]) => BaseRoot | Generic, TypeParserAttachments> {
package/out/type.js CHANGED
@@ -8,6 +8,7 @@ export class InternalTypeParser extends Callable {
8
8
  raw: $.parseRoot,
9
9
  module: $.constructor.module,
10
10
  scope: $.constructor.scope,
11
+ generic: $.generic,
11
12
  // this won't be defined during bootstrapping, but externally always will be
12
13
  ark: $.ambient
13
14
  },
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.1",
4
+ "version": "2.0.0-rc.3",
5
5
  "license": "MIT",
6
6
  "author": {
7
7
  "name": "David Blass",