pema 0.4.0 → 0.6.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.
Files changed (264) hide show
  1. package/lib/private/ArrayType.d.ts +2 -1
  2. package/lib/private/ArrayType.js +29 -41
  3. package/lib/private/BigIntType.d.ts +2 -2
  4. package/lib/private/BigUintType.d.ts +2 -2
  5. package/lib/private/BlobType.d.ts +2 -2
  6. package/lib/private/BlobType.js +2 -2
  7. package/lib/private/BooleanType.d.ts +2 -2
  8. package/lib/private/BooleanType.js +4 -4
  9. package/lib/private/BuiltinType.d.ts +1 -2
  10. package/lib/private/BuiltinType.js +3 -8
  11. package/lib/private/ConstructorType.d.ts +5 -2
  12. package/lib/private/ConstructorType.js +7 -5
  13. package/lib/private/DataType.d.ts +5 -1
  14. package/lib/private/DateType.d.ts +2 -2
  15. package/lib/private/DateType.js +2 -2
  16. package/lib/private/DefaultType.js +3 -6
  17. package/lib/private/EnumType.d.ts +21 -0
  18. package/lib/private/EnumType.js +30 -0
  19. package/lib/private/FileType.d.ts +2 -2
  20. package/lib/private/FileType.js +2 -2
  21. package/lib/private/FunctionType.d.ts +15 -0
  22. package/lib/private/FunctionType.js +20 -0
  23. package/lib/private/GenericType.d.ts +1 -1
  24. package/lib/private/InferInputSchema.d.ts +7 -17
  25. package/lib/private/InferStore.d.ts +1 -1
  26. package/lib/private/IntType.d.ts +2 -2
  27. package/lib/private/IsType.d.ts +19 -0
  28. package/lib/private/IsType.js +29 -0
  29. package/lib/private/Issue.d.ts +3 -1
  30. package/lib/private/IssueType.d.ts +3 -0
  31. package/lib/private/IssueType.js +2 -0
  32. package/lib/private/JSONType.d.ts +26 -0
  33. package/lib/private/JSONType.js +41 -0
  34. package/lib/private/LiteralType.d.ts +5 -2
  35. package/lib/private/LiteralType.js +11 -5
  36. package/lib/private/NormalizeSchema.d.ts +4 -6
  37. package/lib/private/NullType.js +3 -5
  38. package/lib/private/NumberType.d.ts +1 -1
  39. package/lib/private/NumberType.js +1 -1
  40. package/lib/private/NumericType.d.ts +2 -2
  41. package/lib/private/ObjectType.d.ts +13 -4
  42. package/lib/private/ObjectType.js +24 -11
  43. package/lib/private/OmitType.d.ts +1 -1
  44. package/lib/private/OmitType.js +7 -6
  45. package/lib/private/ParseError.d.ts +6 -2
  46. package/lib/private/ParseError.js +25 -15
  47. package/lib/private/ParseOptions.d.ts +1 -1
  48. package/lib/private/Parsed.d.ts +2 -1
  49. package/lib/private/Parsed.js +3 -0
  50. package/lib/private/PartialType.js +8 -10
  51. package/lib/private/Partialable.d.ts +1 -1
  52. package/lib/private/PrimitiveType.d.ts +0 -1
  53. package/lib/private/PrimitiveType.js +23 -22
  54. package/lib/private/PureType.d.ts +1 -1
  55. package/lib/private/RecordType.js +14 -39
  56. package/lib/private/Schema.d.ts +1 -1
  57. package/lib/private/Serialized.d.ts +18 -4
  58. package/lib/private/{Storeable.d.ts → Storable.d.ts} +3 -3
  59. package/lib/private/{Storeable.js → Storable.js} +2 -2
  60. package/lib/private/StoreSchema.d.ts +3 -6
  61. package/lib/private/StoreType.d.ts +5 -1
  62. package/lib/private/StoreType.js +22 -2
  63. package/lib/private/StringType.d.ts +2 -3
  64. package/lib/private/StringType.js +7 -13
  65. package/lib/private/TupleType.d.ts +2 -2
  66. package/lib/private/TupleType.js +19 -14
  67. package/lib/private/Type.d.ts +1 -1
  68. package/lib/private/URLType.d.ts +2 -2
  69. package/lib/private/URLType.js +2 -2
  70. package/lib/private/UUIDType.d.ts +17 -0
  71. package/lib/private/UUIDType.js +33 -0
  72. package/lib/private/UUIDV4Type.d.ts +13 -0
  73. package/lib/private/UUIDV4Type.js +23 -0
  74. package/lib/private/UUIDV7Type.d.ts +13 -0
  75. package/lib/private/UUIDV7Type.js +23 -0
  76. package/lib/private/UintType.d.ts +2 -2
  77. package/lib/private/UnionType.d.ts +3 -3
  78. package/lib/private/UnionType.js +11 -13
  79. package/lib/private/VirtualType.js +2 -3
  80. package/lib/private/coerce/bigint.d.ts +1 -1
  81. package/lib/private/coerce/bigint.js +4 -6
  82. package/lib/private/coerce/float.d.ts +2 -0
  83. package/lib/private/coerce/float.js +8 -0
  84. package/lib/private/coerce/int.d.ts +1 -1
  85. package/lib/private/coerce/int.js +7 -5
  86. package/lib/private/constructor.d.ts +1 -1
  87. package/lib/private/dict.d.ts +11 -0
  88. package/lib/private/dict.js +6 -0
  89. package/lib/private/enum.d.ts +3 -0
  90. package/lib/private/enum.js +5 -0
  91. package/lib/private/errors.d.ts +21 -0
  92. package/lib/private/errors.js +53 -0
  93. package/lib/private/function.d.ts +7 -0
  94. package/lib/private/function.js +6 -0
  95. package/lib/private/index.d.ts +79 -30
  96. package/lib/private/index.js +20 -2
  97. package/lib/private/is.d.ts +4 -0
  98. package/lib/private/is.js +3 -0
  99. package/lib/private/json/JSONIssue.d.ts +2 -0
  100. package/lib/private/json/JSONPayload.d.ts +1 -1
  101. package/lib/private/json.d.ts +5 -0
  102. package/lib/private/json.js +5 -0
  103. package/lib/private/normalize.js +2 -3
  104. package/lib/private/object.d.ts +3 -4
  105. package/lib/private/object.js +2 -2
  106. package/lib/private/omit.d.ts +1 -1
  107. package/lib/private/path/join.d.ts +1 -1
  108. package/lib/private/path/next.d.ts +1 -1
  109. package/lib/private/path/rebase.d.ts +1 -1
  110. package/lib/private/schema-errors.d.ts +16 -0
  111. package/lib/private/schema-errors.js +17 -0
  112. package/lib/private/spec/bigint.d.ts +1 -1
  113. package/lib/private/spec/bigint.js +30 -41
  114. package/lib/private/spec/biguint.d.ts +1 -1
  115. package/lib/private/spec/biguint.js +29 -45
  116. package/lib/private/spec/int.d.ts +1 -1
  117. package/lib/private/spec/int.js +27 -38
  118. package/lib/private/spec/uint.d.ts +1 -1
  119. package/lib/private/spec/uint.js +31 -43
  120. package/lib/private/test.d.ts +34 -0
  121. package/lib/private/test.js +107 -0
  122. package/lib/private/uuid.d.ts +4 -0
  123. package/lib/private/uuid.js +3 -0
  124. package/lib/private/validator/ends-with.d.ts +1 -2
  125. package/lib/private/validator/ends-with.js +8 -10
  126. package/lib/private/validator/f32.js +3 -8
  127. package/lib/private/validator/integer.d.ts +1 -2
  128. package/lib/private/validator/integer.js +7 -11
  129. package/lib/private/validator/isotime.js +8 -10
  130. package/lib/private/validator/length.js +12 -20
  131. package/lib/private/validator/max.js +15 -16
  132. package/lib/private/validator/min.js +15 -16
  133. package/lib/private/validator/port.d.ts +1 -2
  134. package/lib/private/validator/port.js +6 -9
  135. package/lib/private/validator/range.js +7 -13
  136. package/lib/private/validator/regex.d.ts +1 -1
  137. package/lib/private/validator/regex.js +5 -9
  138. package/lib/private/validator/starts-with.d.ts +1 -2
  139. package/lib/private/validator/starts-with.js +8 -10
  140. package/lib/private/validator/unique-by.d.ts +1 -1
  141. package/lib/private/validator/unique-by.js +8 -14
  142. package/lib/private/validator/unique-with.d.ts +1 -1
  143. package/lib/private/validator/unique-with.js +3 -7
  144. package/lib/private/validator/unique.js +2 -6
  145. package/lib/private/validator/values.d.ts +1 -1
  146. package/lib/private/validator/values.js +5 -8
  147. package/lib/public/StoreType.d.ts +1 -1
  148. package/lib/public/index.d.ts +1 -9
  149. package/lib/public/index.js +0 -9
  150. package/package.json +18 -15
  151. package/lib/private/DecrementDepth.d.ts +0 -3
  152. package/lib/private/DecrementDepth.js +0 -2
  153. package/lib/private/InferSchema.d.ts +0 -20
  154. package/lib/private/InferSchema.js +0 -2
  155. package/lib/private/PrimaryType.d.ts +0 -14
  156. package/lib/private/PrimaryType.js +0 -26
  157. package/lib/private/SchemaError.d.ts +0 -4
  158. package/lib/private/SchemaError.js +0 -8
  159. package/lib/private/error/fail.d.ts +0 -3
  160. package/lib/private/error/fail.js +0 -5
  161. package/lib/private/error/schemafail.d.ts +0 -3
  162. package/lib/private/error/schemafail.js +0 -5
  163. package/lib/private/error.d.ts +0 -4
  164. package/lib/private/error.js +0 -11
  165. package/lib/private/expect.d.ts +0 -22
  166. package/lib/private/expect.js +0 -32
  167. package/lib/private/expected.d.ts +0 -3
  168. package/lib/private/expected.js +0 -11
  169. package/lib/private/primary.d.ts +0 -4
  170. package/lib/private/primary.js +0 -3
  171. package/lib/private/test/messages-of.d.ts +0 -3
  172. package/lib/private/test/messages-of.js +0 -4
  173. package/lib/private/test/paths-of.d.ts +0 -3
  174. package/lib/private/test/paths-of.js +0 -4
  175. package/lib/private/test/throws-issues.d.ts +0 -4
  176. package/lib/private/test/throws-issues.js +0 -13
  177. package/lib/private/validator/uuid.d.ts +0 -3
  178. package/lib/private/validator/uuid.js +0 -4
  179. package/lib/public/DataType.d.ts +0 -2
  180. package/lib/public/DataType.js +0 -2
  181. package/lib/public/Id.d.ts +0 -2
  182. package/lib/public/Id.js +0 -2
  183. package/lib/public/InferStore.d.ts +0 -2
  184. package/lib/public/InferStore.js +0 -2
  185. package/lib/public/InferStoreOut.d.ts +0 -2
  186. package/lib/public/InferStoreOut.js +0 -2
  187. package/lib/public/Issue.d.ts +0 -2
  188. package/lib/public/Issue.js +0 -2
  189. package/lib/public/JSONPayload.d.ts +0 -2
  190. package/lib/public/JSONPayload.js +0 -2
  191. package/lib/public/OmitType.d.ts +0 -2
  192. package/lib/public/OmitType.js +0 -2
  193. package/lib/public/Schema.d.ts +0 -2
  194. package/lib/public/Schema.js +0 -2
  195. package/lib/public/Serialized.d.ts +0 -2
  196. package/lib/public/Serialized.js +0 -2
  197. package/lib/public/StoreId.d.ts +0 -2
  198. package/lib/public/StoreId.js +0 -2
  199. package/lib/public/StoreSchema.d.ts +0 -2
  200. package/lib/public/StoreSchema.js +0 -2
  201. package/lib/public/array.d.ts +0 -3
  202. package/lib/public/array.js +0 -3
  203. package/lib/public/bigint.d.ts +0 -2
  204. package/lib/public/bigint.js +0 -2
  205. package/lib/public/biguint.d.ts +0 -2
  206. package/lib/public/biguint.js +0 -2
  207. package/lib/public/blob.d.ts +0 -2
  208. package/lib/public/blob.js +0 -2
  209. package/lib/public/boolean.d.ts +0 -3
  210. package/lib/public/boolean.js +0 -3
  211. package/lib/public/constructor.d.ts +0 -3
  212. package/lib/public/constructor.js +0 -3
  213. package/lib/public/date.d.ts +0 -2
  214. package/lib/public/date.js +0 -2
  215. package/lib/public/f32.d.ts +0 -2
  216. package/lib/public/f32.js +0 -2
  217. package/lib/public/f64.d.ts +0 -2
  218. package/lib/public/f64.js +0 -2
  219. package/lib/public/file.d.ts +0 -2
  220. package/lib/public/file.js +0 -2
  221. package/lib/public/i128.d.ts +0 -2
  222. package/lib/public/i128.js +0 -2
  223. package/lib/public/i16.d.ts +0 -2
  224. package/lib/public/i16.js +0 -2
  225. package/lib/public/i32.d.ts +0 -2
  226. package/lib/public/i32.js +0 -2
  227. package/lib/public/i64.d.ts +0 -2
  228. package/lib/public/i64.js +0 -2
  229. package/lib/public/i8.d.ts +0 -2
  230. package/lib/public/i8.js +0 -2
  231. package/lib/public/int.d.ts +0 -2
  232. package/lib/public/int.js +0 -2
  233. package/lib/public/number.d.ts +0 -3
  234. package/lib/public/number.js +0 -3
  235. package/lib/public/object.d.ts +0 -2
  236. package/lib/public/object.js +0 -2
  237. package/lib/public/optional.d.ts +0 -2
  238. package/lib/public/optional.js +0 -2
  239. package/lib/public/primary.d.ts +0 -2
  240. package/lib/public/primary.js +0 -2
  241. package/lib/public/pure.d.ts +0 -2
  242. package/lib/public/pure.js +0 -2
  243. package/lib/public/record.d.ts +0 -3
  244. package/lib/public/record.js +0 -3
  245. package/lib/public/string.d.ts +0 -3
  246. package/lib/public/string.js +0 -3
  247. package/lib/public/symbol.d.ts +0 -2
  248. package/lib/public/symbol.js +0 -2
  249. package/lib/public/u128.d.ts +0 -2
  250. package/lib/public/u128.js +0 -2
  251. package/lib/public/u16.d.ts +0 -2
  252. package/lib/public/u16.js +0 -2
  253. package/lib/public/u32.d.ts +0 -2
  254. package/lib/public/u32.js +0 -2
  255. package/lib/public/u64.d.ts +0 -2
  256. package/lib/public/u64.js +0 -2
  257. package/lib/public/u8.d.ts +0 -2
  258. package/lib/public/u8.js +0 -2
  259. package/lib/public/uint.d.ts +0 -3
  260. package/lib/public/uint.js +0 -3
  261. package/lib/public/union.d.ts +0 -3
  262. package/lib/public/union.js +0 -3
  263. package/lib/public/unknown.d.ts +0 -3
  264. package/lib/public/unknown.js +0 -2
