arktype 2.0.0-beta.1 → 2.0.0-beta.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/out/ark.d.ts +18 -4
- package/out/ark.js +22 -3
- package/out/ast.d.ts +213 -0
- package/out/ast.js +3 -0
- package/out/config.d.ts +13 -0
- package/out/generic.d.ts +117 -22
- package/out/index.d.ts +6 -5
- package/out/index.js +2 -2
- package/out/intersect.d.ts +28 -0
- package/out/intersect.js +1 -0
- package/out/keys.d.ts +16 -0
- package/out/keys.js +1 -0
- package/out/keywords/arkGenerics.d.ts +17 -0
- package/out/keywords/arkGenerics.js +16 -0
- package/out/keywords/format.d.ts +12 -0
- package/out/keywords/format.js +36 -0
- package/out/keywords/internal.d.ts +11 -0
- package/out/keywords/internal.js +25 -0
- package/out/keywords/jsObjects.d.ts +15 -0
- package/out/keywords/jsObjects.js +13 -0
- package/out/keywords/parsing.d.ts +16 -0
- package/out/keywords/parsing.js +77 -0
- package/out/keywords/platformObjects.d.ts +13 -0
- package/out/keywords/platformObjects.js +12 -0
- package/out/keywords/tsGenerics.d.ts +37 -0
- package/out/keywords/tsGenerics.js +37 -0
- package/out/keywords/tsKeywords.d.ts +18 -0
- package/out/keywords/tsKeywords.js +17 -0
- package/out/keywords/typedArray.d.ts +16 -0
- package/out/keywords/typedArray.js +14 -0
- package/out/keywords/utils/creditCard.d.ts +2 -0
- package/out/keywords/utils/creditCard.js +25 -0
- package/out/keywords/utils/date.d.ts +20 -0
- package/out/keywords/utils/date.js +36 -0
- package/out/keywords/utils/ip.d.ts +3 -0
- package/out/keywords/utils/ip.js +20 -0
- package/out/keywords/utils/regex.d.ts +2 -0
- package/out/keywords/utils/regex.js +9 -0
- package/out/keywords/validation.d.ts +19 -0
- package/out/keywords/validation.js +84 -0
- package/out/module.d.ts +21 -13
- package/out/module.js +1 -0
- package/out/parser/definition.d.ts +5 -4
- package/out/parser/objectLiteral.d.ts +6 -5
- package/out/parser/objectLiteral.js +2 -2
- package/out/parser/semantic/bounds.d.ts +2 -1
- package/out/parser/semantic/divisor.d.ts +2 -2
- package/out/parser/semantic/infer.d.ts +14 -9
- package/out/parser/semantic/keyof.d.ts +7 -0
- package/out/parser/semantic/keyof.js +1 -0
- package/out/parser/semantic/validate.d.ts +6 -7
- package/out/parser/semantic/validate.js +0 -1
- package/out/parser/string/reduce/dynamic.d.ts +2 -1
- package/out/parser/string/reduce/shared.d.ts +1 -1
- package/out/parser/string/reduce/static.d.ts +1 -1
- package/out/parser/string/shift/operand/date.d.ts +1 -1
- package/out/parser/string/shift/operand/genericArgs.d.ts +4 -4
- package/out/parser/string/shift/operand/unenclosed.d.ts +13 -8
- package/out/parser/string/shift/operator/bounds.d.ts +2 -1
- package/out/parser/string/shift/operator/bounds.js +5 -5
- package/out/parser/string/shift/operator/default.d.ts +2 -1
- package/out/parser/string/string.d.ts +2 -1
- package/out/parser/tuple.d.ts +4 -2
- package/out/parser/tuple.js +6 -6
- package/out/scope.d.ts +51 -29
- package/out/scope.js +2 -7
- package/out/subtypes/array.d.ts +13 -0
- package/out/subtypes/array.js +1 -0
- package/out/subtypes/base.d.ts +76 -0
- package/out/subtypes/base.js +1 -0
- package/out/subtypes/date.d.ts +11 -0
- package/out/subtypes/date.js +1 -0
- package/out/subtypes/instantiate.d.ts +16 -0
- package/out/subtypes/instantiate.js +1 -0
- package/out/subtypes/morph.d.ts +10 -0
- package/out/subtypes/morph.js +1 -0
- package/out/subtypes/number.d.ts +12 -0
- package/out/subtypes/number.js +1 -0
- package/out/subtypes/object.d.ts +27 -0
- package/out/subtypes/object.js +1 -0
- package/out/subtypes/string.d.ts +13 -0
- package/out/subtypes/string.js +1 -0
- package/out/subtypes/validator.d.ts +11 -0
- package/out/subtypes/validator.js +1 -0
- package/out/type.d.ts +19 -67
- package/package.json +3 -3
- package/out/match.d.ts +0 -71
- package/out/match.js +0 -50
package/out/ark.d.ts
CHANGED
|
@@ -1,9 +1,24 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { ArkErrors } from "@ark/schema";
|
|
2
|
+
import type { inferred } from "./ast.js";
|
|
2
3
|
import type { GenericHktParser } from "./generic.js";
|
|
3
|
-
import type
|
|
4
|
-
import type
|
|
4
|
+
import { type arkGenericsExports } from "./keywords/arkGenerics.js";
|
|
5
|
+
import { type formattingExports } from "./keywords/format.js";
|
|
6
|
+
import { type internalExports } from "./keywords/internal.js";
|
|
7
|
+
import { type jsObjectExports } from "./keywords/jsObjects.js";
|
|
8
|
+
import { type parsingExports } from "./keywords/parsing.js";
|
|
9
|
+
import { type platformObjectExports } from "./keywords/platformObjects.js";
|
|
10
|
+
import { type tsGenericsExports } from "./keywords/tsGenerics.js";
|
|
11
|
+
import { type tsKeywordExports } from "./keywords/tsKeywords.js";
|
|
12
|
+
import { type typedArrayExports } from "./keywords/typedArray.js";
|
|
13
|
+
import { type validationExports } from "./keywords/validation.js";
|
|
14
|
+
import type { Module, Submodule } from "./module.js";
|
|
5
15
|
import { type Scope } from "./scope.js";
|
|
6
16
|
import type { DeclarationParser, DefinitionParser, TypeParser } from "./type.js";
|
|
17
|
+
export interface Ark extends tsKeywordExports, jsObjectExports, platformObjectExports, validationExports, tsGenericsExports, arkGenericsExports, internalExports {
|
|
18
|
+
TypedArray: Submodule<typedArrayExports>;
|
|
19
|
+
parse: Submodule<parsingExports>;
|
|
20
|
+
format: Submodule<formattingExports>;
|
|
21
|
+
}
|
|
7
22
|
export declare const ambient: Scope<Ark>;
|
|
8
23
|
export declare const ark: Module<Ark>;
|
|
9
24
|
export declare const type: TypeParser<{}>;
|
|
@@ -14,6 +29,5 @@ export declare namespace type {
|
|
|
14
29
|
type errors = ArkErrors;
|
|
15
30
|
}
|
|
16
31
|
export declare const generic: GenericHktParser<{}>;
|
|
17
|
-
export declare const match: MatchParser<{}>;
|
|
18
32
|
export declare const define: DefinitionParser<{}>;
|
|
19
33
|
export declare const declare: DeclarationParser<{}>;
|
package/out/ark.js
CHANGED
|
@@ -1,9 +1,28 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { arkGenerics } from "./keywords/arkGenerics.js";
|
|
2
|
+
import { formatting } from "./keywords/format.js";
|
|
3
|
+
import { internal } from "./keywords/internal.js";
|
|
4
|
+
import { jsObjects } from "./keywords/jsObjects.js";
|
|
5
|
+
import { parsing } from "./keywords/parsing.js";
|
|
6
|
+
import { platformObjects } from "./keywords/platformObjects.js";
|
|
7
|
+
import { tsGenerics } from "./keywords/tsGenerics.js";
|
|
8
|
+
import { tsKeywords } from "./keywords/tsKeywords.js";
|
|
9
|
+
import { typedArray } from "./keywords/typedArray.js";
|
|
10
|
+
import { validation } from "./keywords/validation.js";
|
|
2
11
|
import { scope } from "./scope.js";
|
|
3
|
-
export const ambient = scope(
|
|
12
|
+
export const ambient = scope({
|
|
13
|
+
...tsKeywords,
|
|
14
|
+
...jsObjects,
|
|
15
|
+
...platformObjects,
|
|
16
|
+
...validation,
|
|
17
|
+
...internal,
|
|
18
|
+
...tsGenerics,
|
|
19
|
+
...arkGenerics,
|
|
20
|
+
TypedArray: typedArray,
|
|
21
|
+
parse: parsing,
|
|
22
|
+
format: formatting
|
|
23
|
+
}, { prereducedAliases: true, ambient: true });
|
|
4
24
|
export const ark = ambient.export();
|
|
5
25
|
export const type = ambient.type;
|
|
6
26
|
export const generic = ambient.generic;
|
|
7
|
-
export const match = ambient.match;
|
|
8
27
|
export const define = ambient.define;
|
|
9
28
|
export const declare = ambient.declare;
|
package/out/ast.d.ts
ADDED
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
import type { ArkError, ArkErrors, constraintKindOf, Morph, NodeSchema, PrimitiveConstraintKind } from "@ark/schema";
|
|
2
|
+
import { type anyOrNever, type array, type BuiltinObjectKind, type BuiltinObjects, type conform, type equals, type leftIfEqual, type Primitive, type propValueOf, type show } from "@ark/util";
|
|
3
|
+
import type { type } from "./ark.js";
|
|
4
|
+
import type { inferPipe } from "./intersect.js";
|
|
5
|
+
import type { platformObjectExports } from "./keywords/platformObjects.js";
|
|
6
|
+
import type { typedArrayExports } from "./keywords/typedArray.js";
|
|
7
|
+
import type { Type } from "./type.js";
|
|
8
|
+
export declare const inferred: " arkInferred";
|
|
9
|
+
export type inferred = typeof inferred;
|
|
10
|
+
export type Comparator = "<" | "<=" | ">" | ">=" | "==";
|
|
11
|
+
export type RegexLiteral<source extends string = string> = `/${source}/`;
|
|
12
|
+
export type DateLiteral<source extends string = string> = `d"${source}"` | `d'${source}'`;
|
|
13
|
+
export type ConstraintSet = Record<PropertyKey, 1>;
|
|
14
|
+
export type Constraints = Record<string, ConstraintSet>;
|
|
15
|
+
export declare const constrained: " arkConstrained";
|
|
16
|
+
export type constrained = typeof constrained;
|
|
17
|
+
export type constrain<base, constraints extends Constraints> = base & {
|
|
18
|
+
[constrained]: constraints;
|
|
19
|
+
};
|
|
20
|
+
export type LimitLiteral = number | DateLiteral;
|
|
21
|
+
export type normalizeLimit<limit> = limit extends DateLiteral<infer source> ? source : limit extends number | string ? limit : never;
|
|
22
|
+
type constraint<rule> = {
|
|
23
|
+
[k in rule & PropertyKey]: 1;
|
|
24
|
+
};
|
|
25
|
+
export type AtLeast<rule> = {
|
|
26
|
+
atLeast: constraint<rule>;
|
|
27
|
+
};
|
|
28
|
+
export type AtMost<rule> = {
|
|
29
|
+
atMost: constraint<rule>;
|
|
30
|
+
};
|
|
31
|
+
export type MoreThan<rule> = {
|
|
32
|
+
moreThan: constraint<rule>;
|
|
33
|
+
};
|
|
34
|
+
export type LessThan<rule> = {
|
|
35
|
+
lessThan: constraint<rule>;
|
|
36
|
+
};
|
|
37
|
+
export type Literal<rule> = {
|
|
38
|
+
literal: constraint<rule>;
|
|
39
|
+
};
|
|
40
|
+
export type DivisibleBy<rule> = {
|
|
41
|
+
divisibleBy: constraint<rule>;
|
|
42
|
+
};
|
|
43
|
+
export type Length<rule> = {
|
|
44
|
+
length: constraint<rule>;
|
|
45
|
+
};
|
|
46
|
+
export type Matching<rule> = {
|
|
47
|
+
matching: constraint<rule>;
|
|
48
|
+
};
|
|
49
|
+
export type anonymous = "?";
|
|
50
|
+
export type Narrowed = {
|
|
51
|
+
predicate: {
|
|
52
|
+
[k in anonymous]: 1;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
export type primitiveConstraintKindOf<In> = Extract<PrimitiveConstraintKind, constraintKindOf<In>>;
|
|
56
|
+
export declare namespace number {
|
|
57
|
+
type atLeast<rule> = constrain<number, AtLeast<rule>>;
|
|
58
|
+
type moreThan<rule> = constrain<number, MoreThan<rule>>;
|
|
59
|
+
type atMost<rule> = constrain<number, AtMost<rule>>;
|
|
60
|
+
type lessThan<rule> = constrain<number, LessThan<rule>>;
|
|
61
|
+
type divisibleBy<rule> = constrain<number, DivisibleBy<rule>>;
|
|
62
|
+
type narrowed = constrain<number, Narrowed>;
|
|
63
|
+
type is<constraints extends Constraints> = constrain<number, constraints>;
|
|
64
|
+
type parseConstraint<kind extends PrimitiveConstraintKind, schema extends NodeSchema<kind>> = normalizePrimitiveConstraintRoot<schema> extends infer rule ? kind extends "min" ? schema extends {
|
|
65
|
+
exclusive: true;
|
|
66
|
+
} ? moreThan<rule> : atLeast<rule> : kind extends "max" ? schema extends {
|
|
67
|
+
exclusive: true;
|
|
68
|
+
} ? lessThan<rule> : atMost<rule> : kind extends "divisor" ? divisibleBy<rule> : narrowed : never;
|
|
69
|
+
}
|
|
70
|
+
export type AtLeastLength<rule> = {
|
|
71
|
+
atLeastLength: constraint<rule>;
|
|
72
|
+
};
|
|
73
|
+
export type AtMostLength<rule> = {
|
|
74
|
+
atMostLength: constraint<rule>;
|
|
75
|
+
};
|
|
76
|
+
export type MoreThanLength<rule> = {
|
|
77
|
+
moreThanLength: constraint<rule>;
|
|
78
|
+
};
|
|
79
|
+
export type LessThanLength<rule> = {
|
|
80
|
+
lessThanLength: constraint<rule>;
|
|
81
|
+
};
|
|
82
|
+
export type ExactlyLength<rule> = {
|
|
83
|
+
atLeastLength: constraint<rule>;
|
|
84
|
+
atMostLength: constraint<rule>;
|
|
85
|
+
};
|
|
86
|
+
export declare namespace string {
|
|
87
|
+
type atLeastLength<rule> = constrain<string, AtLeastLength<rule>>;
|
|
88
|
+
type moreThanLength<rule> = constrain<string, MoreThanLength<rule>>;
|
|
89
|
+
type atMostLength<rule> = constrain<string, AtMostLength<rule>>;
|
|
90
|
+
type lessThanLength<rule> = constrain<string, LessThanLength<rule>>;
|
|
91
|
+
type exactlyLength<rule> = constrain<string, ExactlyLength<rule>>;
|
|
92
|
+
type matching<rule> = constrain<string, Matching<rule>>;
|
|
93
|
+
type narrowed = constrain<string, Narrowed>;
|
|
94
|
+
type is<constraints extends Constraints> = constrain<string, constraints>;
|
|
95
|
+
type parseConstraint<kind extends PrimitiveConstraintKind, schema extends NodeSchema<kind>> = normalizePrimitiveConstraintRoot<schema> extends infer rule ? kind extends "minLength" ? schema extends {
|
|
96
|
+
exclusive: true;
|
|
97
|
+
} ? moreThanLength<rule> : atLeastLength<rule> : kind extends "maxLength" ? schema extends {
|
|
98
|
+
exclusive: true;
|
|
99
|
+
} ? lessThanLength<rule> : atMostLength<rule> : kind extends "pattern" ? matching<rule & string> : kind extends "exactLength" ? exactlyLength<rule> : narrowed : never;
|
|
100
|
+
}
|
|
101
|
+
export type AtOrAfter<rule> = {
|
|
102
|
+
atOrAfter: constraint<rule>;
|
|
103
|
+
};
|
|
104
|
+
export type AtOrBefore<rule> = {
|
|
105
|
+
atOrBefore: constraint<rule>;
|
|
106
|
+
};
|
|
107
|
+
export type After<rule> = {
|
|
108
|
+
after: constraint<rule>;
|
|
109
|
+
};
|
|
110
|
+
export type Before<rule> = {
|
|
111
|
+
before: constraint<rule>;
|
|
112
|
+
};
|
|
113
|
+
export declare namespace Date {
|
|
114
|
+
type atOrAfter<rule> = constrain<Date, AtOrAfter<rule>>;
|
|
115
|
+
type after<rule> = constrain<Date, After<rule>>;
|
|
116
|
+
type atOrBefore<rule> = constrain<Date, AtOrBefore<rule>>;
|
|
117
|
+
type before<rule> = constrain<Date, Before<rule>>;
|
|
118
|
+
type narrowed = constrain<Date, Narrowed>;
|
|
119
|
+
type literal<rule> = constrain<Date, Literal<rule>>;
|
|
120
|
+
type is<constraints extends Constraints> = constrain<Date, constraints>;
|
|
121
|
+
type parseConstraint<kind extends PrimitiveConstraintKind, schema extends NodeSchema<kind>> = normalizePrimitiveConstraintRoot<schema> extends infer rule ? kind extends "after" ? schema extends {
|
|
122
|
+
exclusive: true;
|
|
123
|
+
} ? after<normalizeLimit<rule>> : atOrAfter<normalizeLimit<rule>> : kind extends "before" ? schema extends {
|
|
124
|
+
exclusive: true;
|
|
125
|
+
} ? before<normalizeLimit<rule>> : atOrBefore<normalizeLimit<rule>> : narrowed : never;
|
|
126
|
+
}
|
|
127
|
+
export type applyConstraint<t, kind extends PrimitiveConstraintKind, schema extends NodeSchema<kind>> = t extends MorphAst<infer i, infer o> ? (In: leftIfEqual<i, _applyConstraint<i, kind, schema>>) => Out<o> : leftIfEqual<t, _applyConstraint<t, kind, schema>>;
|
|
128
|
+
type _applyConstraint<t, kind extends PrimitiveConstraintKind, schema extends NodeSchema<kind>> = schemaToConstraint<kind, schema> extends infer constraint ? parseConstraints<t> extends ([
|
|
129
|
+
infer base,
|
|
130
|
+
infer constraints extends Constraints
|
|
131
|
+
]) ? [
|
|
132
|
+
number,
|
|
133
|
+
base
|
|
134
|
+
] extends [base, number] ? number.is<constraint & constraints> : [string, base] extends [base, string] ? string.is<constraint & constraints> : [Date, base] extends [base, Date] ? Date.is<constraint & constraints> : constrain<base, constraints & constraint> : [number, t] extends [t, number] ? number.parseConstraint<kind, schema> : [string, t] extends [t, string] ? string.parseConstraint<kind, schema> : [Date, t] extends [t, Date] ? Date.parseConstraint<kind, schema> : constrain<t, conform<constraint, Constraints>> : never;
|
|
135
|
+
export type parseConstraints<t> = t extends constrain<infer base, infer constraints> ? equals<t, number & {
|
|
136
|
+
[constrained]: constraints;
|
|
137
|
+
}> extends true ? [
|
|
138
|
+
number,
|
|
139
|
+
constraints
|
|
140
|
+
] : equals<t, string & {
|
|
141
|
+
[constrained]: constraints;
|
|
142
|
+
}> extends true ? [
|
|
143
|
+
string,
|
|
144
|
+
constraints
|
|
145
|
+
] : equals<t, Date & {
|
|
146
|
+
[constrained]: constraints;
|
|
147
|
+
}> extends true ? [
|
|
148
|
+
Date,
|
|
149
|
+
constraints
|
|
150
|
+
] : [base, constraints] : null;
|
|
151
|
+
export type normalizePrimitiveConstraintRoot<schema extends NodeSchema<PrimitiveConstraintKind>> = "rule" extends keyof schema ? conform<schema["rule"], PropertyKey> : conform<schema, PropertyKey>;
|
|
152
|
+
export type schemaToConstraint<kind extends PrimitiveConstraintKind, schema extends NodeSchema<kind>> = normalizePrimitiveConstraintRoot<schema> extends infer rule ? kind extends "pattern" ? Matching<rule> : kind extends "divisor" ? DivisibleBy<rule> : kind extends "exactLength" ? Length<rule> : kind extends "min" ? schema extends {
|
|
153
|
+
exclusive: true;
|
|
154
|
+
} ? MoreThan<rule> : AtLeast<rule> : kind extends "max" ? schema extends {
|
|
155
|
+
exclusive: true;
|
|
156
|
+
} ? LessThan<rule> : AtMost<rule> : kind extends "minLength" ? schema extends {
|
|
157
|
+
exclusive: true;
|
|
158
|
+
} ? MoreThanLength<rule> : AtLeastLength<rule> : kind extends "maxLength" ? schema extends {
|
|
159
|
+
exclusive: true;
|
|
160
|
+
} ? LessThanLength<rule> : AtMostLength<rule> : kind extends "exactLength" ? ExactlyLength<rule> : kind extends "after" ? schema extends {
|
|
161
|
+
exclusive: true;
|
|
162
|
+
} ? After<normalizeLimit<rule>> : AtOrAfter<normalizeLimit<rule>> : kind extends "before" ? schema extends {
|
|
163
|
+
exclusive: true;
|
|
164
|
+
} ? Before<normalizeLimit<rule>> : AtOrBefore<normalizeLimit<rule>> : Narrowed : never;
|
|
165
|
+
export type distillIn<t> = finalizeDistillation<t, _distill<t, "in", "base">>;
|
|
166
|
+
export type distillOut<t> = finalizeDistillation<t, _distill<t, "out", "base">>;
|
|
167
|
+
export type distillConstrainableIn<t> = finalizeDistillation<t, _distill<t, "in", "constrainable">>;
|
|
168
|
+
export type distillConstrainableOut<t> = finalizeDistillation<t, _distill<t, "out", "constrainable">>;
|
|
169
|
+
type finalizeDistillation<t, distilled> = equals<t, distilled> extends true ? t : distilled;
|
|
170
|
+
export type includesMorphs<t> = [
|
|
171
|
+
_distill<t, "in", "constrainable">,
|
|
172
|
+
_distill<t, "out", "constrainable">
|
|
173
|
+
] extends ([
|
|
174
|
+
_distill<t, "out", "constrainable">,
|
|
175
|
+
_distill<t, "in", "constrainable">
|
|
176
|
+
]) ? false : true;
|
|
177
|
+
type _distill<t, io extends "in" | "out", distilledKind extends "base" | "constrainable"> = t extends undefined ? t : [t] extends [anyOrNever] ? t : parseConstraints<t> extends ([
|
|
178
|
+
infer base,
|
|
179
|
+
infer constraints extends Constraints
|
|
180
|
+
]) ? distilledKind extends "base" ? _distill<base, io, distilledKind> : constrain<_distill<base, io, distilledKind>, constraints> : t extends TerminallyInferredObjectKind | Primitive ? t : unknown extends t ? unknown : t extends MorphAst<infer i, infer o> ? io extends "in" ? _distill<i, io, distilledKind> : _distill<o, io, distilledKind> : t extends DefaultableAst<infer t> ? _distill<t, io, distilledKind> : t extends array ? distillArray<t, io, distilledKind, []> : t extends Function ? t : {
|
|
181
|
+
[k in keyof t]: t[k];
|
|
182
|
+
} extends t ? io extends "in" ? show<{
|
|
183
|
+
[k in keyof t as k extends defaultableKeyOf<t> ? never : k]: _distill<t[k], io, distilledKind>;
|
|
184
|
+
} & {
|
|
185
|
+
[k in defaultableKeyOf<t>]?: _distill<t[k], io, distilledKind>;
|
|
186
|
+
}> : {
|
|
187
|
+
[k in keyof t]: _distill<t[k], io, distilledKind>;
|
|
188
|
+
} : t;
|
|
189
|
+
export type defaultableKeyOf<t> = {
|
|
190
|
+
[k in keyof t]: [t[k]] extends [anyOrNever] ? never : t[k] extends DefaultableAst ? k : never;
|
|
191
|
+
}[keyof t];
|
|
192
|
+
type distillArray<t extends array, io extends "in" | "out", constraints extends "base" | "constrainable", prefix extends array> = t extends readonly [infer head, ...infer tail] ? distillArray<tail, io, constraints, [
|
|
193
|
+
...prefix,
|
|
194
|
+
_distill<head, io, constraints>
|
|
195
|
+
]> : [...prefix, ...distillPostfix<t, io, constraints>];
|
|
196
|
+
type distillPostfix<t extends array, io extends "in" | "out", constraints extends "base" | "constrainable", postfix extends array = []> = t extends readonly [...infer init, infer last] ? distillPostfix<init, io, constraints, [
|
|
197
|
+
_distill<last, io, constraints>,
|
|
198
|
+
...postfix
|
|
199
|
+
]> : [...{
|
|
200
|
+
[i in keyof t]: _distill<t[i], io, constraints>;
|
|
201
|
+
}, ...postfix];
|
|
202
|
+
/** Objects we don't want to expand during inference like Date or Promise */
|
|
203
|
+
type TerminallyInferredObjectKind = ArkEnv.prototypes | BuiltinObjects[Exclude<BuiltinObjectKind, "Array" | "Function">] | propValueOf<platformObjectExports> | propValueOf<typedArrayExports>;
|
|
204
|
+
export type inferPredicate<t, predicate> = predicate extends (data: any, ...args: any[]) => data is infer narrowed ? t extends constrain<unknown, infer constraints> ? applyConstraint<constrain<narrowed, constraints>, "predicate", any> : applyConstraint<narrowed, "predicate", any> : applyConstraint<t, "predicate", any>;
|
|
205
|
+
export type constrainWithPredicate<t> = t extends constrain<unknown, infer constraints> ? applyConstraint<constrain<t, constraints>, "predicate", any> : applyConstraint<t, "predicate", any>;
|
|
206
|
+
export type inferPipes<t, pipes extends Morph[]> = pipes extends [infer head extends Morph, ...infer tail extends Morph[]] ? inferPipes<pipes[0] extends type.cast<infer tPipe> ? inferPipe<t, tPipe> : inferMorphOut<head> extends infer out ? (In: distillConstrainableIn<t>) => Out<out> : never, tail> : t;
|
|
207
|
+
export type inferMorphOut<morph extends Morph> = Exclude<ReturnType<morph>, ArkError | ArkErrors>;
|
|
208
|
+
export type Out<o = any> = ["=>", o];
|
|
209
|
+
export type MorphAst<i = any, o = any> = (In: i) => Out<o>;
|
|
210
|
+
export type Default<v = any> = ["=", v];
|
|
211
|
+
export type DefaultableAst<t = any, v = any> = (In?: t) => Default<v>;
|
|
212
|
+
export type termOrType<t> = t | Type<t, any>;
|
|
213
|
+
export {};
|
package/out/ast.js
ADDED
package/out/config.d.ts
CHANGED
|
@@ -1 +1,14 @@
|
|
|
1
|
+
import type { ArkSchemaRegistryContents } from "@ark/schema";
|
|
2
|
+
import type { Ark } from "./ark.js";
|
|
3
|
+
import type { exportScope } from "./module.js";
|
|
1
4
|
export * from "@ark/schema/config";
|
|
5
|
+
export interface ArkTypeRegistryContents extends ArkSchemaRegistryContents {
|
|
6
|
+
ambient: exportScope<Ark>;
|
|
7
|
+
}
|
|
8
|
+
declare global {
|
|
9
|
+
export interface ArkEnv {
|
|
10
|
+
registry(): ArkTypeRegistryContents;
|
|
11
|
+
}
|
|
12
|
+
export namespace ArkEnv {
|
|
13
|
+
}
|
|
14
|
+
}
|
package/out/generic.d.ts
CHANGED
|
@@ -1,34 +1,123 @@
|
|
|
1
|
-
import type { GenericParamAst, GenericParamDef,
|
|
2
|
-
import { type array, type Callable, type conform, type ErrorMessage, type
|
|
1
|
+
import type { arkKind, GenericAst, GenericHkt, GenericParamAst, GenericParamDef, genericParamNames, GenericRoot, LazyGenericBody } from "@ark/schema";
|
|
2
|
+
import { type array, type Callable, type conform, type ErrorMessage, type ErrorType, type WhiteSpaceToken } from "@ark/util";
|
|
3
3
|
import type { inferDefinition } from "./parser/definition.js";
|
|
4
4
|
import type { inferAstRoot } from "./parser/semantic/infer.js";
|
|
5
5
|
import type { validateAst } from "./parser/semantic/validate.js";
|
|
6
6
|
import type { state, StaticState } from "./parser/string/reduce/static.js";
|
|
7
7
|
import { Scanner } from "./parser/string/shift/scanner.js";
|
|
8
8
|
import { parseUntilFinalizer } from "./parser/string/string.js";
|
|
9
|
-
import type { ParseContext } from "./scope.js";
|
|
9
|
+
import type { ParseContext, Scope } from "./scope.js";
|
|
10
10
|
import type { inferTypeRoot, Type, validateTypeRoot } from "./type.js";
|
|
11
11
|
export type ParameterString<params extends string = string> = `<${params}>`;
|
|
12
12
|
export type extractParams<s extends ParameterString> = s extends ParameterString<infer params> ? params : never;
|
|
13
|
-
export type validateParameterString<s extends ParameterString, $> = parseGenericParams<extractParams<s>, $> extends
|
|
14
|
-
|
|
15
|
-
export type GenericInstantiator<params extends array<GenericParamAst>, def, $, args$> =
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
export type validateParameterString<s extends ParameterString, $> = parseGenericParams<extractParams<s>, $> extends infer e extends ErrorMessage ? e : s;
|
|
14
|
+
type validateGenericArg<arg, param extends GenericParamAst, $> = inferTypeRoot<arg, $> extends param[1] ? arg : ErrorType<`Invalid argument for ${param[0]}`, [expected: param[1]]>;
|
|
15
|
+
export type GenericInstantiator<params extends array<GenericParamAst>, def, $, args$> = params["length"] extends 1 ? {
|
|
16
|
+
<const a, r = instantiateGeneric<def, params, [a], $, args$>>(a: validateTypeRoot<a, args$> & validateGenericArg<a, params[0], args$>): r;
|
|
17
|
+
} : params["length"] extends 2 ? {
|
|
18
|
+
<const a, const b, r = instantiateGeneric<def, params, [a, b], $, args$>>(...args: [validateTypeRoot<a, args$>, validateTypeRoot<b, args$>] & [
|
|
19
|
+
validateGenericArg<a, params[0], args$>,
|
|
20
|
+
validateGenericArg<b, params[1], args$>
|
|
21
|
+
]): r;
|
|
22
|
+
} : params["length"] extends 3 ? {
|
|
23
|
+
<const a, const b, const c, r = instantiateGeneric<def, params, [a, b, c], $, args$>>(...args: [
|
|
24
|
+
validateTypeRoot<a, args$>,
|
|
25
|
+
validateTypeRoot<b, args$>,
|
|
26
|
+
validateTypeRoot<c, args$>
|
|
27
|
+
] & [
|
|
28
|
+
validateGenericArg<a, params[0], args$>,
|
|
29
|
+
validateGenericArg<b, params[1], args$>,
|
|
30
|
+
validateGenericArg<c, params[2], args$>
|
|
31
|
+
]): r;
|
|
32
|
+
} : params["length"] extends 4 ? {
|
|
33
|
+
<const a, const b, const c, const d, r = instantiateGeneric<def, params, [a, b, c, d], $, args$>>(...args: [
|
|
34
|
+
validateTypeRoot<a, args$>,
|
|
35
|
+
validateTypeRoot<b, args$>,
|
|
36
|
+
validateTypeRoot<c, args$>,
|
|
37
|
+
validateTypeRoot<d, args$>
|
|
38
|
+
] & [
|
|
39
|
+
validateGenericArg<a, params[0], args$>,
|
|
40
|
+
validateGenericArg<b, params[1], args$>,
|
|
41
|
+
validateGenericArg<c, params[2], args$>,
|
|
42
|
+
validateGenericArg<d, params[3], args$>
|
|
43
|
+
]): r;
|
|
44
|
+
} : params["length"] extends 4 ? {
|
|
45
|
+
<const a, const b, const c, const d, const e, r = instantiateGeneric<def, params, [a, b, c, d, e], $, args$>>(...args: [
|
|
46
|
+
validateTypeRoot<a, args$>,
|
|
47
|
+
validateTypeRoot<b, args$>,
|
|
48
|
+
validateTypeRoot<c, args$>,
|
|
49
|
+
validateTypeRoot<d, args$>,
|
|
50
|
+
validateTypeRoot<e, args$>
|
|
51
|
+
] & [
|
|
52
|
+
validateGenericArg<a, params[0], args$>,
|
|
53
|
+
validateGenericArg<b, params[1], args$>,
|
|
54
|
+
validateGenericArg<c, params[2], args$>,
|
|
55
|
+
validateGenericArg<d, params[3], args$>,
|
|
56
|
+
validateGenericArg<e, params[4], args$>
|
|
57
|
+
]): r;
|
|
58
|
+
} : params["length"] extends 5 ? {
|
|
59
|
+
<const a, const b, const c, const d, const e, const f, r = instantiateGeneric<def, params, [a, b, c, d, e, f], $, args$>>(...args: [
|
|
60
|
+
validateTypeRoot<a, args$>,
|
|
61
|
+
validateTypeRoot<b, args$>,
|
|
62
|
+
validateTypeRoot<c, args$>,
|
|
63
|
+
validateTypeRoot<d, args$>,
|
|
64
|
+
validateTypeRoot<e, args$>,
|
|
65
|
+
validateTypeRoot<f, args$>
|
|
66
|
+
] & [
|
|
67
|
+
validateGenericArg<a, params[0], args$>,
|
|
68
|
+
validateGenericArg<b, params[1], args$>,
|
|
69
|
+
validateGenericArg<c, params[2], args$>,
|
|
70
|
+
validateGenericArg<d, params[3], args$>,
|
|
71
|
+
validateGenericArg<e, params[4], args$>,
|
|
72
|
+
validateGenericArg<f, params[5], args$>
|
|
73
|
+
]): r;
|
|
74
|
+
} : params["length"] extends 6 ? {
|
|
75
|
+
<const a, const b, const c, const d, const e, const f, const g, r = instantiateGeneric<def, params, [a, b, c, d, e, f, g], $, args$>>(...args: [
|
|
76
|
+
validateTypeRoot<a, args$>,
|
|
77
|
+
validateTypeRoot<b, args$>,
|
|
78
|
+
validateTypeRoot<c, args$>,
|
|
79
|
+
validateTypeRoot<d, args$>,
|
|
80
|
+
validateTypeRoot<e, args$>,
|
|
81
|
+
validateTypeRoot<f, args$>,
|
|
82
|
+
validateTypeRoot<g, args$>
|
|
83
|
+
] & [
|
|
84
|
+
validateGenericArg<a, params[0], args$>,
|
|
85
|
+
validateGenericArg<b, params[1], args$>,
|
|
86
|
+
validateGenericArg<c, params[2], args$>,
|
|
87
|
+
validateGenericArg<d, params[3], args$>,
|
|
88
|
+
validateGenericArg<e, params[4], args$>,
|
|
89
|
+
validateGenericArg<f, params[5], args$>,
|
|
90
|
+
validateGenericArg<g, params[6], args$>
|
|
91
|
+
]): r;
|
|
92
|
+
} : (error: ErrorMessage<`You may not define more than 7 positional generic parameters`>) => never;
|
|
93
|
+
type instantiateGeneric<def, params extends array<GenericParamAst>, args, $, args$> = Type<[
|
|
94
|
+
def
|
|
95
|
+
] extends [GenericHkt] ? GenericHkt.instantiate<def, {
|
|
22
96
|
[i in keyof args]: inferTypeRoot<args[i], args$>;
|
|
23
|
-
}> : inferDefinition<def, $, bindGenericArgs<params, args$, args>>, $>;
|
|
97
|
+
}> : inferDefinition<def, $, bindGenericArgs<params, args$, args>>, args$>;
|
|
24
98
|
type bindGenericArgs<params extends array<GenericParamAst>, $, args> = {
|
|
25
99
|
[i in keyof params & `${number}` as params[i][0]]: inferTypeRoot<args[i & keyof args], $>;
|
|
26
100
|
};
|
|
27
|
-
|
|
101
|
+
type baseGenericResolutions<params extends array<GenericParamAst>, $> = baseGenericConstraints<params> extends infer baseConstraints ? {
|
|
102
|
+
[k in keyof baseConstraints]: Type<baseConstraints[k], $>;
|
|
103
|
+
} : never;
|
|
104
|
+
export type baseGenericConstraints<params extends array<GenericParamAst>> = {
|
|
28
105
|
[i in keyof params & `${number}` as params[i][0]]: params[i][1];
|
|
29
106
|
};
|
|
30
|
-
export interface Generic<params extends array<GenericParamAst> = array<GenericParamAst>, bodyDef = unknown, $ = {},
|
|
31
|
-
|
|
107
|
+
export interface Generic<params extends array<GenericParamAst> = array<GenericParamAst>, bodyDef = unknown, $ = {}, arg$ = $> extends Callable<GenericInstantiator<params, bodyDef, $, arg$>> {
|
|
108
|
+
[arkKind]: "generic";
|
|
109
|
+
t: GenericAst<params, bodyDef, $, arg$>;
|
|
110
|
+
bodyDef: bodyDef;
|
|
111
|
+
params: {
|
|
112
|
+
[i in keyof params]: [params[i][0], Type<params[i][1], $>];
|
|
113
|
+
};
|
|
114
|
+
names: genericParamNames<params>;
|
|
115
|
+
constraints: {
|
|
116
|
+
[i in keyof params]: Type<params[i][1], $>;
|
|
117
|
+
};
|
|
118
|
+
$: Scope<$>;
|
|
119
|
+
arg$: Scope<arg$>;
|
|
120
|
+
internal: GenericRoot;
|
|
32
121
|
}
|
|
33
122
|
export type GenericDeclaration<name extends string = string, params extends ParameterString = ParameterString> = `${name}${params}`;
|
|
34
123
|
export type parseValidGenericParams<def extends ParameterString, $> = conform<parseGenericParams<extractParams<def>, $>, array<GenericParamAst>>;
|
|
@@ -47,19 +136,25 @@ declare const paramsTerminators: {
|
|
|
47
136
|
type ParamsTerminator = keyof typeof paramsTerminators;
|
|
48
137
|
declare const parseName: (scanner: Scanner, result: GenericParamDef[], ctx: ParseContext) => GenericParamDef[];
|
|
49
138
|
type parseName<unscanned extends string, result extends array<GenericParamAst>, $> = parseNextNameChar<Scanner.skipWhitespace<unscanned>, "", result, $>;
|
|
50
|
-
type parseNextNameChar<unscanned extends string, name extends string, result extends array<GenericParamAst>, $> = unscanned extends `${infer lookahead}${infer nextUnscanned}` ? lookahead extends ParamsTerminator ? name extends "" ?
|
|
139
|
+
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<unscanned, name, result, $> : never : parseNextNameChar<nextUnscanned, `${name}${lookahead}`, result, $> : name extends "" ? result : [...result, [name, unknown]];
|
|
51
140
|
declare const extendsToken = "extends ";
|
|
52
141
|
type ConstrainingToken = ":" | typeof extendsToken;
|
|
53
142
|
declare const _parseOptionalConstraint: (scanner: Scanner, name: string, result: GenericParamDef[], ctx: ParseContext) => GenericParamDef[];
|
|
54
|
-
type _parseOptionalConstraint<unscanned extends string, name extends string, result extends array<GenericParamAst>, $> = Scanner.skipWhitespace<unscanned> extends (`${ConstrainingToken}${infer nextUnscanned}`) ? parseUntilFinalizer<state.initialize<nextUnscanned>, $, {}> extends (infer finalArgState extends StaticState) ? validateAst<finalArgState["root"], $, {}> extends (
|
|
143
|
+
type _parseOptionalConstraint<unscanned extends string, name extends string, result extends array<GenericParamAst>, $> = Scanner.skipWhitespace<unscanned> extends (`${ConstrainingToken}${infer nextUnscanned}`) ? parseUntilFinalizer<state.initialize<nextUnscanned>, $, {}> extends (infer finalArgState extends StaticState) ? validateAst<finalArgState["root"], $, {}> extends (infer e extends ErrorMessage) ? e : parseName<finalArgState["unscanned"], [
|
|
55
144
|
...result,
|
|
56
145
|
[name, inferAstRoot<finalArgState["root"], $, {}>]
|
|
57
146
|
], $> : never : parseName<Scanner.skipWhitespace<unscanned> extends `,${infer nextUnscanned}` ? nextUnscanned : unscanned, [
|
|
58
147
|
...result,
|
|
59
148
|
[name, unknown]
|
|
60
149
|
], $>;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
150
|
+
type genericParamDefToAst<schema extends GenericParamDef, $> = schema extends string ? [schema, unknown] : schema extends readonly [infer name, infer def] ? [
|
|
151
|
+
name,
|
|
152
|
+
inferTypeRoot<def, $>
|
|
153
|
+
] : never;
|
|
154
|
+
export type genericParamDefsToAst<defs extends array<GenericParamDef>, $> = [
|
|
155
|
+
...{
|
|
156
|
+
[i in keyof defs]: genericParamDefToAst<defs[i], $>;
|
|
157
|
+
}
|
|
158
|
+
];
|
|
159
|
+
export type GenericHktParser<$ = {}> = <const paramsDef extends array<GenericParamDef>>(...params: paramsDef) => <hkt extends abstract new () => GenericHkt, params extends Array<GenericParamAst> = genericParamDefsToAst<paramsDef, $>>(instantiateDef: LazyGenericBody<baseGenericResolutions<params, $>>, hkt: hkt) => Generic<params, InstanceType<hkt>, $, $>;
|
|
65
160
|
export {};
|
package/out/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export { ArkError, ArkErrors
|
|
2
|
-
export type {
|
|
3
|
-
export { ambient, ark, declare, define, generic,
|
|
4
|
-
export {
|
|
1
|
+
export { ArkError, ArkErrors, GenericHkt } from "@ark/schema";
|
|
2
|
+
export type { ArkConfig, ArkScopeConfig } from "@ark/schema";
|
|
3
|
+
export { ambient, ark, declare, define, generic, type } from "./ark.js";
|
|
4
|
+
export type { Generic } from "./generic.js";
|
|
5
|
+
export { Module, type Submodule } from "./module.js";
|
|
5
6
|
export { scope, type Scope, type inferScope, type validateScope } from "./scope.js";
|
|
6
|
-
export { Type, type
|
|
7
|
+
export { Type, type inferAmbient, type inferTypeRoot, type validateAmbient, type validateTypeRoot } from "./type.js";
|
package/out/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { ArkError, ArkErrors
|
|
2
|
-
export { ambient, ark, declare, define, generic,
|
|
1
|
+
export { ArkError, ArkErrors, GenericHkt } from "@ark/schema";
|
|
2
|
+
export { ambient, ark, declare, define, generic, type } from "./ark.js";
|
|
3
3
|
export { Module } from "./module.js";
|
|
4
4
|
export { scope } from "./scope.js";
|
|
5
5
|
export { Type } from "./type.js";
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { anyOrNever, array, conform, Hkt, intersectArrays, show } from "@ark/util";
|
|
2
|
+
import type { constrain, Constraints, MorphAst, Out, parseConstraints } from "./ast.js";
|
|
3
|
+
export type inferIntersection<l, r> = _inferIntersection<l, r, false>;
|
|
4
|
+
export type inferPipe<l, r> = _inferIntersection<l, r, true>;
|
|
5
|
+
type _inferIntersection<l, r, piped extends boolean> = [
|
|
6
|
+
l & r
|
|
7
|
+
] extends [infer t extends anyOrNever] ? t : l extends MorphAst<infer lIn, infer lOut> ? r extends MorphAst<any, infer rOut> ? piped extends true ? (In: lIn) => Out<rOut> : never : piped extends true ? (In: lIn) => Out<r> : (In: _inferIntersection<lIn, r, false>) => Out<lOut> : r extends MorphAst<infer rIn, infer rOut> ? (In: _inferIntersection<rIn, l, false>) => Out<rOut> : parseConstraints<l> extends ([
|
|
8
|
+
infer lBase,
|
|
9
|
+
infer lConstraints extends Constraints
|
|
10
|
+
]) ? parseConstraints<r> extends ([
|
|
11
|
+
infer rBase,
|
|
12
|
+
infer rConstraints extends Constraints
|
|
13
|
+
]) ? constrain<_inferIntersection<lBase, rBase, piped>, lConstraints & rConstraints> : constrain<_inferIntersection<lBase, r, piped>, lConstraints> : parseConstraints<r> extends ([
|
|
14
|
+
infer rBase,
|
|
15
|
+
infer rConstraints extends Constraints
|
|
16
|
+
]) ? constrain<_inferIntersection<l, rBase, piped>, rConstraints> : [l, r] extends [object, object] ? intersectObjects<l, r, piped> extends infer result ? result : never : l & r;
|
|
17
|
+
declare class MorphableIntersection<piped extends boolean> extends Hkt.Kind {
|
|
18
|
+
hkt: (In: conform<this[Hkt.args], [l: unknown, r: unknown]>) => _inferIntersection<(typeof In)[0], (typeof In)[1], piped>;
|
|
19
|
+
}
|
|
20
|
+
type intersectObjects<l, r, piped extends boolean> = [
|
|
21
|
+
l,
|
|
22
|
+
r
|
|
23
|
+
] extends [infer lList extends array, infer rList extends array] ? intersectArrays<lList, rList, MorphableIntersection<piped>> : show<{
|
|
24
|
+
[k in keyof l]: k extends keyof r ? _inferIntersection<l[k], r[k], piped> : l[k];
|
|
25
|
+
} & {
|
|
26
|
+
[k in keyof r]: k extends keyof l ? _inferIntersection<l[k], r[k], piped> : r[k];
|
|
27
|
+
}>;
|
|
28
|
+
export {};
|
package/out/intersect.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/out/keys.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { array, join, Key, NonNegativeIntegerLiteral, typeToString } from "@ark/util";
|
|
2
|
+
import type { type } from "./ark.js";
|
|
3
|
+
import type { termOrType } from "./ast.js";
|
|
4
|
+
export type toArkKey<o, k extends keyof o> = k extends number ? [
|
|
5
|
+
o,
|
|
6
|
+
number
|
|
7
|
+
] extends [array, k] ? NonNegativeIntegerLiteral : `${k}` : k;
|
|
8
|
+
export type arkKeyOf<o> = o extends array ? (number extends o["length"] ? NonNegativeIntegerLiteral : never) | {
|
|
9
|
+
[k in keyof o]-?: k extends `${infer index extends number}` ? index | k : never;
|
|
10
|
+
}[keyof o & `${number}`] : {
|
|
11
|
+
[k in keyof o]: k extends number ? k | `${k}` : k;
|
|
12
|
+
}[keyof o];
|
|
13
|
+
export type getArkKey<o, k extends arkKeyOf<o>> = o[Extract<k extends NonNegativeIntegerLiteral ? number : k, keyof o>];
|
|
14
|
+
export type TypeKey = termOrType<Key>;
|
|
15
|
+
export type typeKeyToString<k extends TypeKey> = typeToString<k extends type.cast<infer t> ? t : k>;
|
|
16
|
+
export type writeInvalidKeysMessage<o extends string, keys extends array<string>> = `Key${keys["length"] extends 1 ? "" : "s"} ${join<keys, ", ">} ${keys["length"] extends 1 ? "does" : "do"} not exist on ${o}`;
|
package/out/keys.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Out } from "../ast.js";
|
|
2
|
+
import type { Module } from "../module.js";
|
|
3
|
+
import { type inferScope } from "../scope.js";
|
|
4
|
+
declare const arkGenericsExports: {
|
|
5
|
+
liftArray: import("@ark/schema").GenericRoot<readonly [["element", unknown]], {
|
|
6
|
+
hkt: (args: [unknown]) => (In: unknown) => Out<unknown[]>;
|
|
7
|
+
readonly args: import("@ark/util").array;
|
|
8
|
+
}>;
|
|
9
|
+
merge: import("@ark/schema").GenericRoot<readonly [["base", object], ["props", object]], {
|
|
10
|
+
hkt: (args: [object, object]) => object;
|
|
11
|
+
readonly args: import("@ark/util").array;
|
|
12
|
+
}>;
|
|
13
|
+
};
|
|
14
|
+
export type arkGenericsExports = inferScope<typeof arkGenericsExports>;
|
|
15
|
+
export type arkGenerics = Module<arkGenericsExports>;
|
|
16
|
+
export declare const arkGenerics: arkGenerics;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { GenericHkt, genericNode } from "@ark/schema";
|
|
2
|
+
import { liftArray } from "@ark/util";
|
|
3
|
+
import { scope } from "../scope.js";
|
|
4
|
+
import { tsKeywords } from "./tsKeywords.js";
|
|
5
|
+
const ArkLiftArray = genericNode("element")(args => args.element.or(args.element.array()).pipe(liftArray), class liftArrayHkt extends GenericHkt {
|
|
6
|
+
});
|
|
7
|
+
const ArkMerge = genericNode(["base", tsKeywords.object], ["props", tsKeywords.object])(args => args.base.merge(args.props), class mergeHkt extends GenericHkt {
|
|
8
|
+
});
|
|
9
|
+
const arkGenericsExports = {
|
|
10
|
+
liftArray: ArkLiftArray,
|
|
11
|
+
merge: ArkMerge
|
|
12
|
+
};
|
|
13
|
+
const $ = scope(arkGenericsExports, {
|
|
14
|
+
prereducedAliases: true
|
|
15
|
+
});
|
|
16
|
+
export const arkGenerics = $.export();
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Out } from "../ast.js";
|
|
2
|
+
import type { Module } from "../module.js";
|
|
3
|
+
export type formattingExports = {
|
|
4
|
+
trim: (In: string) => Out<string>;
|
|
5
|
+
uppercase: (In: string) => Out<string>;
|
|
6
|
+
lowercase: (In: string) => Out<string>;
|
|
7
|
+
capitalize: (In: string) => Out<string>;
|
|
8
|
+
wellFormed: (In: string) => Out<string>;
|
|
9
|
+
normalize: (In: string) => Out<string>;
|
|
10
|
+
};
|
|
11
|
+
export type formatting = Module<formattingExports>;
|
|
12
|
+
export declare const formatting: formatting;
|