arktype 2.0.0-dev.24 → 2.0.0-dev.26

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.
Files changed (38) hide show
  1. package/out/ark.d.ts +1 -1
  2. package/out/ark.js +1 -2
  3. package/out/parser/definition.d.ts +1 -1
  4. package/out/parser/generic.d.ts +2 -2
  5. package/out/parser/objectLiteral.d.ts +38 -25
  6. package/out/parser/objectLiteral.js +55 -62
  7. package/out/parser/semantic/bounds.d.ts +1 -1
  8. package/out/parser/semantic/default.d.ts +8 -0
  9. package/out/parser/semantic/default.js +1 -0
  10. package/out/parser/semantic/infer.d.ts +4 -3
  11. package/out/parser/semantic/validate.d.ts +5 -3
  12. package/out/parser/string/reduce/dynamic.d.ts +2 -1
  13. package/out/parser/string/reduce/dynamic.js +4 -2
  14. package/out/parser/string/reduce/shared.d.ts +5 -5
  15. package/out/parser/string/shift/operand/date.d.ts +2 -4
  16. package/out/parser/string/shift/operand/enclosed.d.ts +1 -11
  17. package/out/parser/string/shift/operand/genericArgs.d.ts +1 -1
  18. package/out/parser/string/shift/operand/operand.d.ts +3 -2
  19. package/out/parser/string/shift/operand/operand.js +2 -3
  20. package/out/parser/string/shift/operand/unenclosed.d.ts +4 -4
  21. package/out/parser/string/shift/operand/unenclosed.js +6 -5
  22. package/out/parser/string/shift/operator/bounds.d.ts +3 -5
  23. package/out/parser/string/shift/operator/bounds.js +5 -6
  24. package/out/parser/string/shift/operator/default.d.ts +24 -0
  25. package/out/parser/string/shift/operator/default.js +23 -0
  26. package/out/parser/string/shift/operator/divisor.d.ts +1 -1
  27. package/out/parser/string/shift/operator/operator.d.ts +3 -2
  28. package/out/parser/string/shift/scanner.d.ts +4 -11
  29. package/out/parser/string/shift/scanner.js +10 -12
  30. package/out/parser/string/string.d.ts +7 -5
  31. package/out/parser/string/string.js +4 -1
  32. package/out/parser/tuple.d.ts +4 -4
  33. package/out/parser/tuple.js +3 -3
  34. package/out/scope.d.ts +5 -4
  35. package/out/scope.js +104 -54
  36. package/out/type.d.ts +7 -5
  37. package/out/type.js +7 -4
  38. package/package.json +3 -3
package/out/type.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { ArkErrors, BaseRoot, type BaseMeta, type ConstraintKind, type Disjoint, type DivisorSchema, type ExactLengthSchema, type ExclusiveDateRangeSchema, type ExclusiveNumericRangeSchema, type InclusiveDateRangeSchema, type InclusiveNumericRangeSchema, type InnerRoot, type Morph, type MorphAst, type NodeSchema, type Out, type PatternSchema, type Predicate, type Prerequisite, type PrimitiveConstraintKind, type Root, type constrain, type constraintKindOf, type distillIn, type distillOut, type exclusivizeRangeSchema, type inferIntersection, type inferMorphOut, type inferPipes, type inferPredicate, type writeInvalidOperandMessage } from "@arktype/schema";
1
+ import { ArkErrors, BaseRoot, type BaseMeta, type ConstraintKind, type Disjoint, type DivisorSchema, type ExactLengthSchema, type ExclusiveDateRangeSchema, type ExclusiveNumericRangeSchema, type InclusiveDateRangeSchema, type InclusiveNumericRangeSchema, type InnerRoot, type Morph, type MorphAst, type NodeSchema, type Out, type PatternSchema, type Predicate, type Prerequisite, type PrimitiveConstraintKind, type Root, type constrain, type constraintKindOf, type distillIn, type distillOut, type exclusivizeRangeSchema, type indexInto, type indexOf, type inferIntersection, type inferMorphOut, type inferPipes, type inferPredicate, type writeInvalidOperandMessage } from "@arktype/schema";
2
2
  import { Callable, type Constructor, type ErrorMessage, type array, type conform } from "@arktype/util";
3
3
  import { Generic, type validateParameterString } from "./generic.js";
4
4
  import type { inferDefinition, validateDeclared, validateDefinition } from "./parser/definition.js";
@@ -13,6 +13,7 @@ export interface TypeParser<$ = {}> {
13
13
  <params extends string, const def>(params: `<${validateParameterString<params>}>`, def: validateDefinition<def, $, {
14
14
  [param in parseGenericParams<params>[number]]: unknown;
15
15
  }>): Generic<parseGenericParams<params>, def, $>;
16
+ raw(def: unknown): Type<any, $>;
16
17
  errors: typeof ArkErrors;
17
18
  }
