arktype 2.0.1 → 2.0.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/README.md ADDED
@@ -0,0 +1,161 @@
1
+ <h1 align="center">ArkType</h1>
2
+
3
+ ArkType is a runtime validation library that parses optimized validators from familiar, type-safe syntax.
4
+
5
+ It can be used to check external data like JSON payloads or form submissions at the boundaries of your code (similar to Zod or Yup).
6
+
7
+ <video
8
+ autoPlay
9
+ loop
10
+ controls
11
+ playsInline
12
+ muted
13
+ disablePictureInPicture
14
+ src="https://github.com/user-attachments/assets/eaace5f0-310e-4fc8-9a95-1c0afc6fd110"
15
+ />
16
+
17
+ ## Docs
18
+
19
+ See our [docs site](https://arktype.io)
20
+
21
+ ## Contributions
22
+
23
+ We accept and encourage pull requests from outside ArkType. Planned work is tracked in [this GitHub project](https://github.com/orgs/arktypeio/projects/4).
24
+
25
+ Depending on your level of familiarity with type systems and TS generics, some parts of the codebase may be hard to jump into. That said, there's plenty of opportunities for more straightforward contributions. We'd generally recommend starting with one of these issues labeled [external-contributor-friendly](https://github.com/orgs/arktypeio/projects/4/?filterQuery=label%3A%22external-contributor-friendly%22).
26
+
27
+ If you're planning on submitting a non-trivial fix or a new feature, please [create an issue first](https://github.com/arktypeio/arktype/issues/new) so everyone's on the same page. The last thing we want is for you to spend time on a submission we're unable to merge.
28
+
29
+ When you're ready, check out our [guide](./.github/CONTRIBUTING.md) to get started!
30
+
31
+ ## License
32
+
33
+ This project is licensed under the terms of the
34
+ [MIT license](./LICENSE).
35
+
36
+ ## Code of Conduct
37
+
38
+ We will not tolerate any form of disrespect toward members of our community. Please refer to our [Code of Conduct](./.github/CODE_OF_CONDUCT.md) and reach out to david@arktype.io immediately if you've seen or experienced an interaction that may violate these standards.
39
+
40
+ ## Sponsorship
41
+
42
+ We've been working full-time on this project for multiple years and it means a lot to have the community behind us.
43
+
44
+ If the project has been useful to you and you are in a financial position to do so, please chip in via [GitHub Sponsors](https://github.com/sponsors/arktypeio).
45
+
46
+ Otherwise, consider sending me an email (david@arktype.io) or [message me on Discord](https://arktype.io/discord) to let me know you're a fan of ArkType. Either would make my day!
47
+
48
+ ### ArkSponsors ⛵
49
+
50
+ <table>
51
+ <tr>
52
+ <th>sam-goodwin</th>
53
+ <th>fubhy</th>
54
+ </tr>
55
+ <tr>
56
+ <td>
57
+ <a href="https://github.com/sam-goodwin"
58
+ ><img
59
+ height="64px"
60
+ src="https://avatars.githubusercontent.com/u/38672686"
61
+ /></a>
62
+ </td>
63
+ <td>
64
+ <a href="https://github.com/fubhy"
65
+ ><img
66
+ height="64px"
67
+ src="https://avatars.githubusercontent.com/u/1172528"
68
+ /></a>
69
+ </td>
70
+ </tr>
71
+ </table>
72
+
73
+ ### Sponsors 🥰
74
+
75
+ <table>
76
+ <tr>
77
+ <th>tmm</th>
78
+ <th>mishushakov</th>
79
+ <th>mewhhaha</th>
80
+ <th>codeandcats</th>
81
+ <th>drwpwrs</th>
82
+ </tr>
83
+ <tr>
84
+ <td>
85
+ <a href="https://github.com/tmm"
86
+ ><img
87
+ height="64px"
88
+ src="https://avatars.githubusercontent.com/u/6759464"
89
+ /></a>
90
+ </td>
91
+ <td>
92
+ <a href="https://github.com/mishushakov"
93
+ ><img height="64px" src="https://avatars.githubusercontent.com/u/10400064"
94
+ /></a>
95
+ </td>
96
+ <td>
97
+ <a href="https://github.com/mewhhaha"
98
+ ><img
99
+ height="64px"
100
+ src="https://avatars.githubusercontent.com/u/3399205"
101
+ /></a>
102
+ </td>
103
+ <td>
104
+ <a href="https://github.com/codeandcats"
105
+ ><img
106
+ height="64px"
107
+ src="https://avatars.githubusercontent.com/u/6035934"
108
+ /></a>
109
+ </td>
110
+ <td>
111
+ <a href="https://github.com/drwpwrs"
112
+ ><img
113
+ height="64px"
114
+ src="https://avatars.githubusercontent.com/u/49917220"
115
+ /></a>
116
+ </td>
117
+ </tr>
118
+ <tr>
119
+ <th>Timeraa</th>
120
+ <th>Phalangers</th>
121
+ <th>WilliamConnatser</th>
122
+ <th>JameEnder</th>
123
+ </tr>
124
+ <tr>
125
+ <td>
126
+ <a href="https://github.com/Timeraa"
127
+ ><img
128
+ height="64px"
129
+ src="https://avatars.githubusercontent.com/u/29104008"
130
+ /></a>
131
+ </td>
132
+ <td>
133
+ <a href="https://github.com/Phalangers"
134
+ ><img
135
+ height="64px"
136
+ src="https://avatars.githubusercontent.com/u/13227796"
137
+ /></a>
138
+ </td>
139
+ <td>
140
+ <a href="https://github.com/WilliamConnatser"
141
+ ><img
142
+ height="64px"
143
+ src="https://avatars.githubusercontent.com/u/43946230"
144
+ /></a>
145
+ </td>
146
+ <td>
147
+ <a href="https://github.com/JameEnder"
148
+ ><img
149
+ height="64px"
150
+ src="https://avatars.githubusercontent.com/u/47925045"
151
+ /></a>
152
+ </td>
153
+ <td>
154
+ <a href="https://github.com/tylim88"
155
+ ><img
156
+ height="64px"
157
+ src="https://avatars.githubusercontent.com/u/5227509"
158
+ /></a>
159
+ </td>
160
+ </tr>
161
+ </table>
@@ -19,7 +19,9 @@ export declare namespace distill {
19
19
  }
20
20
  }
21
21
  type finalizeDistillation<t, distilled> = equals<t, distilled> extends true ? t : distilled;
22
- type _distill<t, endpoint extends distill.Endpoint, seen> = t extends undefined ? t : [t] extends [anyOrNever | seen] ? t : unknown extends t ? unknown : t extends Brand<infer base> ? endpoint extends "in" ? base : t : t extends TerminallyInferredObject | Primitive ? t : t extends Function ? t extends InferredMorph<infer i, infer o> ? distillIo<i, o, endpoint, seen> : t : t extends Default<infer constraint> ? _distill<constraint, endpoint, seen> : t extends array ? distillArray<t, endpoint, seen | t> : isSafelyMappable<t> extends true ? distillMappable<t, endpoint, seen | t> : t;
22
+ type _distill<t, endpoint extends distill.Endpoint, seen> = t extends undefined ? t : [t] extends [anyOrNever | seen] ? t : unknown extends t ? unknown : t extends Brand<infer base> ? endpoint extends "in" ? base : t : t extends TerminallyInferredObject | Primitive ? t : t extends Function ? t extends InferredMorph<infer i, infer o> ? [
23
+ ReturnType<t>
24
+ ] extends [anyOrNever] ? t : distillIo<i, o, endpoint, seen> : t : t extends Default<infer constraint> ? _distill<constraint, endpoint, seen> : t extends array ? distillArray<t, endpoint, seen | t> : isSafelyMappable<t> extends true ? distillMappable<t, endpoint, seen | t> : t;
23
25
  type distillMappable<o, endpoint extends distill.Endpoint, seen> = endpoint extends "in" ? show<{
24
26
  [k in keyof o as k extends inferredDefaultKeyOf<o> ? never : k]: _distill<o[k], endpoint, seen>;
25
27
  } & {
package/out/config.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { ArkSchemaRegistry } from "@ark/schema";
2
2
  import type { Ark } from "./keywords/keywords.ts";
3
3
  import type { exportScope } from "./module.ts";
4
- export * from "@ark/schema/config";
4
+ export { configure, type ArkConfig, type ArkSchemaRegistry } from "@ark/schema";
5
5
  export interface ArkTypeRegistryContents extends ArkSchemaRegistry {
6
6
  ambient: exportScope<Ark>;
7
7
  }
package/out/config.js CHANGED
@@ -1,2 +1 @@
1
- // eslint-disable-next-line @typescript-eslint/no-restricted-imports
2
- export * from "@ark/schema/config";
1
+ export { configure } from "@ark/schema";
@@ -1,4 +1,4 @@
1
- import { hasArkKind, isNode } from "@ark/schema";
1
+ import { hasArkKind } from "@ark/schema";
2
2
  import { domainOf, hasDomain, isThunk, objectKindOf, printable, throwParseError } from "@ark/util";
3
3
  import { parseObjectLiteral } from "./objectLiteral.js";
4
4
  import { parseString } from "./string.js";
@@ -12,24 +12,7 @@ export const parseInnerDefinition = (def, ctx) => {
12
12
  // resolutions like "this" or generic args
13
13
  return parseString(def, ctx);
14
14
  }
15
- // include parseConfigHash in cacheId to ensure that if global config
16
- // is updated, we reparse strings
17
- const cacheId = `${ctx.$.id}:${ctx.$.configSnapshot.hash}`;
18
- const scopeCache = (parseCache[cacheId] ??= {});
19
- const cachedResult = scopeCache[def];
20
- if (cachedResult) {
21
- // even though we know $ is the same, we still need to call bindReference
22
- // to ensure config changes have been reflected
23
- if (isNode(cachedResult))
24
- scopeCache[def] = ctx.$.bindReference(cachedResult);
25
- else {
26
- // update node element of optional or defaultable tuple
27
- ;
28
- cachedResult[0] = ctx.$.bindReference(cachedResult[0]);
29
- }
30
- return scopeCache[def];
31
- }
32
- // if we're parsing from scratch, we don't need to worry about binding
15
+ const scopeCache = (parseCache[ctx.$.id] ??= {});
33
16
  return (scopeCache[def] ??= parseString(def, ctx));
34
17
  }
35
18
  return hasDomain(def, "object") ?
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.1",
4
+ "version": "2.0.3",
5
5
  "license": "MIT",
6
6
  "repository": {
7
7
  "type": "git",
@@ -34,8 +34,8 @@
34
34
  "out"
35
35
  ],
36
36
  "dependencies": {
37
- "@ark/util": "0.36.0",
38
- "@ark/schema": "0.36.0"
37
+ "@ark/schema": "0.38.0",
38
+ "@ark/util": "0.38.0"
39
39
  },
40
40
  "publishConfig": {
41
41
  "access": "public"