pema 0.4.0 → 0.5.0
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/lib/private/ArrayType.d.ts +1 -1
- package/lib/private/ArrayType.js +14 -22
- package/lib/private/BigIntType.d.ts +2 -2
- package/lib/private/BigUintType.d.ts +2 -2
- package/lib/private/BlobType.d.ts +2 -2
- package/lib/private/BlobType.js +2 -2
- package/lib/private/BooleanType.d.ts +2 -2
- package/lib/private/BooleanType.js +4 -4
- package/lib/private/BuiltinType.d.ts +1 -1
- package/lib/private/BuiltinType.js +3 -5
- package/lib/private/ConstructorType.d.ts +1 -1
- package/lib/private/ConstructorType.js +3 -5
- package/lib/private/DataType.d.ts +0 -1
- package/lib/private/DateType.d.ts +2 -2
- package/lib/private/DateType.js +2 -2
- package/lib/private/FileType.d.ts +2 -2
- package/lib/private/FileType.js +2 -2
- package/lib/private/GenericType.d.ts +1 -1
- package/lib/private/InferInputSchema.d.ts +7 -17
- package/lib/private/InferStore.d.ts +1 -1
- package/lib/private/IntType.d.ts +2 -2
- package/lib/private/Issue.d.ts +1 -1
- package/lib/private/LiteralType.d.ts +1 -2
- package/lib/private/LiteralType.js +3 -5
- package/lib/private/NormalizeSchema.d.ts +4 -6
- package/lib/private/NullType.js +3 -5
- package/lib/private/NumericType.d.ts +2 -2
- package/lib/private/ObjectType.d.ts +1 -1
- package/lib/private/ObjectType.js +9 -9
- package/lib/private/OmitType.d.ts +1 -1
- package/lib/private/OmitType.js +6 -6
- package/lib/private/ParseError.d.ts +1 -1
- package/lib/private/ParseError.js +2 -2
- package/lib/private/ParseOptions.d.ts +1 -1
- package/lib/private/Parsed.d.ts +1 -1
- package/lib/private/PartialType.js +6 -9
- package/lib/private/Partialable.d.ts +1 -1
- package/lib/private/PrimitiveType.js +18 -9
- package/lib/private/PureType.d.ts +1 -1
- package/lib/private/RecordType.js +8 -14
- package/lib/private/Schema.d.ts +1 -1
- package/lib/private/Serialized.d.ts +1 -4
- package/lib/private/{Storeable.d.ts → Storable.d.ts} +2 -2
- package/lib/private/{Storeable.js → Storable.js} +2 -2
- package/lib/private/StoreSchema.d.ts +3 -6
- package/lib/private/StoreType.d.ts +5 -1
- package/lib/private/StoreType.js +22 -2
- package/lib/private/StringType.d.ts +2 -2
- package/lib/private/StringType.js +2 -2
- package/lib/private/TupleType.d.ts +2 -2
- package/lib/private/TupleType.js +17 -14
- package/lib/private/Type.d.ts +1 -1
- package/lib/private/URLType.d.ts +2 -2
- package/lib/private/URLType.js +2 -2
- package/lib/private/UintType.d.ts +2 -2
- package/lib/private/UnionType.d.ts +3 -3
- package/lib/private/UnionType.js +11 -13
- package/lib/private/VirtualType.js +2 -3
- package/lib/private/coerce/bigint.js +3 -5
- package/lib/private/coerce/int.js +2 -3
- package/lib/private/constructor.d.ts +1 -1
- package/lib/private/dict.d.ts +11 -0
- package/lib/private/dict.js +6 -0
- package/lib/private/fail.d.ts +4 -0
- package/lib/private/fail.js +6 -0
- package/lib/private/index.d.ts +4 -2
- package/lib/private/index.js +6 -2
- package/lib/private/json/JSONPayload.d.ts +1 -1
- package/lib/private/normalize.js +2 -3
- package/lib/private/object.d.ts +2 -3
- package/lib/private/omit.d.ts +1 -1
- package/lib/private/path/join.d.ts +1 -1
- package/lib/private/path/next.d.ts +1 -1
- package/lib/private/path/rebase.d.ts +1 -1
- package/lib/private/test/paths-of.d.ts +1 -1
- package/lib/private/validator/integer.js +2 -2
- package/lib/private/validator/length.js +2 -2
- package/lib/private/validator/max.js +2 -2
- package/lib/private/validator/min.js +2 -2
- package/lib/private/validator/range.js +2 -2
- package/lib/private/validator/values.d.ts +1 -1
- package/lib/private/validator/values.js +3 -2
- package/lib/public/index.d.ts +20 -1
- package/lib/public/index.js +8 -1
- package/package.json +13 -11
- package/lib/private/DecrementDepth.d.ts +0 -3
- package/lib/private/DecrementDepth.js +0 -2
- package/lib/private/InferSchema.d.ts +0 -20
- package/lib/private/InferSchema.js +0 -2
- package/lib/private/PrimaryType.d.ts +0 -14
- package/lib/private/PrimaryType.js +0 -26
- package/lib/private/primary.d.ts +0 -4
- package/lib/private/primary.js +0 -3
- package/lib/public/DataType.d.ts +0 -2
- package/lib/public/DataType.js +0 -2
- package/lib/public/Id.d.ts +0 -2
- package/lib/public/Id.js +0 -2
- package/lib/public/InferStore.d.ts +0 -2
- package/lib/public/InferStore.js +0 -2
- package/lib/public/InferStoreOut.d.ts +0 -2
- package/lib/public/InferStoreOut.js +0 -2
- package/lib/public/Issue.d.ts +0 -2
- package/lib/public/Issue.js +0 -2
- package/lib/public/JSONPayload.d.ts +0 -2
- package/lib/public/JSONPayload.js +0 -2
- package/lib/public/OmitType.d.ts +0 -2
- package/lib/public/OmitType.js +0 -2
- package/lib/public/Schema.d.ts +0 -2
- package/lib/public/Schema.js +0 -2
- package/lib/public/Serialized.d.ts +0 -2
- package/lib/public/Serialized.js +0 -2
- package/lib/public/StoreId.d.ts +0 -2
- package/lib/public/StoreId.js +0 -2
- package/lib/public/StoreSchema.d.ts +0 -2
- package/lib/public/StoreSchema.js +0 -2
- package/lib/public/array.d.ts +0 -3
- package/lib/public/array.js +0 -3
- package/lib/public/bigint.d.ts +0 -2
- package/lib/public/bigint.js +0 -2
- package/lib/public/biguint.d.ts +0 -2
- package/lib/public/biguint.js +0 -2
- package/lib/public/blob.d.ts +0 -2
- package/lib/public/blob.js +0 -2
- package/lib/public/boolean.d.ts +0 -3
- package/lib/public/boolean.js +0 -3
- package/lib/public/constructor.d.ts +0 -3
- package/lib/public/constructor.js +0 -3
- package/lib/public/date.d.ts +0 -2
- package/lib/public/date.js +0 -2
- package/lib/public/f32.d.ts +0 -2
- package/lib/public/f32.js +0 -2
- package/lib/public/f64.d.ts +0 -2
- package/lib/public/f64.js +0 -2
- package/lib/public/file.d.ts +0 -2
- package/lib/public/file.js +0 -2
- package/lib/public/i128.d.ts +0 -2
- package/lib/public/i128.js +0 -2
- package/lib/public/i16.d.ts +0 -2
- package/lib/public/i16.js +0 -2
- package/lib/public/i32.d.ts +0 -2
- package/lib/public/i32.js +0 -2
- package/lib/public/i64.d.ts +0 -2
- package/lib/public/i64.js +0 -2
- package/lib/public/i8.d.ts +0 -2
- package/lib/public/i8.js +0 -2
- package/lib/public/int.d.ts +0 -2
- package/lib/public/int.js +0 -2
- package/lib/public/number.d.ts +0 -3
- package/lib/public/number.js +0 -3
- package/lib/public/object.d.ts +0 -2
- package/lib/public/object.js +0 -2
- package/lib/public/optional.d.ts +0 -2
- package/lib/public/optional.js +0 -2
- package/lib/public/primary.d.ts +0 -2
- package/lib/public/primary.js +0 -2
- package/lib/public/pure.d.ts +0 -2
- package/lib/public/pure.js +0 -2
- package/lib/public/record.d.ts +0 -3
- package/lib/public/record.js +0 -3
- package/lib/public/string.d.ts +0 -3
- package/lib/public/string.js +0 -3
- package/lib/public/symbol.d.ts +0 -2
- package/lib/public/symbol.js +0 -2
- package/lib/public/u128.d.ts +0 -2
- package/lib/public/u128.js +0 -2
- package/lib/public/u16.d.ts +0 -2
- package/lib/public/u16.js +0 -2
- package/lib/public/u32.d.ts +0 -2
- package/lib/public/u32.js +0 -2
- package/lib/public/u64.d.ts +0 -2
- package/lib/public/u64.js +0 -2
- package/lib/public/u8.d.ts +0 -2
- package/lib/public/u8.js +0 -2
- package/lib/public/uint.d.ts +0 -3
- package/lib/public/uint.js +0 -3
- package/lib/public/union.d.ts +0 -3
- package/lib/public/union.js +0 -3
- package/lib/public/unknown.d.ts +0 -3
- package/lib/public/unknown.js +0 -2
package/lib/private/index.js
CHANGED
|
@@ -5,6 +5,7 @@ import blob from "#blob";
|
|
|
5
5
|
import boolean from "#boolean";
|
|
6
6
|
import constructor from "#constructor";
|
|
7
7
|
import date from "#date";
|
|
8
|
+
import dict from "#dict";
|
|
8
9
|
import f32 from "#f32";
|
|
9
10
|
import f64 from "#f64";
|
|
10
11
|
import file from "#file";
|
|
@@ -17,7 +18,7 @@ import int from "#int";
|
|
|
17
18
|
import normalize from "#normalize";
|
|
18
19
|
import number from "#number";
|
|
19
20
|
import omit from "#omit";
|
|
20
|
-
import
|
|
21
|
+
import pure from "#pure";
|
|
21
22
|
import record from "#record";
|
|
22
23
|
import string from "#string";
|
|
23
24
|
import symbol from "#symbol";
|
|
@@ -29,6 +30,7 @@ import u8 from "#u8";
|
|
|
29
30
|
import uint from "#uint";
|
|
30
31
|
import union from "#union";
|
|
31
32
|
import unknown from "#unknown";
|
|
33
|
+
import url from "#url";
|
|
32
34
|
/**
|
|
33
35
|
* Create a schema.
|
|
34
36
|
*/
|
|
@@ -42,6 +44,7 @@ schema.blob = blob;
|
|
|
42
44
|
schema.boolean = boolean;
|
|
43
45
|
schema.constructor = constructor;
|
|
44
46
|
schema.date = date;
|
|
47
|
+
schema.dict = dict;
|
|
45
48
|
schema.f32 = f32;
|
|
46
49
|
schema.f64 = f64;
|
|
47
50
|
schema.file = file;
|
|
@@ -54,7 +57,7 @@ schema.int = int;
|
|
|
54
57
|
schema.number = number;
|
|
55
58
|
schema.omit = omit;
|
|
56
59
|
schema.record = record;
|
|
57
|
-
schema.
|
|
60
|
+
schema.pure = pure;
|
|
58
61
|
schema.string = string;
|
|
59
62
|
schema.symbol = symbol;
|
|
60
63
|
schema.u128 = u128;
|
|
@@ -65,5 +68,6 @@ schema.u8 = u8;
|
|
|
65
68
|
schema.uint = uint;
|
|
66
69
|
schema.union = union;
|
|
67
70
|
schema.unknown = unknown;
|
|
71
|
+
schema.url = url;
|
|
68
72
|
export default schema;
|
|
69
73
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type JSONIssue from "#json/JSONIssue";
|
|
2
|
-
import type JSONPointer from "@rcompat/type
|
|
2
|
+
import type { JSONPointer } from "@rcompat/type";
|
|
3
3
|
type JSONPayload = JSONIssue | Record<JSONPointer, JSONIssue>;
|
|
4
4
|
export type { JSONPayload as default };
|
|
5
5
|
//# sourceMappingURL=JSONPayload.d.ts.map
|
package/lib/private/normalize.js
CHANGED
|
@@ -6,7 +6,7 @@ import ObjectType from "#ObjectType";
|
|
|
6
6
|
import ParsedKey from "#ParsedKey";
|
|
7
7
|
import TupleType from "#TupleType";
|
|
8
8
|
import UndefinedType from "#UndefinedType";
|
|
9
|
-
import
|
|
9
|
+
import is from "@rcompat/is";
|
|
10
10
|
function isParsed(x) {
|
|
11
11
|
return !!x && typeof x === "object" && ParsedKey in x;
|
|
12
12
|
}
|
|
@@ -23,9 +23,8 @@ export default function normalize(x) {
|
|
|
23
23
|
return new UndefinedType();
|
|
24
24
|
if (typeof x === "string" || typeof x === "number" || typeof x === "boolean")
|
|
25
25
|
return new LiteralType(x);
|
|
26
|
-
if (newable(x))
|
|
26
|
+
if (is.newable(x))
|
|
27
27
|
return new ConstructorType(x);
|
|
28
|
-
}
|
|
29
28
|
if (Array.isArray(x)) {
|
|
30
29
|
return x.length === 1
|
|
31
30
|
? new ArrayType(normalize(x[0]))
|
package/lib/private/object.d.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type NormalizeSchema from "#NormalizeSchema";
|
|
2
2
|
import ObjectType from "#ObjectType";
|
|
3
3
|
import type Schema from "#Schema";
|
|
4
|
-
import type Dict from "@rcompat/type
|
|
5
|
-
|
|
6
|
-
type NormalizeProps<S extends Dict<Schema>> = keyof S extends never ? EO : {
|
|
4
|
+
import type { Dict, EmptyObject } from "@rcompat/type";
|
|
5
|
+
type NormalizeProps<S extends Dict<Schema>> = keyof S extends never ? EmptyObject : {
|
|
7
6
|
[K in keyof S]: NormalizeSchema<S[K]>;
|
|
8
7
|
};
|
|
9
8
|
export default function object<P extends Dict<Schema>>(properties: P): ObjectType<NormalizeProps<P>>;
|
package/lib/private/omit.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type ObjectType from "#ObjectType";
|
|
2
2
|
import OmitType from "#OmitType";
|
|
3
3
|
import type Parsed from "#Parsed";
|
|
4
|
-
import type Dict from "@rcompat/type
|
|
4
|
+
import type { Dict } from "@rcompat/type";
|
|
5
5
|
export default function omit<P extends Dict<Parsed<unknown>>, K extends keyof P>(type: ObjectType<P>, ...keys: K[]): OmitType<P, K>;
|
|
6
6
|
//# sourceMappingURL=omit.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import ParsedKey from "#ParsedKey";
|
|
2
2
|
import type ParseOptions from "#ParseOptions";
|
|
3
3
|
export default function next(s: number | string, options?: ParseOptions): {
|
|
4
|
-
[ParsedKey]: import("@rcompat/type
|
|
4
|
+
[ParsedKey]: import("@rcompat/type").JSONPointer;
|
|
5
5
|
coerce?: boolean;
|
|
6
6
|
partial?: boolean;
|
|
7
7
|
validators?: import("../Validator.js").default<unknown>[] | undefined;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type ParseIssue from "#ParseIssue";
|
|
2
|
-
export default function pathsOf(issues: ParseIssue[]): import("@rcompat/type
|
|
2
|
+
export default function pathsOf(issues: ParseIssue[]): import("@rcompat/type").JSONPointer[];
|
|
3
3
|
//# sourceMappingURL=paths-of.d.ts.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import fail from "#error/fail";
|
|
2
2
|
import schemafail from "#error/schemafail";
|
|
3
3
|
import ParseError from "#ParseError";
|
|
4
|
-
import
|
|
4
|
+
import is from "@rcompat/is";
|
|
5
5
|
export default function length(from, to) {
|
|
6
|
-
if (!
|
|
6
|
+
if (!is.finite(from) || !is.finite(to)) {
|
|
7
7
|
throw schemafail("length: {0} and {1} must be finite numbers", from, to);
|
|
8
8
|
}
|
|
9
9
|
if (from < 0 || to < 0) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import fail from "#error/fail";
|
|
2
2
|
import schemafail from "#error/schemafail";
|
|
3
|
-
import
|
|
3
|
+
import is from "@rcompat/is";
|
|
4
4
|
export default function max(limit) {
|
|
5
5
|
// validate limit once
|
|
6
6
|
if (typeof limit === "number") {
|
|
7
|
-
if (!
|
|
7
|
+
if (!is.finite(limit)) {
|
|
8
8
|
throw schemafail("max: limit {0} must be a finite number", limit);
|
|
9
9
|
}
|
|
10
10
|
return (x) => {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import fail from "#error/fail";
|
|
2
2
|
import schemafail from "#error/schemafail";
|
|
3
|
-
import
|
|
3
|
+
import is from "@rcompat/is";
|
|
4
4
|
export default function min(limit) {
|
|
5
5
|
// validate limit once
|
|
6
6
|
if (typeof limit === "number") {
|
|
7
|
-
if (!
|
|
7
|
+
if (!is.finite(limit)) {
|
|
8
8
|
throw schemafail("max: limit {0} must be a finite number", limit);
|
|
9
9
|
}
|
|
10
10
|
return (x) => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import ParseError from "#ParseError";
|
|
2
|
-
import
|
|
2
|
+
import is from "@rcompat/is";
|
|
3
3
|
const fail = (input, msg) => new ParseError([{ input, message: msg, path: "" }]);
|
|
4
4
|
export default function range(from, to) {
|
|
5
|
-
if (!
|
|
5
|
+
if (!is.finite(from) || !is.finite(to)) {
|
|
6
6
|
throw new TypeError("range(): from and to must be finite numbers");
|
|
7
7
|
}
|
|
8
8
|
return (x) => {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import ParseError from "#ParseError";
|
|
2
2
|
export default function values(input) {
|
|
3
|
-
const
|
|
3
|
+
const input_values = Object.values(input);
|
|
4
|
+
const allowed = input_values.map(v => String(v)).join(", ");
|
|
4
5
|
return (x) => {
|
|
5
|
-
if (!
|
|
6
|
+
if (!input_values.includes(x)) {
|
|
6
7
|
throw new ParseError([{
|
|
7
8
|
input: x,
|
|
8
9
|
message: `"${x}" not in given list of values (${allowed})`,
|
package/lib/public/index.d.ts
CHANGED
|
@@ -1,11 +1,30 @@
|
|
|
1
|
+
export { default as ArrayType } from "#ArrayType";
|
|
2
|
+
export { default as BooleanType } from "#BooleanType";
|
|
1
3
|
export { default as ConstructorType } from "#ConstructorType";
|
|
2
4
|
export { default as DefaultType } from "#DefaultType";
|
|
3
5
|
export { default } from "#index";
|
|
4
6
|
export { default as LiteralType } from "#LiteralType";
|
|
7
|
+
export { default as NumberType } from "#NumberType";
|
|
5
8
|
export { default as ObjectType } from "#ObjectType";
|
|
6
9
|
export { default as OptionalType } from "#OptionalType";
|
|
7
10
|
export { default as PureType } from "#PureType";
|
|
11
|
+
export { default as RecordType } from "#RecordType";
|
|
12
|
+
export { default as StringType } from "#StringType";
|
|
8
13
|
export { default as TupleType } from "#TupleType";
|
|
14
|
+
export { default as UintType } from "#UintType";
|
|
9
15
|
export { default as UndefinedType } from "#UndefinedType";
|
|
10
|
-
export { default as
|
|
16
|
+
export { default as UnionType } from "#UnionType";
|
|
17
|
+
export { default as UnknownType } from "#UnknownType";
|
|
18
|
+
export type { default as DataKey } from "#DataKey";
|
|
19
|
+
export type { default as DataType } from "#DataType";
|
|
20
|
+
export type { default as Id } from "#Id";
|
|
21
|
+
export type { default as InferStore } from "#InferStore";
|
|
22
|
+
export type { default as InferStoreOut } from "#InferStoreOut";
|
|
23
|
+
export type { default as Issue } from "#Issue";
|
|
24
|
+
export type { default as JSONPayload } from "#json/JSONPayload";
|
|
25
|
+
export type { default as Schema } from "#Schema";
|
|
26
|
+
export type { default as Serialized } from "#Serialized";
|
|
27
|
+
export type { default as Storable } from "#Storable";
|
|
28
|
+
export type { default as StoreId } from "#StoreId";
|
|
29
|
+
export type { default as StoreSchema } from "#StoreSchema";
|
|
11
30
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/public/index.js
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
|
+
export { default as ArrayType } from "#ArrayType";
|
|
2
|
+
export { default as BooleanType } from "#BooleanType";
|
|
1
3
|
export { default as ConstructorType } from "#ConstructorType";
|
|
2
4
|
export { default as DefaultType } from "#DefaultType";
|
|
3
5
|
export { default } from "#index";
|
|
4
6
|
export { default as LiteralType } from "#LiteralType";
|
|
7
|
+
export { default as NumberType } from "#NumberType";
|
|
5
8
|
export { default as ObjectType } from "#ObjectType";
|
|
6
9
|
export { default as OptionalType } from "#OptionalType";
|
|
7
10
|
export { default as PureType } from "#PureType";
|
|
11
|
+
export { default as RecordType } from "#RecordType";
|
|
12
|
+
export { default as StringType } from "#StringType";
|
|
8
13
|
export { default as TupleType } from "#TupleType";
|
|
14
|
+
export { default as UintType } from "#UintType";
|
|
9
15
|
export { default as UndefinedType } from "#UndefinedType";
|
|
10
|
-
export { default as
|
|
16
|
+
export { default as UnionType } from "#UnionType";
|
|
17
|
+
export { default as UnknownType } from "#UnknownType";
|
|
11
18
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pema",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Primate schema validation",
|
|
5
5
|
"homepage": "https://primate.run/docs/validation",
|
|
6
6
|
"bugs": "https://github.com/primate-run/primate/issues",
|
|
7
|
+
"type": "module",
|
|
7
8
|
"license": "MIT",
|
|
8
|
-
"files": [
|
|
9
|
-
"/lib/**/*.js",
|
|
10
|
-
"/lib/**/*.d.ts",
|
|
11
|
-
"!/**/*.spec.*"
|
|
12
|
-
],
|
|
13
9
|
"repository": {
|
|
14
10
|
"type": "git",
|
|
15
11
|
"url": "https://github.com/primate-run/primate",
|
|
16
12
|
"directory": "packages/pema"
|
|
17
13
|
},
|
|
14
|
+
"files": [
|
|
15
|
+
"/lib/**/*.js",
|
|
16
|
+
"/lib/**/*.d.ts",
|
|
17
|
+
"!/**/*.spec.*"
|
|
18
|
+
],
|
|
18
19
|
"dependencies": {
|
|
19
|
-
"@rcompat/assert": "^0.
|
|
20
|
-
"@rcompat/cli": "^0.
|
|
21
|
-
"@rcompat/is": "^0.
|
|
22
|
-
|
|
20
|
+
"@rcompat/assert": "^0.6.0",
|
|
21
|
+
"@rcompat/cli": "^0.14.0",
|
|
22
|
+
"@rcompat/is": "^0.4.2"
|
|
23
|
+
},
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@rcompat/type": "^0.9.0"
|
|
23
26
|
},
|
|
24
|
-
"type": "module",
|
|
25
27
|
"imports": {
|
|
26
28
|
"#*": {
|
|
27
29
|
"apekit": "./src/private/*.ts",
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type ArrayType from "#ArrayType";
|
|
2
|
-
import type DecrementDepth from "#DecrementDepth";
|
|
3
|
-
import type Infer from "#Infer";
|
|
4
|
-
import type NullType from "#NullType";
|
|
5
|
-
import type Parsed from "#Parsed";
|
|
6
|
-
import type Schema from "#Schema";
|
|
7
|
-
import type TupleType from "#TupleType";
|
|
8
|
-
import type UndefinedType from "#UndefinedType";
|
|
9
|
-
import type UndefinedToOptional from "@rcompat/type/UndefinedToOptional";
|
|
10
|
-
type InferSchema<S, Depth extends number = 3> = [
|
|
11
|
-
Depth
|
|
12
|
-
] extends [never] ? never : S extends Parsed<unknown> ? Infer<S> : S extends null ? Infer<NullType> : S extends undefined ? Infer<UndefinedType> : S extends [infer Only] ? Only extends Parsed<unknown> ? Infer<ArrayType<Only>> : never : S extends Schema[] ? InferSchema<TupleType<{
|
|
13
|
-
[K in keyof S]: S[K] extends Parsed<unknown> ? InferSchema<S[K], DecrementDepth[Depth]> : never;
|
|
14
|
-
}>> : S extends {
|
|
15
|
-
[key: string]: Schema;
|
|
16
|
-
} ? UndefinedToOptional<{
|
|
17
|
-
[K in keyof S]: InferSchema<S[K], DecrementDepth[Depth]>;
|
|
18
|
-
}> : never;
|
|
19
|
-
export type { InferSchema as default };
|
|
20
|
-
//# sourceMappingURL=InferSchema.d.ts.map
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type Infer from "#Infer";
|
|
2
|
-
import type ParseOptions from "#ParseOptions";
|
|
3
|
-
import PrimitiveType from "#PrimitiveType";
|
|
4
|
-
import Storeable from "#Storeable";
|
|
5
|
-
export default class PrimaryType extends PrimitiveType<string | undefined, "PrimaryType"> implements Storeable<"primary"> {
|
|
6
|
-
get name(): "primary";
|
|
7
|
-
get datatype(): "primary";
|
|
8
|
-
parse(x: unknown, options?: ParseOptions): Infer<this>;
|
|
9
|
-
toJSON(): {
|
|
10
|
-
type: "primary";
|
|
11
|
-
datatype: "primary";
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=PrimaryType.d.ts.map
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import error from "#error";
|
|
2
|
-
import ParseError from "#ParseError";
|
|
3
|
-
import PrimitiveType from "#PrimitiveType";
|
|
4
|
-
import Storeable from "#Storeable";
|
|
5
|
-
export default class PrimaryType extends PrimitiveType {
|
|
6
|
-
get name() {
|
|
7
|
-
return "primary";
|
|
8
|
-
}
|
|
9
|
-
get datatype() {
|
|
10
|
-
return "primary";
|
|
11
|
-
}
|
|
12
|
-
parse(x, options = {}) {
|
|
13
|
-
// the primary type is an optional ype
|
|
14
|
-
if (x === undefined) {
|
|
15
|
-
return x;
|
|
16
|
-
}
|
|
17
|
-
if (typeof x !== "string") {
|
|
18
|
-
throw new ParseError(error(this.name, x, options));
|
|
19
|
-
}
|
|
20
|
-
return x;
|
|
21
|
-
}
|
|
22
|
-
toJSON() {
|
|
23
|
-
return Storeable.serialize(this);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=PrimaryType.js.map
|
package/lib/private/primary.d.ts
DELETED
package/lib/private/primary.js
DELETED
package/lib/public/DataType.d.ts
DELETED
package/lib/public/DataType.js
DELETED
package/lib/public/Id.d.ts
DELETED
package/lib/public/Id.js
DELETED
package/lib/public/InferStore.js
DELETED
package/lib/public/Issue.d.ts
DELETED
package/lib/public/Issue.js
DELETED
package/lib/public/OmitType.d.ts
DELETED
package/lib/public/OmitType.js
DELETED
package/lib/public/Schema.d.ts
DELETED
package/lib/public/Schema.js
DELETED
package/lib/public/Serialized.js
DELETED
package/lib/public/StoreId.d.ts
DELETED
package/lib/public/StoreId.js
DELETED
package/lib/public/array.d.ts
DELETED
package/lib/public/array.js
DELETED
package/lib/public/bigint.d.ts
DELETED
package/lib/public/bigint.js
DELETED
package/lib/public/biguint.d.ts
DELETED
package/lib/public/biguint.js
DELETED
package/lib/public/blob.d.ts
DELETED
package/lib/public/blob.js
DELETED
package/lib/public/boolean.d.ts
DELETED
package/lib/public/boolean.js
DELETED
package/lib/public/date.d.ts
DELETED
package/lib/public/date.js
DELETED
package/lib/public/f32.d.ts
DELETED
package/lib/public/f32.js
DELETED
package/lib/public/f64.d.ts
DELETED
package/lib/public/f64.js
DELETED
package/lib/public/file.d.ts
DELETED
package/lib/public/file.js
DELETED
package/lib/public/i128.d.ts
DELETED
package/lib/public/i128.js
DELETED
package/lib/public/i16.d.ts
DELETED
package/lib/public/i16.js
DELETED
package/lib/public/i32.d.ts
DELETED
package/lib/public/i32.js
DELETED
package/lib/public/i64.d.ts
DELETED
package/lib/public/i64.js
DELETED
package/lib/public/i8.d.ts
DELETED