18
19
  export declare class RawTypeParser extends Callable<(...args: unknown[]) => BaseRoot | Generic, TypeParserAttachments> {
@@ -40,12 +41,15 @@ declare class _Type<t = unknown, $ = any> extends InnerRoot<t, $> {
40
41
  pipe<a extends Morph<this["infer"]>, b extends Morph<inferMorphOut<a>>, c extends Morph<inferMorphOut<b>>, d extends Morph<inferMorphOut<c>>, e extends Morph<inferMorphOut<d>>>(a: a, b: b, c: c, d: d, e: e): Type<inferPipes<t, [a, b, c, d, e]>, $>;
41
42
  pipe<a extends Morph<this["infer"]>, 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>>>(a: a, b: b, c: c, d: d, e: e, f: f): Type<inferPipes<t, [a, b, c, d, e, f]>, $>;
42
43
  pipe<a extends Morph<this["infer"]>, 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>>>(a: a, b: b, c: c, d: d, e: e, f: f, g: g): Type<inferPipes<t, [a, b, c, d, e, f, g]>, $>;
43
- narrow<const predicate extends Predicate<distillOut<t>>>(predicate: predicate): Type<t extends MorphAst ? (In: this["tIn"]) => Out<inferPredicate<this["tOut"], predicate>> : inferPredicate<t, predicate>, $>;
44
+ narrow<predicate extends Predicate<distillOut<t>>>(predicate: predicate): Type<t extends MorphAst ? inferPredicate<this["tOut"], predicate> extends infer narrowed ? (In: this["tIn"]) => Out<narrowed> : never : inferPredicate<t, predicate>, $>;
44
45
  equals<def>(def: validateTypeRoot<def, $>): this is Type<inferTypeRoot<def>, $>;
45
46
  extract<def>(r: validateTypeRoot<def, $>): Type<t, $>;
46
47
  exclude<def>(r: validateTypeRoot<def, $>): Type<t, $>;
47
48
  extends<def>(other: validateTypeRoot<def, $>): this is Type<inferTypeRoot<def>, $>;
48
49
  overlaps<def>(r: validateTypeRoot<def, $>): boolean;
50
+ get<k1 extends indexOf<t>>(k1: k1 | AnyType<k1>): Type<indexInto<t, k1>, $>;
51
+ get<k1 extends indexOf<t>, k2 extends indexOf<indexInto<t, k1>>>(k1: k1 | AnyType<k1>, k2: k2 | AnyType<k2>): Type<indexInto<indexInto<t, k1>, k2>, $>;
52
+ get<k1 extends indexOf<t>, k2 extends indexOf<indexInto<t, k1>>, k3 extends indexOf<indexInto<indexInto<t, k1>, k2>>>(k1: k1 | AnyType<k1>, k2: k2 | AnyType<k2>, k3: k3 | AnyType<k3>): Type<indexInto<indexInto<indexInto<t, k1>, k2>, k3>, $>;
49
53
  constrain<kind extends PrimitiveConstraintKind, const def extends NodeSchema<kind>>(kind: conform<kind, constraintKindOf<this["inferIn"]>>, def: def): Type<constrain<t, kind, def>, $>;
50
54
  satisfying<predicate extends Predicate<distillIn<t>>>(predicate: predicate): Type<t extends MorphAst ? (In: inferPredicate<this["tIn"], predicate>) => Out<this["tOut"]> : inferPredicate<t, predicate>, $>;
51
55
  divisibleBy<const schema extends DivisorSchema>(this: validateChainedConstraint<"divisor", this>, schema: schema): Type<constrain<t, "divisor", schema>, $>;
@@ -69,9 +73,7 @@ export interface Type<
69
73
  out t = unknown, $ = {}> extends _Type<t, $> {
70
74
  }
71
75
  export type TypeConstructor<t = unknown, $ = {}> = new (def: unknown, $: Scope<$>) => Type<t, $>;
72
- export type AnyType<
73
- /** @ts-expect-error allow instantiation assignment to the base type */
74
- out t = unknown, $ = any> = Type<t, $>;
76
+ export type AnyType<out t = unknown> = Type<t, any>;
75
77
  export declare const Type: TypeConstructor;
76
78
  export type DefinitionParser<$> = <def>(def: validateTypeRoot<def, $>) => def;
77
79
  export type validateTypeRoot<def, $ = {}> = validateDefinition<def, $, bindThis<def>>;
package/out/type.js CHANGED
@@ -2,9 +2,6 @@ import { ArkErrors, BaseRoot } from "@arktype/schema";
2
2
  import { Callable } from "@arktype/util";
3
3
  import { Generic } from "./generic.js";
4
4
  import { parseGenericParams } from "./parser/generic.js";
5
- const typeParserAttachments = Object.freeze({
6
- errors: ArkErrors
7
- });
8
5
  export class RawTypeParser extends Callable {
9
6
  constructor($) {
10
7
  super((...args) => {
@@ -27,7 +24,13 @@ export class RawTypeParser extends Callable {
27
24
  // non-expression tuple definitions to be parsed, but it's not a supported
28
25
  // part of the API as specified by the associated types
29
26
  return $.parseRoot(args);
30
- }, { bind: $, attach: typeParserAttachments });
27
+ }, {
28
+ bind: $,
29
+ attach: {
30
+ errors: ArkErrors,
31
+ raw: $.parseRoot
32
+ }
33
+ });
31
34
  }
32
35
  }
33
36
  export const Type = BaseRoot;
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-dev.24",
4
+ "version": "2.0.0-dev.26",
5
5
  "license": "MIT",
6
6
  "author": {
7
7
  "name": "David Blass",
@@ -24,8 +24,8 @@
24
24
  "out"
25
25
  ],
26
26
  "dependencies": {
27
- "@arktype/util": "0.0.49",
28
- "@arktype/schema": "0.1.16"
27
+ "@arktype/util": "0.0.51",
28
+ "@arktype/schema": "0.1.18"
29
29
  },
30
30
  "scripts": {
31
31
  "build": "tsx ../repo/build.ts",