@@ -0,0 +1,2 @@
1
+ export default function coerceFloat(x: unknown): unknown;
2
+ //# sourceMappingURL=float.d.ts.map
@@ -0,0 +1,8 @@
1
+ import is from "@rcompat/is";
2
+ export default function coerceFloat(x) {
3
+ const n = is.numeric(x) ? Number(x) : x;
4
+ if (is.number(n))
5
+ return n;
6
+ return x;
7
+ }
8
+ //# sourceMappingURL=float.js.map
@@ -1,2 +1,2 @@
1
- export default function coerceInt(x: unknown): unknown;
1
+ export default function coerce_int(x: unknown): unknown;
2
2
  //# sourceMappingURL=int.d.ts.map
@@ -1,8 +1,10 @@
1
- import numeric from "@rcompat/is/numeric";
2
- export default function coerceInt(x) {
3
- if (numeric(x)) {
4
- return Number(x);
5
- }
1
+ import is from "@rcompat/is";
2
+ export default function coerce_int(x) {
3
+ // normalize from string to number; other types unaffected
4
+ const n = is.numeric(x) ? Number(x) : x;
5
+ // if is integer, return it
6
+ if (typeof n === "number" && is.int(n))
7
+ return n;
6
8
  return x;
7
9
  }
8
10
  //# sourceMappingURL=int.js.map
@@ -1,5 +1,5 @@
1
1
  import ConstructorType from "#ConstructorType";
2
- import type AbstractNewable from "@rcompat/type/AbstractNewable";
2
+ import type { AbstractNewable } from "@rcompat/type";
3
3
  /**
4
4
  * Value is a constructed instance of the given class.
5
5
  */
@@ -0,0 +1,11 @@
1
+ import type Parsed from "#Parsed";
2
+ import type RecordType from "#RecordType";
3
+ import type StringType from "#StringType";
4
+ /**
5
+ * Value is a dictionary (record with string keys) of the given type.
6
+ *
7
+ * @param of - The value type (defaults to p.string)
8
+ */
9
+ export default function dict(): RecordType<StringType, StringType>;
10
+ export default function dict<const Value extends Parsed<unknown>>(of: Value): RecordType<StringType, Value>;
11
+ //# sourceMappingURL=dict.d.ts.map
@@ -0,0 +1,6 @@
1
+ import record from "#record";
2
+ import string from "#string";
3
+ export default function dict(of = string) {
4
+ return record(string, of);
5
+ }
6
+ //# sourceMappingURL=dict.js.map
@@ -0,0 +1,3 @@
1
+ import EnumType from "#EnumType";
2
+ export default function _enum<T extends readonly string[]>(values: T): EnumType<T>;
3
+ //# sourceMappingURL=enum.d.ts.map
@@ -0,0 +1,5 @@
1
+ import EnumType from "#EnumType";
2
+ export default function _enum(values) {
3
+ return new EnumType(values);
4
+ }
5
+ //# sourceMappingURL=enum.js.map
@@ -0,0 +1,21 @@
1
+ import ParseError from "#ParseError";
2
+ import type ParseOptions from "#ParseOptions";
3
+ import type { JSONPointer } from "@rcompat/type";
4
+ declare function invalid_type(input: unknown, expected: string, options?: ParseOptions<any> | JSONPointer): ParseError;
5
+ declare function invalid_format(input: unknown, message: string, path?: JSONPointer): ParseError;
6
+ declare function too_small(input: unknown, message: string, path?: JSONPointer): ParseError;
7
+ declare function too_large(input: unknown, message: string, path?: JSONPointer): ParseError;
8
+ declare function out_of_range(input: unknown, message: string, path?: JSONPointer): ParseError;
9
+ declare function duplicate(input: unknown, message: string, path?: JSONPointer): ParseError;
10
+ declare function not_in_set(input: unknown, message: string, path?: JSONPointer): ParseError;
11
+ declare const _default: {
12
+ invalid_type: typeof invalid_type;
13
+ invalid_format: typeof invalid_format;
14
+ too_small: typeof too_small;
15
+ too_large: typeof too_large;
16
+ out_of_range: typeof out_of_range;
17
+ duplicate: typeof duplicate;
18
+ not_in_set: typeof not_in_set;
19
+ };
20
+ export default _default;
21
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1,53 @@
1
+ import ParsedKey from "#ParsedKey";
2
+ import ParseError from "#ParseError";
3
+ function print_got(x) {
4
+ if (x === undefined)
5
+ return "undefined";
6
+ if (x === null)
7
+ return "null";
8
+ return `\`${x?.toString() ?? x}\` (${typeof x})`;
9
+ }
10
+ function invalid_type(input, expected, options = "") {
11
+ const path = typeof options === "string"
12
+ ? options
13
+ : options[ParsedKey] ?? "";
14
+ return new ParseError([{
15
+ type: "invalid_type",
16
+ input,
17
+ message: `expected ${expected}, got ${print_got(input)}`,
18
+ path,
19
+ }]);
20
+ }
21
+ function invalid_format(input, message, path = "") {
22
+ return new ParseError([{
23
+ type: "invalid_format",
24
+ input,
25
+ message,
26
+ path,
27
+ }]);
28
+ }
29
+ function too_small(input, message, path = "") {
30
+ return new ParseError([{ type: "too_small", input, message, path }]);
31
+ }
32
+ function too_large(input, message, path = "") {
33
+ return new ParseError([{ type: "too_large", input, message, path }]);
34
+ }
35
+ function out_of_range(input, message, path = "") {
36
+ return new ParseError([{ type: "out_of_range", input, message, path }]);
37
+ }
38
+ function duplicate(input, message, path = "") {
39
+ return new ParseError([{ type: "duplicate", input, message, path }]);
40
+ }
41
+ function not_in_set(input, message, path = "") {
42
+ return new ParseError([{ type: "not_in_set", input, message, path }]);
43
+ }
44
+ export default {
45
+ invalid_type,
46
+ invalid_format,
47
+ too_small,
48
+ too_large,
49
+ out_of_range,
50
+ duplicate,
51
+ not_in_set,
52
+ };
53
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1,7 @@
1
+ import FunctionType from "#FunctionType";
2
+ /**
3
+ * Value is a function.
4
+ */
5
+ declare const _default: FunctionType;
6
+ export default _default;
7
+ //# sourceMappingURL=function.d.ts.map
@@ -0,0 +1,6 @@
1
+ import FunctionType from "#FunctionType";
2
+ /**
3
+ * Value is a function.
4
+ */
5
+ export default new FunctionType();
6
+ //# sourceMappingURL=function.js.map
@@ -1,3 +1,42 @@
1
+ export type { default as ArrayType } from "#ArrayType";
2
+ export type { default as BooleanType } from "#BooleanType";
3
+ export type { default as ConstructorType } from "#ConstructorType";
4
+ export type { default as DataKey } from "#DataKey";
5
+ export type { default as DataType } from "#DataType";
6
+ export type { default as DateType } from "#DateType";
7
+ export type { default as DefaultType } from "#DefaultType";
8
+ export type { default as EnumType } from "#EnumType";
9
+ export type { default as FunctionType } from "#FunctionType";
10
+ export type { default as Id } from "#Id";
11
+ export type { default as InferStore } from "#InferStore";
12
+ export type { default as InferStoreOut } from "#InferStoreOut";
13
+ export type { default as Issue } from "#Issue";
14
+ export type { default as IsType } from "#IsType";
15
+ export type { default as JSONPayload } from "#json/JSONPayload";
16
+ export type { default as LiteralType } from "#LiteralType";
17
+ export type { default as NormalizeSchema, NormalizeSchemaObject } from "#NormalizeSchema";
18
+ export type { default as NullType } from "#NullType";
19
+ export type { default as NumberType } from "#NumberType";
20
+ export type { default as ObjectType } from "#ObjectType";
21
+ export type { default as OptionalType } from "#OptionalType";
22
+ export type { default as Parsed } from "#Parsed";
23
+ export type { default as PureType } from "#PureType";
24
+ export type { default as RecordType } from "#RecordType";
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";
30
+ export type { default as StringType } from "#StringType";
31
+ export type { default as TupleType } from "#TupleType";
32
+ export type { default as UintType } from "#UintType";
33
+ export type { default as UndefinedType } from "#UndefinedType";
34
+ export type { default as UnionType } from "#UnionType";
35
+ export type { default as UnknownType } from "#UnknownType";
36
+ export type { default as UUIDType } from "#UUIDType";
37
+ export type { default as UUIDV4Type } from "#UUIDV4Type";
38
+ export type { default as UUIDV7Type } from "#UUIDV7Type";
39
+ import enum_ from "#enum";
1
40
  import type NormalizeSchema from "#NormalizeSchema";
2
41
  import type Schema from "#Schema";
3
42
  /**
@@ -5,36 +44,46 @@ import type Schema from "#Schema";
5
44
  */
6
45
  declare function schema<const S extends Schema>(s: S): NormalizeSchema<S>;
7
46
  declare namespace schema {
8
- var array: typeof import("#array").default;
9
- var bigint: import("./BigIntType.js").default<"i64">;
10
- var biguint: import("./BigUintType.js").default<"u64">;
11
- var blob: import("./BlobType.js").default;
12
- var boolean: import("./BooleanType.js").default;
13
- var constructor: <const C extends import("@rcompat/type/AbstractNewable").default>(constructor: C) => import("./ConstructorType.js").default<C>;
14
- var date: import("./DateType.js").default;
15
- var f32: import("./NumberType.js").default<"f32">;
16
- var f64: import("./NumberType.js").default<"f64">;
17
- var file: import("./FileType.js").default;
18
- var i128: import("./BigIntType.js").default<"i128">;
19
- var i16: import("./IntType.js").default<"i16">;
20
- var i32: import("./IntType.js").default<"i32">;
21
- var i64: import("./BigIntType.js").default<"i64">;
22
- var i8: import("./IntType.js").default<"i8">;
23
- var int: import("./IntType.js").default<"i32">;
24
- var number: import("./NumberType.js").default<"f64">;
25
- var omit: typeof import("#omit").default;
26
- var record: <const Key extends import("./RecordTypeKey.js").default, const Value extends import("./Parsed.js").default<unknown>>(k: Key, v: Value) => import("./RecordType.js").default<Key, Value>;
27
- var primary: import("./PrimaryType.js").default;
28
- var string: import("./StringType.js").default;
29
- var symbol: import("./SymbolType.js").default;
30
- var u128: import("./BigUintType.js").default<"u128">;
31
- var u16: import("./UintType.js").default<"u16">;
32
- var u32: import("./UintType.js").default<"u32">;
33
- var u64: import("./BigUintType.js").default<"u64">;
34
- var u8: import("./UintType.js").default<"u8">;
35
- var uint: import("./UintType.js").default<"u32">;
36
- var union: typeof import("#union").default;
37
- var unknown: import("./UnknownType.js").default;
47
+ export var array: typeof import("#array").default;
48
+ export var bigint: import("./BigIntType.js").default<"i64">;
49
+ export var biguint: import("./BigUintType.js").default<"u64">;
50
+ export var blob: import("./BlobType.js").default;
51
+ export var boolean: import("#BooleanType").default;
52
+ export var constructor: <const C extends import("@rcompat/type").AbstractNewable>(constructor: C) => import("#ConstructorType").default<C>;
53
+ export var date: import("#DateType").default;
54
+ export var dict: typeof import("#dict").default;
55
+ var _a: typeof enum_;
56
+ export var f32: import("#NumberType").default<"f32">;
57
+ export var f64: import("#NumberType").default<"f64">;
58
+ export var file: import("./FileType.js").default;
59
+ var _b: import("#FunctionType").default;
60
+ export var i128: import("./BigIntType.js").default<"i128">;
61
+ export var i16: import("./IntType.js").default<"i16">;
62
+ export var i32: import("./IntType.js").default<"i32">;
63
+ export var i64: import("./BigIntType.js").default<"i64">;
64
+ export var i8: import("./IntType.js").default<"i8">;
65
+ export var int: import("./IntType.js").default<"i32">;
66
+ export var is: <T>(predicate: (x: unknown) => x is T) => import("#IsType").default<T>;
67
+ export var json: typeof import("#json").default;
68
+ export var number: import("#NumberType").default<"f64">;
69
+ export var object: typeof import("#object").default;
70
+ export var omit: typeof import("#omit").default;
71
+ export var record: <const Key extends import("./RecordTypeKey.js").default, const Value extends import("#Parsed").default<unknown>>(k: Key, v: Value) => import("#RecordType").default<Key, Value>;
72
+ export var pure: typeof import("#pure").default;
73
+ export var string: import("#StringType").default;
74
+ export var symbol: import("./SymbolType.js").default;
75
+ export var tuple: typeof import("#tuple").default;
76
+ export var u128: import("./BigUintType.js").default<"u128">;
77
+ export var u16: import("#UintType").default<"u16">;
78
+ export var u32: import("#UintType").default<"u32">;
79
+ export var u64: import("./BigUintType.js").default<"u64">;
80
+ export var u8: import("#UintType").default<"u8">;
81
+ export var uint: import("#UintType").default<"u32">;
82
+ export var union: typeof import("#union").default;
83
+ export var unknown: import("#UnknownType").default;
84
+ export var url: import("./URLType.js").default;
85
+ export var uuid: import("#UUIDType").default;
86
+ export { _a as enum, _b as function };
38
87
  }
39
88
  export default schema;
40
89
  //# sourceMappingURL=index.d.ts.map
@@ -5,22 +5,29 @@ 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";
9
+ import enum_ from "#enum";
8
10
  import f32 from "#f32";
9
11
  import f64 from "#f64";
10
12
  import file from "#file";
13
+ import fn from "#function";
11
14
  import i128 from "#i128";
12
15
  import i16 from "#i16";
13
16
  import i32 from "#i32";
14
17
  import i64 from "#i64";
15
18
  import i8 from "#i8";
16
19
  import int from "#int";
20
+ import is from "#is";
21
+ import json from "#json";
17
22
  import normalize from "#normalize";
18
23
  import number from "#number";
24
+ import object from "#object";
19
25
  import omit from "#omit";
20
- import primary from "#primary";
26
+ import pure from "#pure";
21
27
  import record from "#record";
22
28
  import string from "#string";
23
29
  import symbol from "#symbol";
30
+ import tuple from "#tuple";
24
31
  import u128 from "#u128";
25
32
  import u16 from "#u16";
26
33
  import u32 from "#u32";
@@ -29,6 +36,8 @@ import u8 from "#u8";
29
36
  import uint from "#uint";
30
37
  import union from "#union";
31
38
  import unknown from "#unknown";
39
+ import url from "#url";
40
+ import uuid from "#uuid";
32
41
  /**
33
42
  * Create a schema.
34
43
  */
@@ -42,21 +51,28 @@ schema.blob = blob;
42
51
  schema.boolean = boolean;
43
52
  schema.constructor = constructor;
44
53
  schema.date = date;
54
+ schema.dict = dict;
55
+ schema.enum = enum_;
45
56
  schema.f32 = f32;
46
57
  schema.f64 = f64;
47
58
  schema.file = file;
59
+ schema.function = fn;
48
60
  schema.i128 = i128;
49
61
  schema.i16 = i16;
50
62
  schema.i32 = i32;
51
63
  schema.i64 = i64;
52
64
  schema.i8 = i8;
53
65
  schema.int = int;
66
+ schema.is = is;
67
+ schema.json = json;
54
68
  schema.number = number;
69
+ schema.object = object;
55
70
  schema.omit = omit;
56
71
  schema.record = record;
57
- schema.primary = primary;
72
+ schema.pure = pure;
58
73
  schema.string = string;
59
74
  schema.symbol = symbol;
75
+ schema.tuple = tuple;
60
76
  schema.u128 = u128;
61
77
  schema.u16 = u16;
62
78
  schema.u32 = u32;
@@ -65,5 +81,7 @@ schema.u8 = u8;
65
81
  schema.uint = uint;
66
82
  schema.union = union;
67
83
  schema.unknown = unknown;
84
+ schema.url = url;
85
+ schema.uuid = uuid;
68
86
  export default schema;
69
87
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,4 @@
1
+ import IsType from "#IsType";
2
+ declare const _default: <T>(predicate: (x: unknown) => x is T) => IsType<T>;
3
+ export default _default;
4
+ //# sourceMappingURL=is.d.ts.map
@@ -0,0 +1,3 @@
1
+ import IsType from "#IsType";
2
+ export default (predicate) => new IsType(predicate);
3
+ //# sourceMappingURL=is.js.map
@@ -1,4 +1,6 @@
1
+ import type IssueType from "#IssueType";
1
2
  type JSONIssue = {
3
+ type: IssueType;
2
4
  message: string;
3
5
  messages: string[];
4
6
  };
@@ -1,5 +1,5 @@
1
1
  import type JSONIssue from "#json/JSONIssue";
2
- import type JSONPointer from "@rcompat/type/JSONPointer";
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
@@ -0,0 +1,5 @@
1
+ import type { ParsedJSON } from "#JSONType";
2
+ import JSONType from "#JSONType";
3
+ export default function json(): JSONType<undefined>;
4
+ export default function json<S extends ParsedJSON>(inner: S): JSONType<S>;
5
+ //# sourceMappingURL=json.d.ts.map
@@ -0,0 +1,5 @@
1
+ import JSONType from "#JSONType";
2
+ export default function json(inner) {
3
+ return new JSONType(inner);
4
+ }
5
+ //# sourceMappingURL=json.js.map
@@ -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 newable from "@rcompat/is/newable";
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]))
@@ -1,11 +1,10 @@
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/Dict";
5
- import type EO from "@rcompat/type/EO";
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
- export default function object<P extends Dict<Schema>>(properties: P): ObjectType<NormalizeProps<P>>;
8
+ export default function object<P extends Dict<Schema> = Dict<Schema>>(properties: P): ObjectType<NormalizeProps<P>>;
10
9
  export {};
