pema 0.6.1 → 0.8.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 (175) hide show
  1. package/lib/private/ArrayType.d.ts +6 -3
  2. package/lib/private/ArrayType.js +15 -6
  3. package/lib/private/BigIntType.d.ts +1 -1
  4. package/lib/private/BigUintType.d.ts +1 -1
  5. package/lib/private/BooleanType.d.ts +5 -1
  6. package/lib/private/BooleanType.js +6 -0
  7. package/lib/private/BuiltinType.d.ts +1 -1
  8. package/lib/private/BuiltinType.js +6 -2
  9. package/lib/private/ConstructorType.d.ts +1 -1
  10. package/lib/private/ConstructorType.js +3 -1
  11. package/lib/private/DateType.d.ts +4 -1
  12. package/lib/private/DateType.js +6 -0
  13. package/lib/private/DefaultType.d.ts +1 -1
  14. package/lib/private/DefaultType.js +6 -5
  15. package/lib/private/EnumType.d.ts +1 -1
  16. package/lib/private/EnumType.js +5 -2
  17. package/lib/private/FunctionType.d.ts +1 -1
  18. package/lib/private/FunctionType.js +6 -3
  19. package/lib/private/IntType.d.ts +2 -2
  20. package/lib/private/IntType.js +2 -2
  21. package/lib/private/IsType.d.ts +1 -1
  22. package/lib/private/IsType.js +3 -1
  23. package/lib/private/JSONType.d.ts +1 -1
  24. package/lib/private/JSONType.js +3 -1
  25. package/lib/private/LiteralType.d.ts +6 -4
  26. package/lib/private/LiteralType.js +10 -8
  27. package/lib/private/Loose.d.ts +4 -0
  28. package/lib/private/Loose.js +3 -0
  29. package/lib/private/Mode.d.ts +3 -0
  30. package/lib/private/Mode.js +2 -0
  31. package/lib/private/NormalizeSchema.d.ts +3 -3
  32. package/lib/private/NullType.d.ts +1 -1
  33. package/lib/private/NullType.js +5 -2
  34. package/lib/private/NumberType.d.ts +1 -1
  35. package/lib/private/NumericType.d.ts +7 -3
  36. package/lib/private/NumericType.js +5 -2
  37. package/lib/private/ObjectType.d.ts +8 -5
  38. package/lib/private/ObjectType.js +17 -6
  39. package/lib/private/OmitType.d.ts +6 -3
  40. package/lib/private/OmitType.js +7 -2
  41. package/lib/private/OptionalType.d.ts +1 -1
  42. package/lib/private/OptionalType.js +6 -5
  43. package/lib/private/ParseError.d.ts +1 -1
  44. package/lib/private/ParseError.js +9 -8
  45. package/lib/private/ParseOptions.d.ts +2 -1
  46. package/lib/private/Parsed.d.ts +4 -3
  47. package/lib/private/Parsed.js +2 -3
  48. package/lib/private/PartialType.d.ts +6 -3
  49. package/lib/private/PartialType.js +7 -2
  50. package/lib/private/PrimitiveType.d.ts +1 -1
  51. package/lib/private/PrimitiveType.js +7 -4
  52. package/lib/private/PureType.d.ts +1 -1
  53. package/lib/private/PureType.js +2 -2
  54. package/lib/private/RecordType.d.ts +8 -5
  55. package/lib/private/RecordType.js +7 -2
  56. package/lib/private/Serialized.d.ts +13 -13
  57. package/lib/private/Storable.d.ts +1 -0
  58. package/lib/private/Storable.js +4 -0
  59. package/lib/private/StoreType.d.ts +2 -2
  60. package/lib/private/StoreType.js +4 -2
  61. package/lib/private/TupleType.d.ts +6 -3
  62. package/lib/private/TupleType.js +14 -5
  63. package/lib/private/URLType.d.ts +6 -1
  64. package/lib/private/URLType.js +21 -0
  65. package/lib/private/UUIDType.d.ts +1 -1
  66. package/lib/private/UUIDType.js +3 -1
  67. package/lib/private/UUIDV4Type.d.ts +1 -1
  68. package/lib/private/UUIDV4Type.js +3 -1
  69. package/lib/private/UUIDV7Type.d.ts +1 -1
  70. package/lib/private/UUIDV7Type.js +3 -1
  71. package/lib/private/UintType.d.ts +2 -2
  72. package/lib/private/UintType.js +2 -2
  73. package/lib/private/UnionType.d.ts +6 -3
  74. package/lib/private/UnionType.js +10 -5
  75. package/lib/private/VirtualType.js +2 -2
  76. package/lib/private/array.d.ts +6 -4
  77. package/lib/private/array.js +10 -2
  78. package/lib/private/blob.d.ts +6 -2
  79. package/lib/private/blob.js +5 -1
  80. package/lib/private/boolean.d.ts +5 -4
  81. package/lib/private/boolean.js +5 -4
  82. package/lib/private/coerce/date.js +3 -5
  83. package/lib/private/coerce/int.js +1 -1
  84. package/lib/private/constructor.d.ts +6 -5
  85. package/lib/private/constructor.js +11 -1
  86. package/lib/private/date.d.ts +6 -2
  87. package/lib/private/date.js +5 -1
  88. package/lib/private/dict.d.ts +12 -2
  89. package/lib/private/dict.js +10 -2
  90. package/lib/private/enum.d.ts +9 -1
  91. package/lib/private/enum.js +8 -1
  92. package/lib/private/errors.js +5 -6
  93. package/lib/private/f32.d.ts +6 -2
  94. package/lib/private/f32.js +5 -1
  95. package/lib/private/f64.d.ts +6 -2
  96. package/lib/private/f64.js +5 -1
  97. package/lib/private/file.d.ts +6 -2
  98. package/lib/private/file.js +5 -1
  99. package/lib/private/function.d.ts +6 -5
  100. package/lib/private/function.js +5 -1
  101. package/lib/private/i128.d.ts +6 -2
  102. package/lib/private/i128.js +5 -1
  103. package/lib/private/i16.d.ts +6 -2
  104. package/lib/private/i16.js +5 -1
  105. package/lib/private/i32.d.ts +6 -2
  106. package/lib/private/i32.js +5 -1
  107. package/lib/private/i64.d.ts +6 -2
  108. package/lib/private/i64.js +5 -1
  109. package/lib/private/i8.d.ts +6 -2
  110. package/lib/private/i8.js +5 -1
  111. package/lib/private/index.d.ts +257 -41
  112. package/lib/private/index.js +148 -41
  113. package/lib/private/is-parsed.d.ts +3 -0
  114. package/lib/private/is-parsed.js +7 -0
  115. package/lib/private/is.d.ts +6 -2
  116. package/lib/private/is.js +9 -1
  117. package/lib/private/json.d.ts +12 -2
  118. package/lib/private/json.js +9 -1
  119. package/lib/private/literal.d.ts +9 -1
  120. package/lib/private/literal.js +10 -1
  121. package/lib/private/normalize.js +4 -11
  122. package/lib/private/null.d.ts +6 -2
  123. package/lib/private/null.js +5 -1
  124. package/lib/private/object.d.ts +11 -4
  125. package/lib/private/object.js +17 -1
  126. package/lib/private/omit.d.ts +9 -1
  127. package/lib/private/omit.js +9 -1
  128. package/lib/private/partial.d.ts +9 -2
  129. package/lib/private/partial.js +11 -2
  130. package/lib/private/path/next.d.ts +1 -7
  131. package/lib/private/pure.d.ts +9 -1
  132. package/lib/private/pure.js +9 -1
  133. package/lib/private/record.d.ts +6 -5
  134. package/lib/private/record.js +9 -1
  135. package/lib/private/resolve.d.ts +2 -0
  136. package/lib/private/resolve.js +7 -0
  137. package/lib/private/spec/bigint.d.ts +5 -1
  138. package/lib/private/spec/bigint.js +28 -26
  139. package/lib/private/spec/biguint.d.ts +5 -1
  140. package/lib/private/spec/biguint.js +30 -22
  141. package/lib/private/spec/int.d.ts +5 -1
  142. package/lib/private/spec/int.js +25 -23
  143. package/lib/private/spec/uint.d.ts +5 -1
  144. package/lib/private/spec/uint.js +23 -21
  145. package/lib/private/string.d.ts +6 -5
  146. package/lib/private/string.js +5 -4
  147. package/lib/private/symbol.d.ts +6 -2
  148. package/lib/private/symbol.js +5 -1
  149. package/lib/private/test.d.ts +4 -21
  150. package/lib/private/test.js +0 -44
  151. package/lib/private/tuple.d.ts +9 -2
  152. package/lib/private/tuple.js +11 -1
  153. package/lib/private/u128.d.ts +6 -2
  154. package/lib/private/u128.js +5 -1
  155. package/lib/private/u16.d.ts +6 -2
  156. package/lib/private/u16.js +5 -1
  157. package/lib/private/u32.d.ts +6 -5
  158. package/lib/private/u32.js +5 -4
  159. package/lib/private/u64.d.ts +6 -2
  160. package/lib/private/u64.js +5 -1
  161. package/lib/private/u8.d.ts +6 -2
  162. package/lib/private/u8.js +5 -1
  163. package/lib/private/undefined.d.ts +5 -1
  164. package/lib/private/undefined.js +4 -1
  165. package/lib/private/union.d.ts +12 -3
  166. package/lib/private/union.js +9 -1
  167. package/lib/private/unknown.d.ts +5 -4
  168. package/lib/private/unknown.js +4 -1
  169. package/lib/private/url.d.ts +6 -2
  170. package/lib/private/url.js +5 -1
  171. package/lib/private/uuid.d.ts +6 -2
  172. package/lib/private/uuid.js +5 -1
  173. package/package.json +8 -7
  174. package/lib/private/is-parsed-type.d.ts +0 -3
  175. package/lib/private/is-parsed-type.js +0 -6
