arktype 2.0.0-rc.0 → 2.0.0-rc.2
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 +12 -7
- package/out/generic.js +3 -3
- package/out/index.d.ts +2 -2
- package/out/index.js +1 -0
- package/out/keywords/ark.d.ts +13 -7
- package/out/keywords/ark.js +11 -5
- package/out/keywords/{builtin.d.ts → builtins.d.ts} +9 -5
- package/out/keywords/{builtin.js → builtins.js} +1 -1
- package/out/keywords/constructors/Array.d.ts +11 -7
- package/out/keywords/constructors/Array.js +1 -1
- package/out/keywords/constructors/FormData.d.ts +12 -6
- package/out/keywords/constructors/FormData.js +15 -2
- package/out/keywords/constructors/TypedArray.d.ts +18 -14
- package/out/keywords/constructors/constructors.d.ts +21 -31
- package/out/keywords/constructors/constructors.js +11 -26
- package/out/keywords/number/number.d.ts +5 -3
- package/out/keywords/string/capitalize.d.ts +10 -9
- package/out/keywords/string/date.d.ts +30 -25
- package/out/keywords/string/date.js +1 -1
- package/out/keywords/string/integer.d.ts +10 -9
- package/out/keywords/string/ip.d.ts +11 -11
- package/out/keywords/string/json.d.ts +10 -9
- package/out/keywords/string/lower.d.ts +10 -9
- package/out/keywords/string/normalize.d.ts +49 -29
- package/out/keywords/string/numeric.d.ts +10 -9
- package/out/keywords/string/string.d.ts +73 -18
- package/out/keywords/string/string.js +2 -2
- package/out/keywords/string/trim.d.ts +10 -9
- package/out/keywords/string/upper.d.ts +10 -9
- package/out/keywords/string/url.d.ts +10 -9
- package/out/keywords/string/uuid.d.ts +17 -13
- package/out/keywords/ts.d.ts +33 -22
- package/out/keywords/ts.js +15 -13
- package/out/parser/definition.d.ts +2 -4
- package/out/parser/objectLiteral.d.ts +13 -1
- package/out/parser/semantic/bounds.d.ts +3 -1
- package/out/parser/semantic/default.d.ts +3 -2
- package/out/parser/semantic/infer.d.ts +20 -14
- package/out/parser/semantic/utils.d.ts +2 -2
- package/out/parser/semantic/validate.d.ts +5 -8
- package/out/parser/string/shift/operand/enclosed.d.ts +3 -1
- package/out/parser/string/shift/operand/unenclosed.d.ts +6 -7
- package/out/parser/string/shift/operator/bounds.d.ts +6 -5
- package/out/parser/string/shift/operator/operator.js +2 -2
- package/out/parser/string/shift/scanner.d.ts +3 -1
- package/out/parser/string/shift/scanner.js +2 -2
- package/out/parser/string/string.d.ts +3 -2
- package/out/scope.d.ts +18 -4
- package/out/scope.js +15 -2
- package/out/subtypes/base.d.ts +2 -1
- package/out/type.d.ts +5 -2
- package/out/type.js +12 -6
- package/package.json +3 -3
package/out/generic.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import { type array, type Callable, type conform, type ErrorMessage, type ErrorType, type Hkt, type WhiteSpaceToken } from "@ark/util";
|
|
1
|
+
import { GenericRoot, type arkKind, type GenericAst, type GenericParamAst, type GenericParamDef, type genericParamNames, type LazyGenericBody } from "@ark/schema";
|
|
2
|
+
import { type array, type Callable, type conform, type ErrorMessage, type ErrorType, type Hkt, type Json, type WhiteSpaceToken } from "@ark/util";
|
|
3
3
|
import type { inferDefinition, validateDefinition } from "./parser/definition.ts";
|
|
4
4
|
import type { inferAstRoot } from "./parser/semantic/infer.ts";
|
|
5
5
|
import type { validateAst } from "./parser/semantic/validate.ts";
|
|
@@ -118,7 +118,10 @@ export interface Generic<params extends array<GenericParamAst> = array<GenericPa
|
|
|
118
118
|
$: Scope<$>;
|
|
119
119
|
arg$: Scope<arg$>;
|
|
120
120
|
internal: GenericRoot;
|
|
121
|
+
json: Json;
|
|
121
122
|
}
|
|
123
|
+
export type GenericConstructor<params extends array<GenericParamAst> = array<GenericParamAst>, bodyDef = unknown, $ = {}, arg$ = {}> = new () => Generic<params, bodyDef, $, arg$>;
|
|
124
|
+
export declare const Generic: GenericConstructor;
|
|
122
125
|
export type GenericDeclaration<name extends string = string, params extends ParameterString = ParameterString> = `${name}${params}`;
|
|
123
126
|
export type parseValidGenericParams<def extends ParameterString, $> = conform<parseGenericParams<extractParams<def>, $>, array<GenericParamAst>>;
|
|
124
127
|
export declare const emptyGenericParameterMessage = "An empty string is not a valid generic parameter name";
|
|
@@ -126,14 +129,14 @@ export type emptyGenericParameterMessage = typeof emptyGenericParameterMessage;
|
|
|
126
129
|
export declare const parseGenericParams: (def: string, ctx: ParseContext) => array<GenericParamDef>;
|
|
127
130
|
export type parseGenericParams<def extends string, $> = parseNextNameChar<Scanner.skipWhitespace<def>, "", [
|
|
128
131
|
], $>;
|
|
129
|
-
type ParamsTerminator = WhiteSpaceToken | ","
|
|
132
|
+
type ParamsTerminator = WhiteSpaceToken | ",";
|
|
130
133
|
declare const parseName: (scanner: Scanner, result: GenericParamDef[], ctx: ParseContext) => GenericParamDef[];
|
|
131
134
|
type parseName<unscanned extends string, result extends array<GenericParamAst>, $> = parseNextNameChar<Scanner.skipWhitespace<unscanned>, "", result, $>;
|
|
132
|
-
type parseNextNameChar<unscanned extends string, name extends string, result extends array<GenericParamAst>, $> = unscanned extends `${infer lookahead}${infer nextUnscanned}` ? lookahead extends ParamsTerminator ? name extends "" ? ErrorMessage<emptyGenericParameterMessage> : lookahead extends "," ? parseName<nextUnscanned, [...result, [name, unknown]], $> : lookahead extends
|
|
135
|
+
type parseNextNameChar<unscanned extends string, name extends string, result extends array<GenericParamAst>, $> = unscanned extends `${infer lookahead}${infer nextUnscanned}` ? lookahead extends ParamsTerminator ? name extends "" ? ErrorMessage<emptyGenericParameterMessage> : lookahead extends "," ? parseName<nextUnscanned, [...result, [name, unknown]], $> : lookahead extends WhiteSpaceToken ? _parseOptionalConstraint<nextUnscanned, name, result, $> : never : parseNextNameChar<nextUnscanned, `${name}${lookahead}`, result, $> : name extends "" ? result : [...result, [name, unknown]];
|
|
133
136
|
declare const extendsToken = "extends ";
|
|
134
|
-
type
|
|
137
|
+
type extendsToken = typeof extendsToken;
|
|
135
138
|
declare const _parseOptionalConstraint: (scanner: Scanner, name: string, result: GenericParamDef[], ctx: ParseContext) => GenericParamDef[];
|
|
136
|
-
type _parseOptionalConstraint<unscanned extends string, name extends string, result extends array<GenericParamAst>, $> = Scanner.skipWhitespace<unscanned> extends (`${
|
|
139
|
+
type _parseOptionalConstraint<unscanned extends string, name extends string, result extends array<GenericParamAst>, $> = Scanner.skipWhitespace<unscanned> extends (`${extendsToken}${infer nextUnscanned}`) ? parseUntilFinalizer<state.initialize<nextUnscanned>, $, {}> extends (infer finalArgState extends StaticState) ? validateAst<finalArgState["root"], $, {}> extends (infer e extends ErrorMessage) ? e : parseName<finalArgState["unscanned"], [
|
|
137
140
|
...result,
|
|
138
141
|
[name, inferAstRoot<finalArgState["root"], $, {}>]
|
|
139
142
|
], $> : never : parseName<Scanner.skipWhitespace<unscanned> extends `,${infer nextUnscanned}` ? nextUnscanned : unscanned, [
|
|
@@ -149,7 +152,9 @@ export type genericParamDefsToAst<defs extends array<GenericParamDef>, $> = [
|
|
|
149
152
|
[i in keyof defs]: genericParamDefToAst<defs[i], $>;
|
|
150
153
|
}
|
|
151
154
|
];
|
|
152
|
-
export type GenericParser<$ = {}> = <const paramsDef extends array<GenericParamDef>>(...params:
|
|
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, $>, $>;
|
|
153
158
|
interface GenericBodyParser<params extends array<GenericParamAst>, $> {
|
|
154
159
|
<const body>(body: validateDefinition<body, $, baseGenericConstraints<params>>): Generic<params, body, $, $>;
|
|
155
160
|
<hkt extends Hkt.constructor>(instantiateDef: LazyGenericBody<baseGenericResolutions<params, $>>, hkt: hkt): Generic<params, InstanceType<hkt>, $, $>;
|
package/out/generic.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import { GenericRoot } from "@ark/schema";
|
|
1
2
|
import { throwParseError } from "@ark/util";
|
|
2
3
|
import { DynamicState } from "./parser/string/reduce/dynamic.js";
|
|
3
4
|
import { Scanner } from "./parser/string/shift/scanner.js";
|
|
4
5
|
import { parseUntilFinalizer } from "./parser/string/string.js";
|
|
6
|
+
export const Generic = GenericRoot;
|
|
5
7
|
export const emptyGenericParameterMessage = "An empty string is not a valid generic parameter name";
|
|
6
8
|
export const parseGenericParams = (def, ctx) => parseName(new Scanner(def), [], ctx);
|
|
7
9
|
const parseName = (scanner, result, ctx) => {
|
|
@@ -20,9 +22,7 @@ const parseName = (scanner, result, ctx) => {
|
|
|
20
22
|
const extendsToken = "extends ";
|
|
21
23
|
const _parseOptionalConstraint = (scanner, name, result, ctx) => {
|
|
22
24
|
scanner.shiftUntilNonWhitespace();
|
|
23
|
-
if (scanner.
|
|
24
|
-
scanner.shift();
|
|
25
|
-
else if (scanner.unscanned.startsWith(extendsToken))
|
|
25
|
+
if (scanner.unscanned.startsWith(extendsToken))
|
|
26
26
|
scanner.jumpForward(extendsToken.length);
|
|
27
27
|
else {
|
|
28
28
|
// if we don't have a contraining token here, return now so we can
|
package/out/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { ArkError, ArkErrors, type ArkConfig, type ArkScopeConfig, type JsonSchema } from "@ark/schema";
|
|
2
2
|
export { Hkt } from "@ark/util";
|
|
3
|
-
export
|
|
4
|
-
export { ambient, ark, declare, define, generic, type } from "./keywords/ark.ts";
|
|
3
|
+
export { Generic } from "./generic.ts";
|
|
4
|
+
export { ambient, ark, declare, define, generic, type, type Ark } from "./keywords/ark.ts";
|
|
5
5
|
export { Module, type BoundModule, type Submodule } from "./module.ts";
|
|
6
6
|
export { module, scope, type Scope, type inferScope, type validateScope } from "./scope.ts";
|
|
7
7
|
export { Type, type inferAmbient, type inferTypeRoot, type validateAmbient, type validateTypeRoot } from "./type.ts";
|
package/out/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { ArkError, ArkErrors } from "@ark/schema";
|
|
2
2
|
export { Hkt } from "@ark/util";
|
|
3
|
+
export { Generic } from "./generic.js";
|
|
3
4
|
export { ambient, ark, declare, define, generic, type } from "./keywords/ark.js";
|
|
4
5
|
export { Module } from "./module.js";
|
|
5
6
|
export { module, scope } from "./scope.js";
|
package/out/keywords/ark.d.ts
CHANGED
|
@@ -1,23 +1,29 @@
|
|
|
1
|
-
import type { ArkErrors } from "@ark/schema";
|
|
1
|
+
import type { ArkErrors, arkKind } from "@ark/schema";
|
|
2
2
|
import type { inferred } from "@ark/util";
|
|
3
3
|
import type { GenericParser } from "../generic.ts";
|
|
4
|
-
import type { Module } from "../module.ts";
|
|
4
|
+
import type { BoundModule, Module } from "../module.ts";
|
|
5
5
|
import { type Scope } from "../scope.ts";
|
|
6
6
|
import type { DeclarationParser, DefinitionParser, TypeParser } from "../type.ts";
|
|
7
|
-
import {
|
|
7
|
+
import { arkBuiltins } from "./builtins.ts";
|
|
8
8
|
import { arkPrototypes } from "./constructors/constructors.ts";
|
|
9
9
|
import { number } from "./number/number.ts";
|
|
10
10
|
import { string } from "./string/string.ts";
|
|
11
|
-
import {
|
|
12
|
-
export interface Ark extends Omit<Ark.keywords, keyof Ark.
|
|
11
|
+
import { arkTsGenerics, arkTsKeywords } from "./ts.ts";
|
|
12
|
+
export interface Ark extends Omit<Ark.keywords, keyof Ark.wrapped>, Ark.wrapped {
|
|
13
13
|
}
|
|
14
14
|
export declare namespace Ark {
|
|
15
|
-
interface keywords extends
|
|
15
|
+
interface keywords extends arkTsKeywords.$, arkTsGenerics.$, arkPrototypes.keywords, arkBuiltins.$ {
|
|
16
16
|
}
|
|
17
|
-
interface
|
|
17
|
+
interface wrapped extends arkPrototypes.wrapped {
|
|
18
18
|
string: string.submodule;
|
|
19
19
|
number: number.submodule;
|
|
20
20
|
}
|
|
21
|
+
interface typeAttachments extends arkTsKeywords.$ {
|
|
22
|
+
Key: arkBuiltins.$["Key"];
|
|
23
|
+
Record: arkTsGenerics.$["Record"];
|
|
24
|
+
}
|
|
25
|
+
interface boundTypeAttachments<$> extends Omit<BoundModule<typeAttachments, $>, arkKind> {
|
|
26
|
+
}
|
|
21
27
|
}
|
|
22
28
|
export declare const ambient: Scope<Ark>;
|
|
23
29
|
export declare const ark: Module<Ark>;
|
package/out/keywords/ark.js
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
1
|
-
import { scope } from "../scope.js";
|
|
2
|
-
import {
|
|
1
|
+
import { $arkTypeRegistry, scope } from "../scope.js";
|
|
2
|
+
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 {
|
|
6
|
+
import { arkTsGenerics, arkTsKeywords } from "./ts.js";
|
|
7
|
+
$arkTypeRegistry.typeAttachments = {
|
|
8
|
+
...arkTsKeywords,
|
|
9
|
+
Key: arkBuiltins.Key,
|
|
10
|
+
Record: arkTsGenerics.Record
|
|
11
|
+
};
|
|
7
12
|
export const ambient = scope({
|
|
8
|
-
...
|
|
13
|
+
...arkTsKeywords,
|
|
14
|
+
...arkTsGenerics,
|
|
9
15
|
...arkPrototypes,
|
|
10
|
-
...
|
|
16
|
+
...arkBuiltins,
|
|
11
17
|
string,
|
|
12
18
|
number
|
|
13
19
|
}, { prereducedAliases: true, ambient: true });
|
|
@@ -5,9 +5,13 @@ declare class MergeHkt extends Hkt<[base: object, props: object]> {
|
|
|
5
5
|
body: util.merge<this[0], this[1]>;
|
|
6
6
|
}
|
|
7
7
|
declare const Merge: import("@ark/schema").GenericRoot<readonly [["base", object], ["props", object]], MergeHkt>;
|
|
8
|
-
export declare const
|
|
9
|
-
export type
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
export declare const arkBuiltins: arkBuiltins;
|
|
9
|
+
export type arkBuiltins = Module<arkBuiltins.$>;
|
|
10
|
+
export declare namespace arkBuiltins {
|
|
11
|
+
type submodule = Submodule<$>;
|
|
12
|
+
type $ = {
|
|
13
|
+
Key: Key;
|
|
14
|
+
Merge: typeof Merge.t;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
13
17
|
export {};
|
|
@@ -4,7 +4,7 @@ import { submodule } from "./utils.js";
|
|
|
4
4
|
class MergeHkt extends Hkt {
|
|
5
5
|
}
|
|
6
6
|
const Merge = genericNode(["base", intrinsic.object], ["props", intrinsic.object])(args => args.base.merge(args.props), MergeHkt);
|
|
7
|
-
export const
|
|
7
|
+
export const arkBuiltins = submodule({
|
|
8
8
|
Key: intrinsic.key,
|
|
9
9
|
Merge
|
|
10
10
|
});
|
|
@@ -5,12 +5,16 @@ declare class liftFromHkt extends Hkt<[element: unknown]> {
|
|
|
5
5
|
body: liftArray<this[0]> extends infer lifted ? (In: this[0] | lifted) => To<lifted> : never;
|
|
6
6
|
}
|
|
7
7
|
declare const liftFrom: import("@ark/schema").GenericRoot<readonly [["element", unknown]], liftFromHkt>;
|
|
8
|
-
export declare const
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
export declare const arkArray: arkArray.module;
|
|
9
|
+
export declare namespace arkArray {
|
|
10
|
+
type module = Module<submodule>;
|
|
11
|
+
type submodule = Submodule<$>;
|
|
12
|
+
type $ = {
|
|
13
|
+
$root: unknown[];
|
|
14
|
+
readonly: readonly unknown[];
|
|
15
|
+
index: NonNegativeIntegerString;
|
|
16
|
+
liftFrom: typeof liftFrom.t;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
15
19
|
export type NonNegativeIntegerString = `${Digit}` | (`${Exclude<Digit, 0>}${string}` & `${bigint}`);
|
|
16
20
|
export {};
|
|
@@ -11,7 +11,7 @@ const liftFrom = genericNode("element")(args => {
|
|
|
11
11
|
.pipe(liftArray)
|
|
12
12
|
.distribute(branch => branch.assertHasKind("morph").declareOut(lifted), rootNode);
|
|
13
13
|
}, liftFromHkt);
|
|
14
|
-
export const
|
|
14
|
+
export const arkArray = submodule({
|
|
15
15
|
$root: intrinsic.Array,
|
|
16
16
|
readonly: "$root",
|
|
17
17
|
index: intrinsic.nonNegativeIntegerString,
|
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import type { Module, Submodule } from "../../module.ts";
|
|
2
|
-
import type {
|
|
2
|
+
import type { To } from "../ast.ts";
|
|
3
3
|
export type FormDataValue = string | File;
|
|
4
4
|
export type ParsedFormData = Record<string, FormDataValue | FormDataValue[]>;
|
|
5
|
-
export declare const
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
export declare const arkFormData: arkFormData.module;
|
|
6
|
+
export declare namespace arkFormData {
|
|
7
|
+
type module = Module<submodule>;
|
|
8
|
+
type submodule = Submodule<$>;
|
|
9
|
+
type $ = {
|
|
10
|
+
$root: FormData;
|
|
11
|
+
value: FormDataValue;
|
|
12
|
+
parse: (In: FormData) => To<ParsedFormData>;
|
|
13
|
+
parsed: ParsedFormData;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
import { rootNode } from "@ark/schema";
|
|
2
2
|
import { registry } from "@ark/util";
|
|
3
3
|
import { submodule } from "../utils.js";
|
|
4
|
-
|
|
4
|
+
const value = rootNode(["string", registry.FileConstructor]);
|
|
5
|
+
const parsedFormDataValue = value.or(value.array());
|
|
6
|
+
const parsed = rootNode({
|
|
7
|
+
meta: "an object representing parsed form data",
|
|
8
|
+
domain: "object",
|
|
9
|
+
index: {
|
|
10
|
+
signature: "string",
|
|
11
|
+
value: parsedFormDataValue
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
export const arkFormData = submodule({
|
|
5
15
|
$root: ["instanceof", FormData],
|
|
16
|
+
value,
|
|
17
|
+
parsed,
|
|
6
18
|
parse: rootNode({
|
|
7
19
|
in: FormData,
|
|
8
20
|
morphs: (data) => {
|
|
@@ -20,6 +32,7 @@ export const FormDataModule = submodule({
|
|
|
20
32
|
result[k] = v;
|
|
21
33
|
}
|
|
22
34
|
return result;
|
|
23
|
-
}
|
|
35
|
+
},
|
|
36
|
+
declaredOut: parsed
|
|
24
37
|
})
|
|
25
38
|
});
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import type { Module, Submodule } from "../../module.ts";
|
|
2
|
-
export declare const TypedArray:
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
export declare const TypedArray: TypedArray.module;
|
|
3
|
+
export declare namespace TypedArray {
|
|
4
|
+
type module = Module<TypedArray.$>;
|
|
5
|
+
type submodule = Submodule<$>;
|
|
6
|
+
type $ = {
|
|
7
|
+
Int8: Int8Array;
|
|
8
|
+
Uint8: Uint8Array;
|
|
9
|
+
Uint8Clamped: Uint8ClampedArray;
|
|
10
|
+
Int16: Int16Array;
|
|
11
|
+
Uint16: Uint16Array;
|
|
12
|
+
Int32: Int32Array;
|
|
13
|
+
Uint32: Uint32Array;
|
|
14
|
+
Float32: Float32Array;
|
|
15
|
+
Float64: Float64Array;
|
|
16
|
+
BigInt64: BigInt64Array;
|
|
17
|
+
BigUint64: BigUint64Array;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -1,41 +1,31 @@
|
|
|
1
|
+
import { type EcmascriptObjects, type PlatformObjects } from "@ark/util";
|
|
1
2
|
import type { Module, Submodule } from "../../module.ts";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
3
|
+
import { arkArray } from "./Array.ts";
|
|
4
|
+
import { arkFormData } from "./FormData.ts";
|
|
4
5
|
import { TypedArray } from "./TypedArray.ts";
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
declare const omittedPrototypes: {
|
|
7
|
+
Boolean: 1;
|
|
8
|
+
Number: 1;
|
|
9
|
+
String: 1;
|
|
10
|
+
};
|
|
11
|
+
export declare const arkPrototypes: arkPrototypes.module;
|
|
7
12
|
export declare namespace arkPrototypes {
|
|
13
|
+
type module = Module<submodule>;
|
|
8
14
|
type submodule = Submodule<$>;
|
|
9
|
-
interface
|
|
15
|
+
interface keywords extends ecmascript, platform {
|
|
10
16
|
}
|
|
11
|
-
interface
|
|
12
|
-
Array: ArrayModule;
|
|
13
|
-
TypedArray: TypedArray;
|
|
17
|
+
interface $ extends Omit<keywords, keyof wrapped>, wrapped {
|
|
14
18
|
}
|
|
15
|
-
|
|
16
|
-
Array:
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
WeakMap: WeakMap<object, unknown>;
|
|
24
|
-
WeakSet: WeakSet<object>;
|
|
25
|
-
Promise: Promise<unknown>;
|
|
26
|
-
};
|
|
27
|
-
type platform = {
|
|
28
|
-
ArrayBuffer: ArrayBuffer;
|
|
29
|
-
Blob: Blob;
|
|
30
|
-
File: File;
|
|
31
|
-
FormData: FormDataModule;
|
|
32
|
-
Headers: Headers;
|
|
33
|
-
Request: Request;
|
|
34
|
-
Response: Response;
|
|
35
|
-
URL: URL;
|
|
36
|
-
};
|
|
37
|
-
interface instances extends ecmascript, platform, TypedArray {
|
|
19
|
+
interface wrapped {
|
|
20
|
+
Array: arkArray.submodule;
|
|
21
|
+
TypedArray: TypedArray.submodule;
|
|
22
|
+
FormData: arkFormData.submodule;
|
|
23
|
+
}
|
|
24
|
+
type ecmascript = Omit<EcmascriptObjects, keyof typeof omittedPrototypes>;
|
|
25
|
+
type platform = PlatformObjects;
|
|
26
|
+
interface instances extends ecmascript, platform {
|
|
38
27
|
}
|
|
39
28
|
type instanceOf<name extends keyof instances = keyof instances> = instances[name];
|
|
40
29
|
type instanceOfExcluding<name extends keyof instances = keyof instances> = instances[Exclude<keyof instances, name>];
|
|
41
30
|
}
|
|
31
|
+
export {};
|
|
@@ -1,31 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ecmascriptConstructors, flatMorph, platformConstructors } from "@ark/util";
|
|
2
2
|
import { submodule } from "../utils.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { arkArray } from "./Array.js";
|
|
4
|
+
import { arkFormData } from "./FormData.js";
|
|
5
5
|
import { TypedArray } from "./TypedArray.js";
|
|
6
|
+
const omittedPrototypes = {
|
|
7
|
+
Boolean: 1,
|
|
8
|
+
Number: 1,
|
|
9
|
+
String: 1
|
|
10
|
+
};
|
|
6
11
|
export const arkPrototypes = submodule({
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
Array: ArrayModule,
|
|
10
|
-
Date: ["instanceof", Date],
|
|
11
|
-
Error: ["instanceof", Error],
|
|
12
|
-
Function: ["instanceof", Function],
|
|
13
|
-
Map: ["instanceof", Map],
|
|
14
|
-
RegExp: ["instanceof", RegExp],
|
|
15
|
-
Set: ["instanceof", Set],
|
|
16
|
-
WeakMap: ["instanceof", WeakMap],
|
|
17
|
-
WeakSet: ["instanceof", WeakSet],
|
|
18
|
-
Promise: ["instanceof", Promise],
|
|
12
|
+
...flatMorph({ ...ecmascriptConstructors, ...platformConstructors }, (k, v) => (k in omittedPrototypes ? [] : [k, ["instanceof", v]])),
|
|
13
|
+
Array: arkArray,
|
|
19
14
|
TypedArray,
|
|
20
|
-
|
|
21
|
-
// See https://developer.mozilla.org/en-US/docs/Web/API
|
|
22
|
-
// Must be implemented in Node etc. as well as the browser to include here
|
|
23
|
-
ArrayBuffer: ["instanceof", ArrayBuffer],
|
|
24
|
-
Blob: ["instanceof", Blob],
|
|
25
|
-
File: ["instanceof", registry.FileConstructor],
|
|
26
|
-
FormData: FormDataModule,
|
|
27
|
-
Headers: ["instanceof", Headers],
|
|
28
|
-
Request: ["instanceof", Request],
|
|
29
|
-
Response: ["instanceof", Response],
|
|
30
|
-
URL: ["instanceof", URL]
|
|
15
|
+
FormData: arkFormData
|
|
31
16
|
});
|
|
@@ -3,7 +3,7 @@ import type { Module, Submodule } from "../../module.ts";
|
|
|
3
3
|
import type { AtLeast, AtMost, Branded, constrain, Constraints, DivisibleBy, LessThan, MoreThan, Narrowed, normalizePrimitiveConstraintRoot } from "../ast.ts";
|
|
4
4
|
import { epoch } from "./epoch.ts";
|
|
5
5
|
import { integer } from "./integer.ts";
|
|
6
|
-
export declare const number:
|
|
6
|
+
export declare const number: number.module;
|
|
7
7
|
export declare namespace number {
|
|
8
8
|
type atLeast<rule> = constrain<number, AtLeast<rule>>;
|
|
9
9
|
type moreThan<rule> = constrain<number, MoreThan<rule>>;
|
|
@@ -18,9 +18,11 @@ export declare namespace number {
|
|
|
18
18
|
} ? moreThan<rule> : atLeast<rule> : kind extends "max" ? schema extends {
|
|
19
19
|
exclusive: true;
|
|
20
20
|
} ? lessThan<rule> : atMost<rule> : kind extends "divisor" ? divisibleBy<rule> : narrowed : never;
|
|
21
|
-
type
|
|
21
|
+
type module = Module<submodule>;
|
|
22
|
+
type submodule = Submodule<$>;
|
|
23
|
+
type $ = {
|
|
22
24
|
$root: number;
|
|
23
25
|
epoch: epoch;
|
|
24
26
|
integer: integer;
|
|
25
|
-
}
|
|
27
|
+
};
|
|
26
28
|
}
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import type { Submodule } from "../../module.ts";
|
|
1
|
+
import type { Module, Submodule } from "../../module.ts";
|
|
2
2
|
import type { Branded, constrain, To } from "../ast.ts";
|
|
3
3
|
declare namespace string {
|
|
4
4
|
type capitalized = constrain<string, Branded<"capitalized">>;
|
|
5
5
|
}
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
6
|
+
export declare const capitalize: capitalize.module;
|
|
7
|
+
export declare namespace capitalize {
|
|
8
|
+
type module = Module<submodule>;
|
|
9
|
+
type submodule = Submodule<$>;
|
|
10
|
+
type $ = {
|
|
11
|
+
$root: (In: string) => To<string.capitalized>;
|
|
12
|
+
preformatted: string.capitalized;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
14
15
|
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { Submodule } from "../../module.ts";
|
|
1
|
+
import type { Module, Submodule } from "../../module.ts";
|
|
2
|
+
import type { type } from "../ark.ts";
|
|
2
3
|
import type { Branded, To, constrain } from "../ast.ts";
|
|
3
4
|
type DayDelimiter = "." | "/" | "-";
|
|
4
5
|
type DayPart = DayPatterns[PartKey];
|
|
@@ -20,18 +21,6 @@ export type DateOptions = {
|
|
|
20
21
|
};
|
|
21
22
|
export declare const iso8601Matcher: RegExp;
|
|
22
23
|
export declare const tryParseDatePattern: (data: string, opts?: DateOptions) => Date | string;
|
|
23
|
-
export declare const date: import("../../module.ts").Module<{
|
|
24
|
-
$root: object;
|
|
25
|
-
epoch: Submodule<{
|
|
26
|
-
$root: object;
|
|
27
|
-
parse: object;
|
|
28
|
-
}>;
|
|
29
|
-
parse: object;
|
|
30
|
-
iso: Submodule<{
|
|
31
|
-
$root: object;
|
|
32
|
-
parse: object;
|
|
33
|
-
}>;
|
|
34
|
-
}>;
|
|
35
24
|
declare namespace string {
|
|
36
25
|
type date = constrain<string, Branded<"date">>;
|
|
37
26
|
namespace date {
|
|
@@ -39,16 +28,32 @@ declare namespace string {
|
|
|
39
28
|
type iso = constrain<string, Branded<"date.iso">>;
|
|
40
29
|
}
|
|
41
30
|
}
|
|
42
|
-
export
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
31
|
+
export declare const stringDate: stringDate.module;
|
|
32
|
+
export declare namespace stringDate {
|
|
33
|
+
type module = Module<stringDate.submodule>;
|
|
34
|
+
type submodule = Submodule<$>;
|
|
35
|
+
type $ = {
|
|
36
|
+
$root: string.date;
|
|
37
|
+
parse: (In: string.date) => To<Date>;
|
|
38
|
+
iso: iso.submodule;
|
|
39
|
+
epoch: epoch.submodule;
|
|
40
|
+
};
|
|
41
|
+
type shallowResolutions = {
|
|
42
|
+
[k in keyof $ as `string.date.${k}`]: $[k] extends type.cast<infer t> ? t : $[k];
|
|
43
|
+
};
|
|
44
|
+
namespace iso {
|
|
45
|
+
type submodule = Submodule<$>;
|
|
46
|
+
type $ = {
|
|
47
|
+
$root: string.date.iso;
|
|
48
|
+
parse: (In: string.date.iso) => To<Date>;
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
namespace epoch {
|
|
52
|
+
type submodule = Submodule<$>;
|
|
53
|
+
type $ = {
|
|
54
|
+
$root: string.date.epoch;
|
|
55
|
+
parse: (In: string.date.epoch) => To<Date>;
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
54
59
|
export {};
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import type { Submodule } from "../../module.ts";
|
|
1
|
+
import type { Module, Submodule } from "../../module.ts";
|
|
2
2
|
import type { Branded, constrain, To } from "../ast.ts";
|
|
3
3
|
import type { number } from "../number/number.ts";
|
|
4
4
|
declare namespace string {
|
|
5
5
|
type integer = constrain<string, Branded<"integer">>;
|
|
6
6
|
}
|
|
7
|
-
export declare const integer:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
7
|
+
export declare const integer: stringInteger.module;
|
|
8
|
+
export declare namespace stringInteger {
|
|
9
|
+
type module = Module<submodule>;
|
|
10
|
+
type submodule = Submodule<$>;
|
|
11
|
+
type $ = {
|
|
12
|
+
$root: string.integer;
|
|
13
|
+
parse: (In: string.integer) => To<number.divisibleBy<1>>;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
15
16
|
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Submodule } from "../../module.ts";
|
|
1
|
+
import type { Module, Submodule } from "../../module.ts";
|
|
2
2
|
import type { Branded, constrain } from "../ast.ts";
|
|
3
3
|
declare namespace string {
|
|
4
4
|
type ip = constrain<string, Branded<"ip">>;
|
|
@@ -7,14 +7,14 @@ declare namespace string {
|
|
|
7
7
|
type v6 = constrain<string, Branded<"ip.v6">>;
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
|
-
export declare const ip:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
10
|
+
export declare const ip: ip.module;
|
|
11
|
+
export declare namespace ip {
|
|
12
|
+
type module = Module<submodule>;
|
|
13
|
+
type submodule = Submodule<$>;
|
|
14
|
+
type $ = {
|
|
15
|
+
$root: string.ip;
|
|
16
|
+
v4: string.ip.v4;
|
|
17
|
+
v6: string.ip.v6;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
20
|
export {};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
|
-
import type { Submodule } from "../../module.ts";
|
|
1
|
+
import type { Module, Submodule } from "../../module.ts";
|
|
2
2
|
import type { Branded, To, constrain } from "../ast.ts";
|
|
3
3
|
declare namespace string {
|
|
4
4
|
type json = constrain<string, Branded<"json">>;
|
|
5
5
|
}
|
|
6
|
-
export declare const json:
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
6
|
+
export declare const json: stringJson.module;
|
|
7
|
+
export declare namespace stringJson {
|
|
8
|
+
type module = Module<submodule>;
|
|
9
|
+
type submodule = Submodule<$>;
|
|
10
|
+
type $ = {
|
|
11
|
+
$root: string.json;
|
|
12
|
+
parse: (In: string.json) => To<object>;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
14
15
|
export {};
|