arktype 2.0.0-rc.10 → 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.
@@ -173,7 +173,8 @@ type inferredDefaultKeyOf<o> = keyof o extends infer k ? k extends keyof o ? [
173
173
  type inferredOptionalKeyOf<o> = keyof o extends infer k ? k extends keyof o ? [
174
174
  o[k]
175
175
  ] extends [anyOrNever] ? never : o[k] extends InferredOptional ? k : never : never : never;
176
- type distillArray<t extends array, opts extends distill.Options> = _distillArray<[...t], opts, []> extends infer result ? distillNonArraykeys<t, t extends unknown[] ? result : Readonly<t>, opts> : never;
176
+ type distillArray<t extends array, opts extends distill.Options> = t[number][] extends t ? alignReadonly<_distill<t[number], opts>[], t> : distillNonArraykeys<t, alignReadonly<_distillArray<[...t], opts, []>, t>, opts>;
177
+ type alignReadonly<result extends unknown[], original extends array> = original extends unknown[] ? result : Readonly<result>;
177
178
  type distillNonArraykeys<originalArray extends array, distilledArray, opts extends distill.Options> = keyof originalArray extends keyof distilledArray | constrained ? distilledArray : distilledArray & _distill<{
178
179
  [k in keyof originalArray as k extends (keyof distilledArray | (opts["branded"] extends true ? never : constrained)) ? never : k]: originalArray[k];
179
180
  }, opts>;
@@ -11,7 +11,7 @@ import { arkPrototypes } from "./constructors/constructors.ts";
11
11
  import type { distill } from "./inference.ts";
12
12
  import { number } from "./number/number.ts";
13
13
  import { string } from "./string/string.ts";
14
- import { arkTsGenerics, arkTsKeywords, unknown } from "./ts.ts";
14
+ import { arkTsGenerics, arkTsKeywords, object, unknown } from "./ts.ts";
15
15
  export interface Ark extends Omit<Ark.keywords, keyof Ark.wrapped>, Ark.wrapped {
16
16
  }
17
17
  export declare namespace Ark {
@@ -20,6 +20,7 @@ export declare namespace Ark {
20
20
  interface wrapped extends arkPrototypes.wrapped {
21
21
  string: string.submodule;
22
22
  number: number.submodule;
23
+ object: object.submodule;
23
24
  unknown: unknown.submodule;
24
25
  }
25
26
  interface typeAttachments extends arkTsKeywords.$ {
@@ -3,7 +3,7 @@ import { arkBuiltins } from "./builtins.js";
3
3
  import { arkPrototypes } from "./constructors/constructors.js";
4
4
  import { number } from "./number/number.js";
5
5
  import { string } from "./string/string.js";
6
- import { arkTsGenerics, arkTsKeywords, unknown } from "./ts.js";
6
+ import { arkTsGenerics, arkTsKeywords, object, unknown } from "./ts.js";
7
7
  $arkTypeRegistry.typeAttachments = {
8
8
  ...arkTsKeywords,
9
9
  Key: arkBuiltins.Key,
@@ -16,6 +16,7 @@ export const ark = scope({
16
16
  ...arkBuiltins,
17
17
  string,
18
18
  number,
19
+ object,
19
20
  unknown
20
21
  }, { prereducedAliases: true, ambient: true });
21
22
  export const keywords = ark.export();
@@ -1,5 +1,6 @@
1
- import { Hkt, type Key, type omit, type pick, type show } from "@ark/util";
1
+ import { Hkt, type Json, type Key, type omit, type pick, type show } from "@ark/util";
2
2
  import type { Module, Submodule } from "../module.ts";
3
+ import type { To } from "./inference.ts";
3
4
  export declare const arkTsKeywords: arkTsKeywords;
4
5
  export type arkTsKeywords = Module<arkTsKeywords.$>;
5
6
  export declare namespace arkTsKeywords {
@@ -30,6 +31,31 @@ export declare namespace unknown {
30
31
  any: any;
31
32
  };
32
33
  }
34
+ export declare const json: Module<{
35
+ root: unknown;
36
+ stringify: unknown;
37
+ }>;
38
+ export declare namespace json {
39
+ type submodule = Submodule<$>;
40
+ type $ = {
41
+ root: Json;
42
+ stringify: (In: Json) => To<string>;
43
+ };
44
+ }
45
+ export declare const object: Module<{
46
+ root: unknown;
47
+ json: Submodule<{
48
+ root: unknown;
49
+ stringify: unknown;
50
+ }>;
51
+ }>;
52
+ export declare namespace object {
53
+ type submodule = Submodule<$>;
54
+ type $ = {
55
+ root: object;
56
+ json: json.submodule;
57
+ };
58
+ }
33
59
  declare class RecordHkt extends Hkt<[Key, unknown]> {
34
60
  body: Record<this[0], this[1]>;
35
61
  }
@@ -1,4 +1,4 @@
1
- import { genericNode, intrinsic } from "@ark/schema";
1
+ import { genericNode, intrinsic, node } from "@ark/schema";
2
2
  import { Hkt } from "@ark/util";
3
3
  import { arkModule } from "./utils.js";
4
4
  export const arkTsKeywords = arkModule({
@@ -19,6 +19,18 @@ export const unknown = arkModule({
19
19
  root: intrinsic.unknown,
20
20
  any: intrinsic.unknown
21
21
  });
22
+ export const json = arkModule({
23
+ root: intrinsic.json,
24
+ stringify: node("morph", {
25
+ in: intrinsic.json,
26
+ morphs: (data) => JSON.stringify(data),
27
+ declaredOut: intrinsic.string
28
+ })
29
+ });
30
+ export const object = arkModule({
31
+ root: intrinsic.object,
32
+ json
33
+ });
22
34
  class RecordHkt extends Hkt {
23
35
  }
24
36
  const Record = genericNode(["K", intrinsic.key], "V")(args => ({
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.10",
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.12.0",
38
- "@ark/schema": "0.12.0"
37
+ "@ark/util": "0.13.0",
38
+ "@ark/schema": "0.13.0"
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public"