@@ -2,5 +2,9 @@ import BigUintType from "#BigUintType";
2
2
  import range from "#validator/range";
3
3
  const from = 0n;
4
4
  const to = 2n ** 64n - 1n;
5
- export default new BigUintType("u64", [range(from, to)]);
5
+ const vanilla = new BigUintType("u64", undefined, [range(from, to)]);
6
+ const loose = new BigUintType("u64", true, [range(from, to)]);
7
+ const strict = new BigUintType("u64", false, [range(from, to)]);
8
+ const u64 = { vanilla, loose, strict };
9
+ export default u64;
6
10
  //# sourceMappingURL=u64.js.map
@@ -1,4 +1,8 @@
1
1
  import UintType from "#UintType";
2
- declare const _default: UintType<"u8">;
3
- export default _default;
2
+ declare const u8: {
3
+ vanilla: UintType<"u8", undefined>;
4
+ loose: UintType<"u8", true>;
5
+ strict: UintType<"u8", false>;
6
+ };
7
+ export default u8;
4
8
  //# sourceMappingURL=u8.d.ts.map
package/lib/private/u8.js CHANGED
@@ -2,5 +2,9 @@ import UintType from "#UintType";
2
2
  import range from "#validator/range";
3
3
  const from = 0;
4
4
  const to = 2 ** 8 - 1;
