arktype 2.0.0-rc.13 → 2.0.0-rc.14
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.
|
@@ -128,7 +128,7 @@ type distillMappable<o, opts extends distill.Options> = opts["endpoint"] extends
|
|
|
128
128
|
[k in keyof o as k extends inferredOptionalKeyOf<o> ? k : never]?: _distill<o[k], opts>;
|
|
129
129
|
}>;
|
|
130
130
|
type distillIo<i, o extends Out, opts extends distill.Options> = opts["endpoint"] extends "in" ? _distill<i, opts> : opts["endpoint"] extends "out.introspectable" ? o extends To<infer validatedOut> ? _distill<validatedOut, opts> : unknown : opts["endpoint"] extends "out" ? _distill<o[1], opts> : _distill<o[1], opts> extends infer r ? o extends To ? (In: i) => To<r> : (In: i) => Out<r> : never;
|
|
131
|
-
type inferredOptionalOrDefaultKeyOf<o> = inferredDefaultKeyOf<o> | inferredOptionalKeyOf<o>;
|
|
131
|
+
export type inferredOptionalOrDefaultKeyOf<o> = inferredDefaultKeyOf<o> | inferredOptionalKeyOf<o>;
|
|
132
132
|
type inExtends<v, t> = [
|
|
133
133
|
v
|
|
134
134
|
] extends [anyOrNever] ? false : [v] extends [t] ? true : [v] extends [InferredMorph<infer i>] ? inExtends<i, t> : false;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Module, Submodule } from "../../module.ts";
|
|
2
|
+
import type { Predicate, of } from "../inference.ts";
|
|
3
|
+
export declare const base64: Module<{
|
|
4
|
+
root: unknown;
|
|
5
|
+
url: unknown;
|
|
6
|
+
}>;
|
|
7
|
+
declare namespace string {
|
|
8
|
+
type base64 = of<string, Predicate<"base64">>;
|
|
9
|
+
namespace base64 {
|
|
10
|
+
type url = of<string, Predicate<"base64.url">>;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export declare namespace base64 {
|
|
14
|
+
type module = Module<submodule>;
|
|
15
|
+
type submodule = Submodule<$>;
|
|
16
|
+
type $ = {
|
|
17
|
+
root: string.base64;
|
|
18
|
+
url: string.base64.url;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { arkModule } from "../utils.js";
|
|
2
|
+
import { regexStringNode } from "./utils.js";
|
|
3
|
+
export const base64 = arkModule({
|
|
4
|
+
root: regexStringNode(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/, "base64-encoded"),
|
|
5
|
+
url: regexStringNode(/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2}(?:==|%3D%3D)?|[A-Za-z0-9_-]{3}(?:=|%3D)?)?$/, "base64url-encoded")
|
|
6
|
+
});
|
|
@@ -25,29 +25,30 @@ const root = rootSchema({
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
});
|
|
28
|
+
const parseJson = (s, ctx) => {
|
|
29
|
+
if (s.length === 0) {
|
|
30
|
+
return ctx.error({
|
|
31
|
+
code: "predicate",
|
|
32
|
+
expected: jsonStringDescription,
|
|
33
|
+
actual: "empty"
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
return JSON.parse(s);
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
return ctx.error({
|
|
41
|
+
code: "predicate",
|
|
42
|
+
expected: jsonStringDescription,
|
|
43
|
+
problem: writeJsonSyntaxErrorProblem(e)
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
};
|
|
28
47
|
export const json = arkModule({
|
|
29
48
|
root,
|
|
30
49
|
parse: rootSchema({
|
|
31
50
|
in: "string",
|
|
32
|
-
morphs:
|
|
33
|
-
if (s.length === 0) {
|
|
34
|
-
return ctx.error({
|
|
35
|
-
code: "predicate",
|
|
36
|
-
expected: jsonStringDescription,
|
|
37
|
-
actual: "empty"
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
try {
|
|
41
|
-
return JSON.parse(s);
|
|
42
|
-
}
|
|
43
|
-
catch (e) {
|
|
44
|
-
return ctx.error({
|
|
45
|
-
code: "predicate",
|
|
46
|
-
expected: jsonStringDescription,
|
|
47
|
-
problem: writeJsonSyntaxErrorProblem(e)
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
+
morphs: parseJson,
|
|
51
52
|
declaredOut: intrinsic.json
|
|
52
53
|
})
|
|
53
54
|
});
|
|
@@ -2,6 +2,7 @@ import type { Module, Submodule } from "../../module.ts";
|
|
|
2
2
|
import type { AtLeastLength, AtMostLength, Default, ExactlyLength, LessThanLength, MoreThanLength, Narrowed, Optional, Predicate, constraint, of } from "../inference.ts";
|
|
3
3
|
import { alpha } from "./alpha.ts";
|
|
4
4
|
import { alphanumeric } from "./alphanumeric.ts";
|
|
5
|
+
import { base64 } from "./base64.ts";
|
|
5
6
|
import { capitalize } from "./capitalize.ts";
|
|
6
7
|
import { creditCard } from "./creditCard.ts";
|
|
7
8
|
import { stringDate } from "./date.ts";
|
|
@@ -42,7 +43,12 @@ export declare const string: Module<{
|
|
|
42
43
|
}>;
|
|
43
44
|
alpha: unknown;
|
|
44
45
|
alphanumeric: unknown;
|
|
46
|
+
url: Submodule<url.submodule>;
|
|
45
47
|
json: Submodule<stringJson.submodule>;
|
|
48
|
+
base64: Submodule<{
|
|
49
|
+
root: unknown;
|
|
50
|
+
url: unknown;
|
|
51
|
+
}>;
|
|
46
52
|
creditCard: unknown;
|
|
47
53
|
integer: Submodule<stringInteger.submodule>;
|
|
48
54
|
date: Submodule<stringDate.submodule>;
|
|
@@ -51,7 +57,6 @@ export declare const string: Module<{
|
|
|
51
57
|
ip: Submodule<ip.submodule>;
|
|
52
58
|
numeric: Submodule<stringNumeric.submodule>;
|
|
53
59
|
semver: unknown;
|
|
54
|
-
url: Submodule<url.submodule>;
|
|
55
60
|
uuid: Submodule<{
|
|
56
61
|
root: string.matching<string> | "00000000-0000-0000-0000-000000000000" | "ffffffff-ffff-ffff-ffff-ffffffffffff";
|
|
57
62
|
v4: unknown;
|
|
@@ -89,6 +94,7 @@ export declare namespace string {
|
|
|
89
94
|
root: string;
|
|
90
95
|
alpha: alpha;
|
|
91
96
|
alphanumeric: alphanumeric;
|
|
97
|
+
base64: base64.submodule;
|
|
92
98
|
digits: digits;
|
|
93
99
|
numeric: stringNumeric.submodule;
|
|
94
100
|
integer: stringInteger.submodule;
|
|
@@ -2,6 +2,7 @@ import { intrinsic } from "@ark/schema";
|
|
|
2
2
|
import { arkModule } from "../utils.js";
|
|
3
3
|
import { alpha } from "./alpha.js";
|
|
4
4
|
import { alphanumeric } from "./alphanumeric.js";
|
|
5
|
+
import { base64 } from "./base64.js";
|
|
5
6
|
import { capitalize } from "./capitalize.js";
|
|
6
7
|
import { creditCard } from "./creditCard.js";
|
|
7
8
|
import { stringDate } from "./date.js";
|
|
@@ -24,6 +25,7 @@ export const string = arkModule({
|
|
|
24
25
|
integer,
|
|
25
26
|
alpha,
|
|
26
27
|
alphanumeric,
|
|
28
|
+
base64,
|
|
27
29
|
digits,
|
|
28
30
|
semver,
|
|
29
31
|
ip,
|
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.
|
|
4
|
+
"version": "2.0.0-rc.14",
|
|
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.
|
|
38
|
-
"@ark/schema": "0.
|
|
37
|
+
"@ark/util": "0.16.0",
|
|
38
|
+
"@ark/schema": "0.16.0"
|
|
39
39
|
},
|
|
40
40
|
"publishConfig": {
|
|
41
41
|
"access": "public"
|