pema 0.1.0 → 0.2.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/LICENSE +19 -0
- package/lib/private/ArrayType.d.ts +28 -5
- package/lib/private/ArrayType.js +82 -22
- package/lib/private/BigIntDataType.d.ts +3 -0
- package/lib/private/BigIntDataType.js +2 -0
- package/lib/private/BigIntType.d.ts +8 -3
- package/lib/private/BigIntType.js +7 -4
- package/lib/private/BigUintDataType.d.ts +3 -0
- package/lib/private/BigUintDataType.js +2 -0
- package/lib/private/BigUintType.d.ts +10 -0
- package/lib/private/BigUintType.js +10 -0
- package/lib/private/BlobType.d.ts +12 -2
- package/lib/private/BlobType.js +12 -2
- package/lib/private/BooleanType.d.ts +10 -2
- package/lib/private/BooleanType.js +14 -2
- package/lib/private/BuiltinType.d.ts +7 -5
- package/lib/private/BuiltinType.js +18 -17
- package/lib/private/CoerceKey.d.ts +4 -0
- package/lib/private/CoerceKey.js +3 -0
- package/lib/private/ConstructorType.d.ts +10 -4
- package/lib/private/ConstructorType.js +13 -11
- package/lib/private/DataKey.d.ts +4 -0
- package/lib/private/DataKey.js +2 -0
- package/lib/private/DataType.d.ts +23 -0
- package/lib/private/DataType.js +2 -0
- package/lib/private/DateType.d.ts +12 -2
- package/lib/private/DateType.js +15 -2
- package/lib/private/DecrementDepth.d.ts +3 -0
- package/lib/private/DecrementDepth.js +2 -0
- package/lib/private/DefaultType.d.ts +13 -6
- package/lib/private/DefaultType.js +19 -11
- package/lib/private/FileType.d.ts +12 -2
- package/lib/private/FileType.js +12 -2
- package/lib/private/FloatDataType.d.ts +3 -0
- package/lib/private/FloatDataType.js +2 -0
- package/lib/private/GenericType.d.ts +2 -2
- package/lib/private/GenericType.js +2 -2
- package/lib/private/Id.d.ts +3 -0
- package/lib/private/Id.js +2 -0
- package/lib/private/Infer.d.ts +2 -2
- package/lib/private/InferInputSchema.d.ts +26 -0
- package/lib/private/InferInputSchema.js +2 -0
- package/lib/private/InferSchema.d.ts +5 -5
- package/lib/private/InferStore.d.ts +9 -0
- package/lib/private/InferStore.js +2 -0
- package/lib/private/InferStoreOut.d.ts +8 -0
- package/lib/private/InferStoreOut.js +2 -0
- package/lib/private/IntDataType.d.ts +3 -0
- package/lib/private/IntDataType.js +2 -0
- package/lib/private/IntType.d.ts +10 -5
- package/lib/private/IntType.js +13 -12
- package/lib/private/Issue.d.ts +6 -0
- package/lib/private/Issue.js +2 -0
- package/lib/private/LiteralType.d.ts +9 -2
- package/lib/private/LiteralType.js +17 -9
- package/lib/private/NormalizeSchema.d.ts +12 -7
- package/lib/private/NullType.d.ts +6 -2
- package/lib/private/NullType.js +11 -11
- package/lib/private/NumberType.d.ts +7 -3
- package/lib/private/NumberType.js +7 -4
- package/lib/private/NumericType.d.ts +25 -0
- package/lib/private/NumericType.js +38 -0
- package/lib/private/ObjectType.d.ts +23 -0
- package/lib/private/ObjectType.js +53 -0
- package/lib/private/OptionalType.d.ts +12 -5
- package/lib/private/OptionalType.js +16 -4
- package/lib/private/ParseError.d.ts +10 -0
- package/lib/private/ParseError.js +51 -0
- package/lib/private/ParseIssue.d.ts +5 -0
- package/lib/private/ParseIssue.js +2 -0
- package/lib/private/ParseOptions.d.ts +10 -0
- package/lib/private/ParseOptions.js +3 -0
- package/lib/private/Parsed.d.ts +24 -0
- package/lib/private/Parsed.js +17 -0
- package/lib/private/ParsedKey.d.ts +4 -0
- package/lib/private/ParsedKey.js +3 -0
- package/lib/private/PartialType.d.ts +25 -0
- package/lib/private/PartialType.js +69 -0
- package/lib/private/Partialable.d.ts +5 -0
- package/lib/private/Partialable.js +2 -0
- package/lib/private/PrimaryType.d.ts +14 -0
- package/lib/private/PrimaryType.js +26 -0
- package/lib/private/PrimitiveType.d.ts +12 -4
- package/lib/private/PrimitiveType.js +50 -17
- package/lib/private/PureType.d.ts +15 -0
- package/lib/private/PureType.js +21 -0
- package/lib/private/RecordType.d.ts +19 -4
- package/lib/private/RecordType.js +43 -14
- package/lib/private/RecordTypeKey.d.ts +1 -1
- package/lib/private/Schema.d.ts +3 -3
- package/lib/private/SchemaError.d.ts +4 -0
- package/lib/private/SchemaError.js +8 -0
- package/lib/private/Serialized.d.ts +72 -0
- package/lib/private/Serialized.js +2 -0
- package/lib/private/StoreId.d.ts +6 -0
- package/lib/private/StoreId.js +2 -0
- package/lib/private/StoreSchema.d.ts +8 -0
- package/lib/private/StoreSchema.js +2 -0
- package/lib/private/StoreType.d.ts +21 -0
- package/lib/private/StoreType.js +45 -0
- package/lib/private/Storeable.d.ts +15 -0
- package/lib/private/Storeable.js +7 -0
- package/lib/private/StringType.d.ts +17 -5
- package/lib/private/StringType.js +47 -13
- package/lib/private/SymbolType.d.ts +4 -1
- package/lib/private/SymbolType.js +5 -2
- package/lib/private/TupleType.d.ts +11 -4
- package/lib/private/TupleType.js +16 -22
- package/lib/private/Type.d.ts +5 -3
- package/lib/private/Type.js +2 -2
- package/lib/private/URLType.d.ts +16 -2
- package/lib/private/URLType.js +12 -2
- package/lib/private/UintDataType.d.ts +3 -0
- package/lib/private/UintDataType.js +2 -0
- package/lib/private/UintType.d.ts +14 -7
- package/lib/private/UintType.js +20 -12
- package/lib/private/UndefinedType.d.ts +4 -1
- package/lib/private/UndefinedType.js +7 -2
- package/lib/private/UnionType.d.ts +15 -4
- package/lib/private/UnionType.js +32 -26
- package/lib/private/UnknownType.d.ts +5 -0
- package/lib/private/UnknownType.js +7 -0
- package/lib/private/Validator.d.ts +1 -1
- package/lib/private/VirtualType.d.ts +6 -0
- package/lib/private/VirtualType.js +11 -0
- package/lib/private/array.d.ts +6 -3
- package/lib/private/array.js +7 -1
- package/lib/private/bigint.d.ts +1 -3
- package/lib/private/bigint.js +1 -2
- package/lib/private/biguint.d.ts +2 -0
- package/lib/private/biguint.js +2 -0
- package/lib/private/boolean.d.ts +3 -0
- package/lib/private/boolean.js +3 -0
- package/lib/private/coerce/bigint.d.ts +2 -0
- package/lib/private/coerce/bigint.js +13 -0
- package/lib/private/coerce/date.d.ts +2 -0
- package/lib/private/coerce/date.js +56 -0
- package/lib/private/coerce/int.d.ts +2 -0
- package/lib/private/coerce/int.js +8 -0
- package/lib/private/constructor.d.ts +5 -2
- package/lib/private/constructor.js +3 -0
- package/lib/private/error/fail.d.ts +3 -0
- package/lib/private/error/fail.js +5 -0
- package/lib/private/error/schemafail.d.ts +3 -0
- package/lib/private/error/schemafail.js +5 -0
- package/lib/private/error.d.ts +3 -2
- package/lib/private/error.js +10 -3
- package/lib/private/expect.d.ts +12 -11
- package/lib/private/expect.js +22 -11
- package/lib/private/expected.js +10 -1
- package/lib/private/f32.d.ts +4 -0
- package/lib/private/f32.js +4 -0
- package/lib/private/f64.d.ts +4 -0
- package/lib/private/f64.js +3 -0
- package/lib/private/i128.d.ts +4 -0
- package/lib/private/i128.js +6 -0
- package/lib/private/i16.d.ts +4 -0
- package/lib/private/i16.js +6 -0
- package/lib/private/i32.d.ts +4 -0
- package/lib/private/i32.js +6 -0
- package/lib/private/i64.d.ts +4 -0
- package/lib/private/i64.js +6 -0
- package/lib/private/i8.d.ts +4 -0
- package/lib/private/i8.js +6 -0
- package/lib/private/index.d.ts +4 -2
- package/lib/private/index.js +5 -40
- package/lib/private/int.d.ts +1 -3
- package/lib/private/int.js +1 -2
- package/lib/private/is-parsed-type.d.ts +3 -0
- package/lib/private/is-parsed-type.js +6 -0
- package/lib/private/json/JSONIssue.d.ts +6 -0
- package/lib/private/json/JSONIssue.js +2 -0
- package/lib/private/json/JSONPayload.d.ts +5 -0
- package/lib/private/json/JSONPayload.js +2 -0
- package/lib/private/literal.d.ts +1 -2
- package/lib/private/literal.js +1 -1
- package/lib/private/normalize.d.ts +4 -0
- package/lib/private/normalize.js +42 -0
- package/lib/private/number.d.ts +1 -3
- package/lib/private/number.js +1 -2
- package/lib/private/object.d.ts +11 -0
- package/lib/private/object.js +10 -0
- package/lib/private/optional.d.ts +2 -2
- package/lib/private/partial.d.ts +9 -0
- package/lib/private/partial.js +8 -0
- package/lib/private/path/join.d.ts +3 -0
- package/lib/private/path/join.js +13 -0
- package/lib/private/path/next.d.ts +9 -0
- package/lib/private/path/next.js +9 -0
- package/lib/private/path/rebase.d.ts +3 -0
- package/lib/private/path/rebase.js +9 -0
- package/lib/private/primary.d.ts +4 -0
- package/lib/private/primary.js +3 -0
- package/lib/private/pure.d.ts +3 -0
- package/lib/private/pure.js +5 -0
- package/lib/private/record.d.ts +5 -2
- package/lib/private/record.js +3 -0
- package/lib/private/spec/bigint.d.ts +5 -0
- package/lib/private/spec/bigint.js +73 -0
- package/lib/private/spec/biguint.d.ts +5 -0
- package/lib/private/spec/biguint.js +73 -0
- package/lib/private/spec/int.d.ts +5 -0
- package/lib/private/spec/int.js +70 -0
- package/lib/private/spec/uint.d.ts +5 -0
- package/lib/private/spec/uint.js +73 -0
- package/lib/private/string.d.ts +3 -0
- package/lib/private/string.js +3 -0
- package/lib/private/test/messages-of.d.ts +3 -0
- package/lib/private/test/messages-of.js +4 -0
- package/lib/private/test/paths-of.d.ts +3 -0
- package/lib/private/test/paths-of.js +4 -0
- package/lib/private/test/throws-issues.d.ts +4 -0
- package/lib/private/test/throws-issues.js +13 -0
- package/lib/private/trait/Default.d.ts +9 -0
- package/lib/private/trait/Default.js +4 -0
- package/lib/private/trait/Optional.d.ts +11 -0
- package/lib/private/trait/Optional.js +4 -0
- package/lib/private/tuple.d.ts +6 -2
- package/lib/private/tuple.js +6 -1
- package/lib/private/u128.d.ts +4 -0
- package/lib/private/u128.js +6 -0
- package/lib/private/u16.d.ts +4 -0
- package/lib/private/u16.js +6 -0
- package/lib/private/u32.d.ts +7 -0
- package/lib/private/u32.js +9 -0
- package/lib/private/u64.d.ts +4 -0
- package/lib/private/u64.js +6 -0
- package/lib/private/u8.d.ts +4 -0
- package/lib/private/u8.js +6 -0
- package/lib/private/uint.d.ts +1 -3
- package/lib/private/uint.js +1 -2
- package/lib/private/union.d.ts +6 -5
- package/lib/private/union.js +4 -1
- package/lib/private/unknown.d.ts +7 -0
- package/lib/private/unknown.js +6 -0
- package/lib/private/validator/email.d.ts +3 -0
- package/lib/private/validator/email.js +4 -0
- package/lib/private/validator/ends-with.d.ts +4 -0
- package/lib/private/validator/ends-with.js +11 -0
- package/lib/private/validator/f32.d.ts +2 -0
- package/lib/private/validator/f32.js +11 -0
- package/lib/private/validator/integer.d.ts +3 -0
- package/lib/private/validator/integer.js +12 -0
- package/lib/private/validator/isotime.d.ts +2 -0
- package/lib/private/validator/isotime.js +30 -0
- package/lib/private/validator/length.d.ts +5 -0
- package/lib/private/validator/length.js +29 -0
- package/lib/private/validator/max.d.ts +6 -0
- package/lib/private/validator/max.js +37 -0
- package/lib/private/validator/min.d.ts +6 -0
- package/lib/private/validator/min.js +37 -0
- package/lib/private/validator/port.d.ts +3 -0
- package/lib/private/validator/port.js +15 -0
- package/lib/private/validator/range.d.ts +3 -0
- package/lib/private/validator/range.js +22 -0
- package/lib/private/validator/regex.d.ts +5 -0
- package/lib/private/validator/regex.js +15 -0
- package/lib/private/validator/starts-with.d.ts +4 -0
- package/lib/private/validator/starts-with.js +11 -0
- package/lib/private/validator/unique-by.d.ts +2 -0
- package/lib/private/validator/unique-by.js +23 -0
- package/lib/private/validator/unique-with.d.ts +2 -0
- package/lib/private/validator/unique-with.js +18 -0
- package/lib/private/validator/unique.d.ts +2 -0
- package/lib/private/validator/unique.js +19 -0
- package/lib/private/validator/uuid.d.ts +3 -0
- package/lib/private/validator/uuid.js +4 -0
- package/lib/private/validator/values.d.ts +4 -0
- package/lib/private/validator/values.js +14 -0
- package/lib/public/DataType.d.ts +2 -0
- package/lib/public/DataType.js +2 -0
- package/lib/public/Id.d.ts +2 -0
- package/lib/public/Id.js +2 -0
- package/lib/public/InferStore.d.ts +2 -0
- package/lib/public/InferStore.js +2 -0
- package/lib/public/InferStoreOut.d.ts +2 -0
- package/lib/public/InferStoreOut.js +2 -0
- package/lib/public/Issue.d.ts +2 -0
- package/lib/public/Issue.js +2 -0
- package/lib/public/JSONPayload.d.ts +2 -0
- package/lib/public/JSONPayload.js +2 -0
- package/lib/public/ParseError.d.ts +2 -0
- package/lib/public/ParseError.js +2 -0
- package/lib/public/Serialized.d.ts +2 -0
- package/lib/public/Serialized.js +2 -0
- package/lib/public/StoreId.d.ts +2 -0
- package/lib/public/StoreId.js +2 -0
- package/lib/public/StoreSchema.d.ts +2 -0
- package/lib/public/StoreSchema.js +2 -0
- package/lib/public/StoreType.d.ts +3 -0
- package/lib/public/StoreType.js +2 -0
- package/lib/public/array.d.ts +3 -0
- package/lib/public/array.js +3 -0
- package/lib/public/bigint.d.ts +2 -0
- package/lib/public/bigint.js +2 -0
- package/lib/public/biguint.d.ts +2 -0
- package/lib/public/biguint.js +2 -0
- package/lib/public/boolean.d.ts +1 -0
- package/lib/public/boolean.js +1 -0
- package/lib/public/constructor.d.ts +1 -0
- package/lib/public/constructor.js +1 -0
- package/lib/public/f32.d.ts +2 -0
- package/lib/public/f32.js +2 -0
- package/lib/public/f64.d.ts +2 -0
- package/lib/public/f64.js +2 -0
- package/lib/public/i128.d.ts +2 -0
- package/lib/public/i128.js +2 -0
- package/lib/public/i16.d.ts +2 -0
- package/lib/public/i16.js +2 -0
- package/lib/public/i32.d.ts +2 -0
- package/lib/public/i32.js +2 -0
- package/lib/public/i64.d.ts +2 -0
- package/lib/public/i64.js +2 -0
- package/lib/public/i8.d.ts +2 -0
- package/lib/public/i8.js +2 -0
- package/lib/public/index.d.ts +6 -0
- package/lib/public/index.js +6 -0
- package/lib/public/number.d.ts +1 -0
- package/lib/public/number.js +1 -0
- package/lib/public/primary.d.ts +2 -0
- package/lib/public/primary.js +2 -0
- package/lib/public/pure.d.ts +2 -0
- package/lib/public/pure.js +2 -0
- package/lib/public/record.d.ts +1 -0
- package/lib/public/record.js +1 -0
- package/lib/public/string.d.ts +1 -0
- package/lib/public/string.js +1 -0
- package/lib/public/u128.d.ts +2 -0
- package/lib/public/u128.js +2 -0
- package/lib/public/u16.d.ts +2 -0
- package/lib/public/u16.js +2 -0
- package/lib/public/u32.d.ts +2 -0
- package/lib/public/u32.js +2 -0
- package/lib/public/u64.d.ts +2 -0
- package/lib/public/u64.js +2 -0
- package/lib/public/u8.d.ts +2 -0
- package/lib/public/u8.js +2 -0
- package/lib/public/uint.d.ts +3 -0
- package/lib/public/uint.js +3 -0
- package/lib/public/union.d.ts +1 -0
- package/lib/public/union.js +1 -0
- package/lib/public/unknown.d.ts +3 -0
- package/lib/public/unknown.js +2 -0
- package/package.json +14 -11
- package/lib/private/AbstractConstructor.d.ts +0 -3
- package/lib/private/AbstractConstructor.js +0 -2
- package/lib/private/MaybeInt.d.ts +0 -3
- package/lib/private/MaybeInt.js +0 -2
- package/lib/private/SchemaType.d.ts +0 -13
- package/lib/private/SchemaType.js +0 -63
- package/lib/private/Validated.d.ts +0 -8
- package/lib/private/Validated.js +0 -10
- package/lib/private/ValidatedKey.d.ts +0 -4
- package/lib/private/ValidatedKey.js +0 -3
- package/lib/private/is-int.d.ts +0 -3
- package/lib/private/is-int.js +0 -5
- package/lib/private/is_validated_type.d.ts +0 -4
- package/lib/private/is_validated_type.js +0 -5
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import BuiltinType from "#BuiltinType";
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import Storeable from "#Storeable";
|
|
3
|
+
export default class FileType extends BuiltinType<File, "FileType"> implements Storeable<"blob"> {
|
|
4
|
+
get Type(): {
|
|
5
|
+
new (fileBits: BlobPart[], fileName: string, options?: FilePropertyBag): File;
|
|
6
|
+
prototype: File;
|
|
7
|
+
};
|
|
8
|
+
get name(): "file";
|
|
9
|
+
get datatype(): "blob";
|
|
10
|
+
toJSON(): {
|
|
11
|
+
type: "file";
|
|
12
|
+
datatype: "blob";
|
|
13
|
+
};
|
|
4
14
|
}
|
|
5
15
|
//# sourceMappingURL=FileType.d.ts.map
|
package/lib/private/FileType.js
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
1
|
import BuiltinType from "#BuiltinType";
|
|
2
|
+
import Storeable from "#Storeable";
|
|
2
3
|
export default class FileType extends BuiltinType {
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
get Type() {
|
|
5
|
+
return File;
|
|
6
|
+
}
|
|
7
|
+
get name() {
|
|
8
|
+
return "file";
|
|
9
|
+
}
|
|
10
|
+
get datatype() {
|
|
11
|
+
return "blob";
|
|
12
|
+
}
|
|
13
|
+
toJSON() {
|
|
14
|
+
return Storeable.serialize(this);
|
|
5
15
|
}
|
|
6
16
|
}
|
|
7
17
|
//# sourceMappingURL=FileType.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import Parsed from "#Parsed";
|
|
2
2
|
import type PrintableGeneric from "@rcompat/type/PrintableGeneric";
|
|
3
|
-
export default abstract class GenericType<Type, Inferred, Name extends string> extends
|
|
3
|
+
export default abstract class GenericType<Type, Inferred, Name extends string> extends Parsed<Inferred> implements PrintableGeneric<Type> {
|
|
4
4
|
get Name(): Name;
|
|
5
5
|
get Type(): Type;
|
|
6
6
|
}
|
package/lib/private/Infer.d.ts
CHANGED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type ArrayType from "#ArrayType";
|
|
2
|
+
import type DecrementDepth from "#DecrementDepth";
|
|
3
|
+
import type DefaultType from "#DefaultType";
|
|
4
|
+
import type Infer from "#Infer";
|
|
5
|
+
import type NullType from "#NullType";
|
|
6
|
+
import type ObjectType from "#ObjectType";
|
|
7
|
+
import type OptionalType from "#OptionalType";
|
|
8
|
+
import type Parsed from "#Parsed";
|
|
9
|
+
import type Schema from "#Schema";
|
|
10
|
+
import type TupleType from "#TupleType";
|
|
11
|
+
import type UndefinedType from "#UndefinedType";
|
|
12
|
+
import type ImpliedOptional from "@rcompat/type/ImpliedOptional";
|
|
13
|
+
import type UndefinedToOptional from "@rcompat/type/UndefinedToOptional";
|
|
14
|
+
type InferInputSchema<S, Depth extends number = 3> = [
|
|
15
|
+
Depth
|
|
16
|
+
] extends [never] ? never : S extends DefaultType<infer T, unknown> ? Infer<T> | undefined : S extends OptionalType<infer T> ? Infer<T> | undefined : S extends ObjectType<infer P> ? ImpliedOptional<UndefinedToOptional<{
|
|
17
|
+
[K in keyof P]: InferInputSchema<P[K], DecrementDepth[Depth]>;
|
|
18
|
+
}>> : 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[] ? InferInputSchema<TupleType<{
|
|
19
|
+
[K in keyof S]: S[K] extends Parsed<unknown> ? InferInputSchema<S[K], DecrementDepth[Depth]> : never;
|
|
20
|
+
}>> : S extends {
|
|
21
|
+
[key: string]: Schema;
|
|
22
|
+
} ? ImpliedOptional<UndefinedToOptional<{
|
|
23
|
+
[K in keyof S]: InferInputSchema<S[K], DecrementDepth[Depth]>;
|
|
24
|
+
}>> : never;
|
|
25
|
+
export type { InferInputSchema as default };
|
|
26
|
+
//# sourceMappingURL=InferInputSchema.d.ts.map
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import type ArrayType from "#ArrayType";
|
|
2
|
+
import type DecrementDepth from "#DecrementDepth";
|
|
2
3
|
import type Infer from "#Infer";
|
|
3
4
|
import type NullType from "#NullType";
|
|
5
|
+
import type Parsed from "#Parsed";
|
|
4
6
|
import type Schema from "#Schema";
|
|
5
7
|
import type TupleType from "#TupleType";
|
|
6
8
|
import type UndefinedType from "#UndefinedType";
|
|
7
|
-
import type Validated from "#Validated";
|
|
8
9
|
import type UndefinedToOptional from "@rcompat/type/UndefinedToOptional";
|
|
9
|
-
type
|
|
10
|
-
type InferSchema<S, Depth extends number = 4> = [
|
|
10
|
+
type InferSchema<S, Depth extends number = 3> = [
|
|
11
11
|
Depth
|
|
12
|
-
] extends [never] ? never : S extends
|
|
13
|
-
[K in keyof S]: S[K] extends
|
|
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
14
|
}>> : S extends {
|
|
15
15
|
[key: string]: Schema;
|
|
16
16
|
} ? UndefinedToOptional<{
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type Parsed from "#Parsed";
|
|
2
|
+
import type StoreSchema from "#StoreSchema";
|
|
3
|
+
import type UndefinedToOptional from "@rcompat/type/UndefinedToOptional";
|
|
4
|
+
type StoreValue<T> = T extends Parsed<infer U> ? U : never;
|
|
5
|
+
type InferStore<T extends StoreSchema> = UndefinedToOptional<{
|
|
6
|
+
[K in keyof T]: StoreValue<T[K]>;
|
|
7
|
+
}>;
|
|
8
|
+
export type { InferStore as default };
|
|
9
|
+
//# sourceMappingURL=InferStore.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type InferStore from "#InferStore";
|
|
2
|
+
import type StoreId from "#StoreId";
|
|
3
|
+
import type StoreSchema from "#StoreSchema";
|
|
4
|
+
type InferStoreOut<T extends StoreSchema> = Omit<InferStore<T>, "id"> & {
|
|
5
|
+
id: StoreId<T>;
|
|
6
|
+
};
|
|
7
|
+
export type { InferStoreOut as default };
|
|
8
|
+
//# sourceMappingURL=InferStoreOut.d.ts.map
|
package/lib/private/IntType.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import coerce from "#coerce/int";
|
|
2
|
+
import CoerceKey from "#CoerceKey";
|
|
3
|
+
import type IntDataType from "#IntDataType";
|
|
4
|
+
import NumericType from "#NumericType";
|
|
5
|
+
import type ParseOptions from "#ParseOptions";
|
|
6
|
+
import type Storeable from "#Storeable";
|
|
7
|
+
export default class IntType<T extends IntDataType> extends NumericType<T, number, "IntType"> implements Storeable<T> {
|
|
8
|
+
[CoerceKey]: typeof coerce;
|
|
9
|
+
get name(): string;
|
|
10
|
+
parse(x: unknown, options?: ParseOptions<number>): import("./Infer.js").default<this>;
|
|
6
11
|
}
|
|
7
12
|
//# sourceMappingURL=IntType.d.ts.map
|
package/lib/private/IntType.js
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
export default class IntType extends
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import coerce from "#coerce/int";
|
|
2
|
+
import CoerceKey from "#CoerceKey";
|
|
3
|
+
import NumericType from "#NumericType";
|
|
4
|
+
import integer from "#validator/integer";
|
|
5
|
+
export default class IntType extends NumericType {
|
|
6
|
+
[CoerceKey] = coerce;
|
|
7
|
+
get name() {
|
|
8
|
+
return "number";
|
|
8
9
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
parse(x, options = {}) {
|
|
11
|
+
return super.parse(x, {
|
|
12
|
+
...options,
|
|
13
|
+
validators: [integer],
|
|
14
|
+
});
|
|
14
15
|
}
|
|
15
16
|
}
|
|
16
17
|
//# sourceMappingURL=IntType.js.map
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import GenericType from "#GenericType";
|
|
2
2
|
import type Infer from "#Infer";
|
|
3
|
-
type
|
|
3
|
+
import type ParseOptions from "#ParseOptions";
|
|
4
|
+
type Literal = string | boolean | number;
|
|
4
5
|
type InferLiteral<T extends Literal> = T;
|
|
5
6
|
export default class LiteralType<T extends Literal> extends GenericType<T, InferLiteral<T>, "LiteralType"> {
|
|
6
7
|
#private;
|
|
7
8
|
constructor(literal: T);
|
|
9
|
+
static new<T extends Literal>(literal: T): LiteralType<T>;
|
|
10
|
+
static get Literal(): Literal;
|
|
8
11
|
get name(): string;
|
|
9
|
-
|
|
12
|
+
parse(x: unknown, options?: ParseOptions): Infer<this>;
|
|
13
|
+
toJSON(): {
|
|
14
|
+
type: "literal";
|
|
15
|
+
value: T;
|
|
16
|
+
};
|
|
10
17
|
}
|
|
11
18
|
export {};
|
|
12
19
|
//# sourceMappingURL=LiteralType.d.ts.map
|
|
@@ -1,24 +1,32 @@
|
|
|
1
|
+
import error from "#error";
|
|
1
2
|
import GenericType from "#GenericType";
|
|
2
|
-
import
|
|
3
|
-
const error = (message, key) => {
|
|
4
|
-
return key === undefined
|
|
5
|
-
? message
|
|
6
|
-
: `${key}: ${message}`;
|
|
7
|
-
};
|
|
3
|
+
import ParseError from "#ParseError";
|
|
8
4
|
export default class LiteralType extends GenericType {
|
|
9
5
|
#literal;
|
|
10
6
|
constructor(literal) {
|
|
11
7
|
super();
|
|
12
8
|
this.#literal = literal;
|
|
13
9
|
}
|
|
10
|
+
static new(literal) {
|
|
11
|
+
return new LiteralType(literal);
|
|
12
|
+
}
|
|
13
|
+
static get Literal() {
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
14
16
|
get name() {
|
|
15
|
-
return
|
|
17
|
+
return JSON.stringify(this.#literal);
|
|
16
18
|
}
|
|
17
|
-
|
|
19
|
+
parse(x, options = {}) {
|
|
18
20
|
if (x !== this.#literal) {
|
|
19
|
-
throw new
|
|
21
|
+
throw new ParseError(error(this.name, x, options));
|
|
20
22
|
}
|
|
21
23
|
return x;
|
|
22
24
|
}
|
|
25
|
+
toJSON() {
|
|
26
|
+
return {
|
|
27
|
+
type: "literal",
|
|
28
|
+
value: this.#literal,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
23
31
|
}
|
|
24
32
|
//# sourceMappingURL=LiteralType.js.map
|
|
@@ -2,15 +2,20 @@ import type ArrayType from "#ArrayType";
|
|
|
2
2
|
import type ConstructorType from "#ConstructorType";
|
|
3
3
|
import type LiteralType from "#LiteralType";
|
|
4
4
|
import type NullType from "#NullType";
|
|
5
|
+
import type ObjectType from "#ObjectType";
|
|
6
|
+
import type Parsed from "#Parsed";
|
|
5
7
|
import type Schema from "#Schema";
|
|
6
8
|
import type TupleType from "#TupleType";
|
|
7
9
|
import type UndefinedType from "#UndefinedType";
|
|
8
|
-
import type
|
|
9
|
-
import type
|
|
10
|
-
type
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
import type AbstractNewable from "@rcompat/type/AbstractNewable";
|
|
11
|
+
import type EO from "@rcompat/type/EO";
|
|
12
|
+
type IsEmptyObject<T> = keyof T extends never ? true : false;
|
|
13
|
+
type NormalizeSchemaArray<T extends Schema[]> = {
|
|
14
|
+
[K in keyof T]: NormalizeSchema<T[K]>;
|
|
15
|
+
};
|
|
16
|
+
type NormalizeSchemaObject<T extends Record<string, unknown>> = IsEmptyObject<T> extends true ? EO : {
|
|
17
|
+
-readonly [K in keyof T]: T[K] extends Parsed<unknown> ? T[K] : NormalizeSchema<T[K]>;
|
|
18
|
+
};
|
|
19
|
+
type NormalizeSchema<S> = S extends Parsed<unknown> ? S : S extends null ? NullType : S extends undefined ? UndefinedType : S extends string ? LiteralType<S> : S extends number ? LiteralType<S> : S extends boolean ? LiteralType<S> : S extends AbstractNewable ? ConstructorType<S> : S extends [infer O] ? O extends Schema ? ArrayType<NormalizeSchema<O>> : never : S extends Schema[] ? TupleType<NormalizeSchemaArray<S>> : S extends Record<string, unknown> ? ObjectType<NormalizeSchemaObject<S>> : never;
|
|
15
20
|
export type { NormalizeSchema as default };
|
|
16
21
|
//# sourceMappingURL=NormalizeSchema.d.ts.map
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import type Infer from "#Infer";
|
|
2
|
+
import type ParseOptions from "#ParseOptions";
|
|
2
3
|
import PrimitiveType from "#PrimitiveType";
|
|
3
4
|
export default class NullType extends PrimitiveType<null, "NullType"> {
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
get name(): "null";
|
|
6
|
+
parse(x: unknown, options?: ParseOptions): Infer<this>;
|
|
7
|
+
toJSON(): {
|
|
8
|
+
type: "null";
|
|
9
|
+
};
|
|
6
10
|
}
|
|
7
11
|
//# sourceMappingURL=NullType.d.ts.map
|
package/lib/private/NullType.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import
|
|
1
|
+
import error from "#error";
|
|
2
|
+
import ParseError from "#ParseError";
|
|
2
3
|
import PrimitiveType from "#PrimitiveType";
|
|
3
|
-
const error_message = (name, x, key) => {
|
|
4
|
-
const base = expected(name, x);
|
|
5
|
-
return key === undefined
|
|
6
|
-
? base
|
|
7
|
-
: `${key}: ${base}`;
|
|
8
|
-
};
|
|
9
4
|
export default class NullType extends PrimitiveType {
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
get name() {
|
|
6
|
+
return "null";
|
|
12
7
|
}
|
|
13
|
-
|
|
8
|
+
parse(x, options = {}) {
|
|
14
9
|
if (x !== null) {
|
|
15
|
-
throw new
|
|
10
|
+
throw new ParseError(error(this.name, x, options));
|
|
16
11
|
}
|
|
17
12
|
return x;
|
|
18
13
|
}
|
|
14
|
+
toJSON() {
|
|
15
|
+
return {
|
|
16
|
+
type: this.name,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
19
|
}
|
|
20
20
|
//# sourceMappingURL=NullType.js.map
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import CoerceKey from "#CoerceKey";
|
|
2
|
+
import type FloatDataType from "#FloatDataType";
|
|
3
|
+
import NumericType from "#NumericType";
|
|
4
|
+
import coerce from "#coerce/int";
|
|
5
|
+
export default class NumberType<T extends FloatDataType = "f64"> extends NumericType<T, number, "NumberType"> {
|
|
6
|
+
[CoerceKey]: typeof coerce;
|
|
7
|
+
get name(): "number";
|
|
4
8
|
}
|
|
5
9
|
//# sourceMappingURL=NumberType.d.ts.map
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import CoerceKey from "#CoerceKey";
|
|
2
|
+
import NumericType from "#NumericType";
|
|
3
|
+
import coerce from "#coerce/int";
|
|
4
|
+
export default class NumberType extends NumericType {
|
|
5
|
+
[CoerceKey] = coerce;
|
|
6
|
+
get name() {
|
|
7
|
+
return "number";
|
|
5
8
|
}
|
|
6
9
|
}
|
|
7
10
|
//# sourceMappingURL=NumberType.js.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type DataKey from "#DataKey";
|
|
2
|
+
import type ParseOptions from "#ParseOptions";
|
|
3
|
+
import PrimitiveType from "#PrimitiveType";
|
|
4
|
+
import type Storeable from "#Storeable";
|
|
5
|
+
import type Validator from "#Validator";
|
|
6
|
+
type Next<T> = {
|
|
7
|
+
options?: ParseOptions;
|
|
8
|
+
validators?: Validator<T>[];
|
|
9
|
+
};
|
|
10
|
+
export default abstract class NumericType<Key extends DataKey, T extends bigint | number, Name extends string> extends PrimitiveType<T, Name> implements Storeable<Key> {
|
|
11
|
+
#private;
|
|
12
|
+
constructor(datatype: Key, validators?: Validator<T>[], options?: ParseOptions);
|
|
13
|
+
derive(next: Next<T>): this;
|
|
14
|
+
values(anyof: Record<string, T>): this;
|
|
15
|
+
range(from: T, to: T): this;
|
|
16
|
+
min(from: T): this;
|
|
17
|
+
max(to: T): this;
|
|
18
|
+
get datatype(): Key;
|
|
19
|
+
toJSON(): {
|
|
20
|
+
type: "number" | "bigint";
|
|
21
|
+
datatype: Key;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
25
|
+
//# sourceMappingURL=NumericType.d.ts.map
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import PrimitiveType from "#PrimitiveType";
|
|
2
|
+
import max from "#validator/max";
|
|
3
|
+
import min from "#validator/min";
|
|
4
|
+
import range from "#validator/range";
|
|
5
|
+
import values from "#validator/values";
|
|
6
|
+
export default class NumericType extends PrimitiveType {
|
|
7
|
+
#datatype;
|
|
8
|
+
constructor(datatype, validators = [], options = {}) {
|
|
9
|
+
super(validators, options);
|
|
10
|
+
this.#datatype = datatype;
|
|
11
|
+
}
|
|
12
|
+
derive(next) {
|
|
13
|
+
const Constructor = this.constructor;
|
|
14
|
+
return new Constructor(this.#datatype, [...this.validators, ...next.validators ?? []], { ...this.options, ...next.options ?? {} });
|
|
15
|
+
}
|
|
16
|
+
values(anyof) {
|
|
17
|
+
return this.derive({ validators: [values(anyof)] });
|
|
18
|
+
}
|
|
19
|
+
range(from, to) {
|
|
20
|
+
return this.derive({ validators: [range(from, to)] });
|
|
21
|
+
}
|
|
22
|
+
min(from) {
|
|
23
|
+
return this.derive({ validators: [min(from)] });
|
|
24
|
+
}
|
|
25
|
+
max(to) {
|
|
26
|
+
return this.derive({ validators: [max(to)] });
|
|
27
|
+
}
|
|
28
|
+
get datatype() {
|
|
29
|
+
return this.#datatype;
|
|
30
|
+
}
|
|
31
|
+
toJSON() {
|
|
32
|
+
return {
|
|
33
|
+
type: this.name,
|
|
34
|
+
datatype: this.#datatype,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=NumericType.js.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import GenericType from "#GenericType";
|
|
2
|
+
import type Infer from "#Infer";
|
|
3
|
+
import type InferInputSchema from "#InferInputSchema";
|
|
4
|
+
import type Parsed from "#Parsed";
|
|
5
|
+
import type ParseOptions from "#ParseOptions";
|
|
6
|
+
import type Serialized from "#Serialized";
|
|
7
|
+
import type Dict from "@rcompat/type/Dict";
|
|
8
|
+
export default class ObjectType<P extends Dict<Parsed<unknown>>> extends GenericType<P, {
|
|
9
|
+
[K in keyof P]: P[K]["infer"];
|
|
10
|
+
}, "ObjectType"> {
|
|
11
|
+
#private;
|
|
12
|
+
constructor(properties: P, options?: ParseOptions);
|
|
13
|
+
get name(): string;
|
|
14
|
+
get properties(): P;
|
|
15
|
+
get input(): InferInputSchema<P>;
|
|
16
|
+
get coerce(): this;
|
|
17
|
+
parse(x: unknown, options?: ParseOptions): Infer<this>;
|
|
18
|
+
toJSON(): {
|
|
19
|
+
type: "object";
|
|
20
|
+
properties: Dict<Serialized>;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=ObjectType.d.ts.map
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import GenericType from "#GenericType";
|
|
2
|
+
import next from "#path/next";
|
|
3
|
+
export default class ObjectType extends GenericType {
|
|
4
|
+
#properties;
|
|
5
|
+
#options;
|
|
6
|
+
constructor(properties, options = {}) {
|
|
7
|
+
super();
|
|
8
|
+
this.#properties = properties;
|
|
9
|
+
this.#options = options;
|
|
10
|
+
}
|
|
11
|
+
get name() {
|
|
12
|
+
const props = Object.entries(this.#properties)
|
|
13
|
+
.map(([k, v]) => `${k}: ${v.name}`)
|
|
14
|
+
.join(", ");
|
|
15
|
+
return `{ ${props} }`;
|
|
16
|
+
}
|
|
17
|
+
get properties() {
|
|
18
|
+
return this.#properties;
|
|
19
|
+
}
|
|
20
|
+
get input() {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
#derive(next) {
|
|
24
|
+
const Constructor = this.constructor;
|
|
25
|
+
return new Constructor(this.#properties, { ...this.#options, ...next });
|
|
26
|
+
}
|
|
27
|
+
get coerce() {
|
|
28
|
+
return this.#derive({ coerce: true });
|
|
29
|
+
}
|
|
30
|
+
parse(x, options = {}) {
|
|
31
|
+
const $options = { ...this.#options, ...options };
|
|
32
|
+
let _x = x;
|
|
33
|
+
if (typeof x !== "object" || x === null) {
|
|
34
|
+
_x = {};
|
|
35
|
+
}
|
|
36
|
+
const out = {};
|
|
37
|
+
for (const k in this.#properties) {
|
|
38
|
+
const parsed = this.#properties[k].parse(_x[k], next(k, $options));
|
|
39
|
+
if (parsed !== undefined) {
|
|
40
|
+
out[k] = parsed;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
return out;
|
|
44
|
+
}
|
|
45
|
+
toJSON() {
|
|
46
|
+
const properties = {};
|
|
47
|
+
for (const [k, v] of Object.entries(this.#properties)) {
|
|
48
|
+
properties[k] = v.toJSON();
|
|
49
|
+
}
|
|
50
|
+
return { type: "object", properties };
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=ObjectType.js.map
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
import GenericType from "#GenericType";
|
|
2
1
|
import type Infer from "#Infer";
|
|
3
|
-
import type
|
|
4
|
-
|
|
2
|
+
import type Parsed from "#Parsed";
|
|
3
|
+
import type ParseOptions from "#ParseOptions";
|
|
4
|
+
import VirtualType from "#VirtualType";
|
|
5
|
+
export default class OptionalType<S extends Parsed<unknown>> extends VirtualType<S | undefined, Infer<S> | undefined, "OptionalType"> {
|
|
5
6
|
#private;
|
|
6
7
|
constructor(s: S);
|
|
7
|
-
get name():
|
|
8
|
-
|
|
8
|
+
get name(): "optional";
|
|
9
|
+
get schema(): S;
|
|
10
|
+
get nullable(): boolean;
|
|
11
|
+
parse(x: unknown, options?: ParseOptions): Infer<this>;
|
|
12
|
+
toJSON(): {
|
|
13
|
+
type: "optional";
|
|
14
|
+
of: import("./Serialized.js").default;
|
|
15
|
+
};
|
|
9
16
|
}
|
|
10
17
|
//# sourceMappingURL=OptionalType.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
export default class OptionalType extends
|
|
1
|
+
import VirtualType from "#VirtualType";
|
|
2
|
+
export default class OptionalType extends VirtualType {
|
|
3
3
|
#schema;
|
|
4
4
|
constructor(s) {
|
|
5
5
|
super();
|
|
@@ -8,13 +8,25 @@ export default class OptionalType extends GenericType {
|
|
|
8
8
|
get name() {
|
|
9
9
|
return "optional";
|
|
10
10
|
}
|
|
11
|
-
|
|
11
|
+
get schema() {
|
|
12
|
+
return this.#schema;
|
|
13
|
+
}
|
|
14
|
+
get nullable() {
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
17
|
+
parse(x, options = {}) {
|
|
12
18
|
const s = this.#schema;
|
|
13
19
|
// optional
|
|
14
20
|
if (x === undefined) {
|
|
15
21
|
return undefined;
|
|
16
22
|
}
|
|
17
|
-
return s.
|
|
23
|
+
return s.parse(x, options);
|
|
24
|
+
}
|
|
25
|
+
toJSON() {
|
|
26
|
+
return {
|
|
27
|
+
type: this.name,
|
|
28
|
+
of: this.schema.toJSON(),
|
|
29
|
+
};
|
|
18
30
|
}
|
|
19
31
|
}
|
|
20
32
|
//# sourceMappingURL=OptionalType.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type JSONPayload from "#json/JSONPayload";
|
|
2
|
+
import type ParseIssue from "#ParseIssue";
|
|
3
|
+
import type Serializable from "@rcompat/type/Serializable";
|
|
4
|
+
export default class ParseError extends Error implements Serializable {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(issues: ParseIssue[]);
|
|
7
|
+
get issues(): ParseIssue[] | undefined;
|
|
8
|
+
toJSON(): JSONPayload;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=ParseError.d.ts.map
|