5
- export default new UintType("u8", [range(from, to)]);
5
+ const vanilla = new UintType("u8", undefined, [range(from, to)]);
6
+ const loose = new UintType("u8", true, [range(from, to)]);
7
+ const strict = new UintType("u8", false, [range(from, to)]);
8
+ const u8 = { vanilla, loose, strict };
9
+ export default u8;
6
10
  //# sourceMappingURL=u8.js.map
@@ -1,4 +1,8 @@
1
1
  import UndefinedType from "#UndefinedType";
2
- declare const _default: UndefinedType;
2
+ declare const _default: {
3
+ vanilla: UndefinedType;
4
+ loose: UndefinedType;
5
+ strict: UndefinedType;
6
+ };
3
7
  export default _default;
4
8
  //# sourceMappingURL=undefined.d.ts.map
@@ -1,3 +1,6 @@
1
1
  import UndefinedType from "#UndefinedType";
2
- export default new UndefinedType();
2
+ const vanilla = new UndefinedType();
3
+ const loose = new UndefinedType();
4
+ const strict = new UndefinedType();
5
+ export default { vanilla, loose, strict };
3
6
  //# sourceMappingURL=undefined.js.map
@@ -4,7 +4,16 @@ import UnionType from "#UnionType";
4
4
  type NormalizeArray<T extends Schema[]> = {
5
5
  [K in keyof T]: NormalizeSchema<T[K]>;
6
6
  };
7
- export default function union(): UnionType<[]>;
8
- export default function union<const T extends Schema[]>(...types: T): UnionType<NormalizeArray<T>>;
9
- export {};
7
+ declare function vanilla(): UnionType<[]>;
8
+ declare function vanilla<const T extends Schema[]>(...types: T): UnionType<NormalizeArray<T>>;
9
+ declare function loose(): UnionType<[], true>;
10
+ declare function loose<const T extends Schema[]>(...types: T): UnionType<NormalizeArray<T>, true>;
11
+ declare function strict(): UnionType<[], false>;
12
+ declare function strict<const T extends Schema[]>(...types: T): UnionType<NormalizeArray<T>, false>;
13
+ declare const union: {
14
+ vanilla: typeof vanilla;
15
+ loose: typeof loose;
16
+ strict: typeof strict;
17
+ };
18
+ export default union;
10
19
  //# sourceMappingURL=union.d.ts.map
@@ -1,6 +1,14 @@
1
1
  import UnionType from "#UnionType";
2
2
  import normalize from "#normalize";