11
10
  //# sourceMappingURL=object.d.ts.map
@@ -1,8 +1,8 @@
1
1
  import normalize from "#normalize";
2
2
  import ObjectType from "#ObjectType";
3
- export default function object(peries) {
3
+ export default function object(properties) {
4
4
  const props = {};
5
- for (const [k, v] of Object.entries(peries)) {
5
+ for (const [k, v] of Object.entries(properties)) {
6
6
  props[k] = normalize(v);
7
7
  }
8
8
  return new ObjectType(props);
@@ -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/Dict";
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,3 +1,3 @@
1
- import type JSONPointer from "@rcompat/type/JSONPointer";
1
+ import type { JSONPointer } from "@rcompat/type";
2
2
  export default function join(base: JSONPointer, ...tokens: (number | string)[]): JSONPointer;
3
3
  //# sourceMappingURL=join.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/JSONPointer").default;
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
- import type JSONPointer from "@rcompat/type/JSONPointer";
1
+ import type { JSONPointer } from "@rcompat/type";
2
2
  export default function rebase(base: JSONPointer, rel: JSONPointer): JSONPointer;
3
3
  //# sourceMappingURL=rebase.d.ts.map
@@ -0,0 +1,16 @@
1
+ declare const errors: {
2
+ unique_subtype_not_primitive: (subtype: string) => import("@rcompat/error").TemplateError;
3
+ min_negative: (limit: number) => import("@rcompat/error").TemplateError;
4
+ max_negative: (limit: number) => import("@rcompat/error").TemplateError;
5
+ length_not_finite: (from: number, to: number) => import("@rcompat/error").TemplateError;
6
+ length_not_positive: (from: number, to: number) => import("@rcompat/error").TemplateError;
7
+ length_from_exceeds_to: (from: number, to: number) => import("@rcompat/error").TemplateError;
8
+ min_limit_not_finite: (limit: number) => import("@rcompat/error").TemplateError;
9
+ max_limit_not_finite: (limit: number) => import("@rcompat/error").TemplateError;
10
+ extend_key_collision: (key: string) => import("@rcompat/error").TemplateError;
11
+ union_at_least_two_members: () => import("@rcompat/error").TemplateError;
12
+ };
13
+ export type Code = keyof typeof errors;
14
+ export declare const Code: { [K in Code]: K; };
15
+ export default errors;
16
+ //# sourceMappingURL=schema-errors.d.ts.map
@@ -0,0 +1,17 @@
1
+ import error from "@rcompat/error";
2
+ const t = error.template;
3
+ const errors = error.coded({
4
+ unique_subtype_not_primitive: (subtype) => t `unique: subtype ${subtype} must be primitive`,
5
+ min_negative: (limit) => t `min: ${limit} must be positive`,
6
+ max_negative: (limit) => t `max: ${limit} must be positive`,
7
+ length_not_finite: (from, to) => t `length: ${from} and ${to} must be finite numbers`,
8
+ length_not_positive: (from, to) => t `length: ${from} and ${to} must be positive`,
9
+ length_from_exceeds_to: (from, to) => t `length: ${from} must be lower than ${to}`,
10
+ min_limit_not_finite: (limit) => t `min: limit ${limit} must be a finite number`,
11
+ max_limit_not_finite: (limit) => t `max: limit ${limit} must be a finite number`,
12
+ extend_key_collision: (key) => t `extend: key ${key} already exists and cannot be overridden`,
13
+ union_at_least_two_members: () => t `union type must have at least two members`,
14
+ });
15
+ export const Code = Object.fromEntries(Object.keys(errors).map(k => [k, k]));
16
+ export default errors;
17
+ //# sourceMappingURL=schema-errors.js.map
@@ -1,5 +1,5 @@
1
1
  import type BigIntDataType from "#BigIntDataType";
2
2
  import type BigIntType from "#BigIntType";
3
- declare const _default: <T extends BigIntDataType>(i: BigIntType<T>, min: bigint, max: bigint) => void;
3
+ declare const _default: <T extends BigIntDataType>(t: BigIntType<T>, min: bigint, max: bigint) => void;
4
4
  export default _default;
5
5
  //# sourceMappingURL=bigint.d.ts.map