3
- export default function union(...types) {
3
+ function vanilla(...types) {
4
4
  return new UnionType(types.map(normalize));
5
5
  }
6
+ function loose(...types) {
7
+ return new UnionType(types.map(normalize), true);
8
+ }
9
+ function strict(...types) {
10
+ return new UnionType(types.map(normalize), false);
11
+ }
12
+ const union = { vanilla, loose, strict };
13
+ export default union;
6
14
  //# sourceMappingURL=union.js.map
@@ -1,7 +1,8 @@
1
1
  import UnknownType from "#UnknownType";
2
- /**
3
- * Value is an unknown type.
4
- */
5
- declare const _default: UnknownType;
2
+ declare const _default: {
3
+ vanilla: UnknownType;
4
+ loose: UnknownType;
5
+ strict: UnknownType;
6
+ };
6
7
  export default _default;
7
8
  //# sourceMappingURL=unknown.d.ts.map
@@ -2,5 +2,8 @@ import UnknownType from "#UnknownType";
2
2
  /**
3
3
  * Value is an unknown type.
4
4
  */
5
- export default new UnknownType();
5
+ const vanilla = new UnknownType();
6
+ const loose = new UnknownType();
7
+ const strict = new UnknownType();
8
+ export default { vanilla, loose, strict };
6
9
  //# sourceMappingURL=unknown.js.map
@@ -1,4 +1,8 @@
1
1
  import URLType from "#URLType";
2
- declare const _default: URLType;
3
- export default _default;
2
+ declare const url: {
3
+ vanilla: URLType<undefined>;
4
+ loose: URLType<true>;
5
+ strict: URLType<false>;
6
+ };
7
+ export default url;
4
8
  //# sourceMappingURL=url.d.ts.map
@@ -1,3 +1,7 @@
1
1
  import URLType from "#URLType";
2
- export default new URLType();
2
+ const vanilla = new URLType();
3
+ const loose = new URLType(true);
4
+ const strict = new URLType(false);
5
+ const url = { vanilla, loose, strict };
6
+ export default url;
3
7
  //# sourceMappingURL=url.js.map
@@ -1,4 +1,8 @@
1
1
  import UUIDType from "#UUIDType";
2
- declare const _default: UUIDType;
3
- export default _default;
2
+ declare const uuid: {
3
+ vanilla: UUIDType;
4
+ loose: UUIDType;
5
+ strict: UUIDType;
6
+ };
7
+ export default uuid;
4
8
  //# sourceMappingURL=uuid.d.ts.map
@@ -1,3 +1,7 @@
1
1
  import UUIDType from "#UUIDType";
2
- export default new UUIDType();
2
+ const vanilla = new UUIDType();
3
+ const loose = new UUIDType();
4
+ const strict = new UUIDType();
5
+ const uuid = { vanilla, loose, strict };
6
+ export default uuid;
3
7
  //# sourceMappingURL=uuid.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pema",
3
- "version": "0.6.1",
3
+ "version": "0.8.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",
@@ -17,13 +17,14 @@
17
17
  "!/**/*.spec.*"
18
18
  ],
19
19
  "dependencies": {
20
- "@rcompat/assert": "^0.8.1",
21
- "@rcompat/cli": "^0.18.1",
22
- "@rcompat/error": "^0.3.1",
23
- "@rcompat/is": "^0.6.1"
20
+ "@rcompat/assert": "^0.13.0",
21
+ "@rcompat/cli": "^0.24.0",
22
+ "@rcompat/error": "^0.8.0",
23
+ "@rcompat/is": "^0.11.0",
24
+ "@rcompat/symbol": "^0.2.0"
24
25
  },
25
26
  "devDependencies": {
26
- "@rcompat/type": "^0.11.1"
27
+ "@rcompat/type": "^0.17.0"
27
28
  },
28
29
  "imports": {
29
30
  "#*": {
@@ -42,7 +43,7 @@
42
43
  }
43
44
  },
44
45
  "scripts": {
45
- "build": "npm run clean && tsc",
46
+ "build": "npm run clean && tsgo",
46
47
  "clean": "rm -rf ./lib",
47
48
  "lint": "eslint .",
48
49
  "lint:fix": "eslint . --fix",
@@ -1,3 +0,0 @@
1
- import type Parsed from "#Parsed";
2
- export default function isParsedType(x: unknown): x is Parsed<unknown>;
3
- //# sourceMappingURL=is-parsed-type.d.ts.map
@@ -1,6 +0,0 @@
1
- import ParsedKey from "#ParsedKey";
2
- export default function isParsedType(x) {
3
- return !!x && typeof x === "object" && ParsedKey in x;
4
- }
5
- ;
6
- //# sourceMappingURL=is-parsed-type.js.map