pema 0.7.0 → 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 (107) hide show
  1. package/lib/private/ArrayType.d.ts +5 -2
  2. package/lib/private/ArrayType.js +4 -2
  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/DateType.d.ts +4 -1
  8. package/lib/private/DateType.js +6 -0
  9. package/lib/private/IntType.d.ts +1 -1
  10. package/lib/private/LiteralType.d.ts +5 -2
  11. package/lib/private/LiteralType.js +7 -4
  12. package/lib/private/Mode.d.ts +3 -0
  13. package/lib/private/Mode.js +2 -0
  14. package/lib/private/NumberType.d.ts +1 -1
  15. package/lib/private/NumericType.d.ts +5 -2
  16. package/lib/private/NumericType.js +5 -2
  17. package/lib/private/ObjectType.d.ts +7 -4
  18. package/lib/private/ObjectType.js +6 -8
  19. package/lib/private/OmitType.d.ts +5 -2
  20. package/lib/private/OmitType.js +4 -1
  21. package/lib/private/PartialType.d.ts +5 -2
  22. package/lib/private/PartialType.js +4 -1
  23. package/lib/private/RecordType.d.ts +7 -4
  24. package/lib/private/RecordType.js +4 -1
  25. package/lib/private/Serialized.d.ts +13 -13
  26. package/lib/private/StoreType.d.ts +1 -1
  27. package/lib/private/TupleType.d.ts +5 -2
  28. package/lib/private/TupleType.js +3 -1
  29. package/lib/private/URLType.d.ts +6 -1
  30. package/lib/private/URLType.js +21 -0
  31. package/lib/private/UintType.d.ts +1 -1
  32. package/lib/private/UnionType.d.ts +5 -2
  33. package/lib/private/UnionType.js +4 -1
  34. package/lib/private/array.d.ts +2 -2
  35. package/lib/private/array.js +2 -7
  36. package/lib/private/blob.js +0 -3
  37. package/lib/private/boolean.d.ts +5 -5
  38. package/lib/private/boolean.js +5 -8
  39. package/lib/private/constructor.js +2 -7
  40. package/lib/private/date.d.ts +3 -3
  41. package/lib/private/date.js +2 -5
  42. package/lib/private/dict.d.ts +4 -4
  43. package/lib/private/enum.d.ts +3 -3
  44. package/lib/private/enum.js +3 -9
  45. package/lib/private/f32.d.ts +3 -3
  46. package/lib/private/f32.js +3 -6
  47. package/lib/private/f64.d.ts +3 -3
  48. package/lib/private/f64.js +2 -5
  49. package/lib/private/file.js +0 -3
  50. package/lib/private/function.js +0 -3
  51. package/lib/private/i128.d.ts +3 -3
  52. package/lib/private/i128.js +3 -6
  53. package/lib/private/i16.d.ts +3 -3
  54. package/lib/private/i16.js +3 -6
  55. package/lib/private/i32.d.ts +3 -3
  56. package/lib/private/i32.js +3 -6
  57. package/lib/private/i64.d.ts +3 -3
  58. package/lib/private/i64.js +3 -6
  59. package/lib/private/i8.d.ts +3 -3
  60. package/lib/private/i8.js +3 -6
  61. package/lib/private/index.d.ts +241 -43
  62. package/lib/private/is.js +2 -7
  63. package/lib/private/json.js +2 -7
  64. package/lib/private/literal.d.ts +5 -5
  65. package/lib/private/literal.js +3 -9
  66. package/lib/private/null.js +0 -3
  67. package/lib/private/object.d.ts +2 -2
  68. package/lib/private/object.js +2 -7
  69. package/lib/private/omit.d.ts +2 -2
  70. package/lib/private/omit.js +2 -7
  71. package/lib/private/partial.d.ts +2 -2
  72. package/lib/private/partial.js +2 -7
  73. package/lib/private/pure.js +2 -7
  74. package/lib/private/record.d.ts +3 -3
  75. package/lib/private/record.js +2 -7
  76. package/lib/private/spec/bigint.d.ts +3 -2
  77. package/lib/private/spec/bigint.js +1 -0
  78. package/lib/private/spec/biguint.d.ts +3 -2
  79. package/lib/private/spec/biguint.js +7 -0
  80. package/lib/private/spec/int.d.ts +3 -2
  81. package/lib/private/spec/int.js +2 -1
  82. package/lib/private/spec/uint.d.ts +3 -2
  83. package/lib/private/spec/uint.js +1 -0
  84. package/lib/private/string.js +0 -3
  85. package/lib/private/symbol.js +0 -3
  86. package/lib/private/tuple.d.ts +2 -2
  87. package/lib/private/tuple.js +2 -7
  88. package/lib/private/u128.d.ts +3 -3
  89. package/lib/private/u128.js +3 -6
  90. package/lib/private/u16.d.ts +3 -3
  91. package/lib/private/u16.js +3 -6
  92. package/lib/private/u32.d.ts +3 -3
  93. package/lib/private/u32.js +3 -9
  94. package/lib/private/u64.d.ts +3 -3
  95. package/lib/private/u64.js +3 -6
  96. package/lib/private/u8.d.ts +3 -3
  97. package/lib/private/u8.js +3 -6
  98. package/lib/private/undefined.d.ts +2 -2
  99. package/lib/private/undefined.js +1 -5
  100. package/lib/private/union.d.ts +4 -4
  101. package/lib/private/union.js +2 -7
  102. package/lib/private/unknown.d.ts +2 -2
  103. package/lib/private/unknown.js +1 -5
  104. package/lib/private/url.d.ts +3 -3
  105. package/lib/private/url.js +2 -5
  106. package/lib/private/uuid.js +0 -3
  107. package/package.json +2 -2
@@ -1,6 +1,6 @@
1
1
  import test from "#test";
2
2
  export default (t, min, max) => {
3
- const { strict, loose } = t;
3
+ const { vanilla, strict, loose } = t;
4
4
  test.case("fail", assert => {
5
5
  assert(strict).invalid_type(["1", 0n, 1n, 1.1, -1.1]);
6
6
  });
@@ -15,6 +15,7 @@ export default (t, min, max) => {
15
15
  assert(strict).out_of_range([min - 1, max + 1]);
16
16
  });
17
17
  test.case("loose", assert => {
18
+ assert(loose).type();
18
19
  assert(loose.parse(0)).equals(0).type();
19
20
  assert(loose.parse(1)).equals(1).type();
20
21
  assert(loose.parse("1")).equals(1).type();
@@ -1,8 +1,9 @@
1
1
  import type UintDataType from "#UintDataType";
2
2
  import type UintType from "#UintType";
3
3
  declare const _default: <T extends UintDataType>(t: {
4
- loose: UintType<T>;
5
- strict: UintType<T>;
4
+ vanilla: UintType<T>;
5
+ loose: UintType<T, true>;
6
+ strict: UintType<T, false>;
6
7
  }, min: number, max: number) => void;
7
8
  export default _default;
8
9
  //# sourceMappingURL=uint.d.ts.map
@@ -15,6 +15,7 @@ export default (t, min, max) => {
15
15
  assert(strict).out_of_range([-1, min - 1, max + 1]);
16
16
  });
17
17
  test.case("loose", assert => {
18
+ assert(loose).type();
18
19
  assert(loose.parse(0)).equals(0).type();
19
20
  assert(loose.parse(1)).equals(1).type();
20
21
  assert(loose.parse("1")).equals(1).type();
@@ -1,10 +1,7 @@
1
- import Loose from "#Loose";
2
1
  import StringType from "#StringType";
3
2
  const vanilla = new StringType();
4
3
  const loose = new StringType();
5
- loose[Loose] = true;
6
4
  const strict = new StringType();
7
- strict[Loose] = false;
8
5
  const string = { vanilla, loose, strict };
9
6
  export default string;
10
7
  //# sourceMappingURL=string.js.map
@@ -1,10 +1,7 @@
1
- import Loose from "#Loose";
2
1
  import SymbolType from "#SymbolType";
3
2
  const vanilla = new SymbolType();
4
3
  const loose = new SymbolType();
5
- loose[Loose] = true;
6
4
  const strict = new SymbolType();
7
- strict[Loose] = false;
8
5
  const symbol = { vanilla, loose, strict };
9
6
  export default symbol;
10
7
  //# sourceMappingURL=symbol.js.map
@@ -5,8 +5,8 @@ type NormalizeSchemaArray<T extends Schema[]> = {
5
5
  [K in keyof T]: NormalizeSchema<T[K]>;
6
6
  };
7
7
  declare function vanilla<const T extends Schema[]>(...items: T): TupleType<NormalizeSchemaArray<T>>;
8
- declare function loose<const T extends Schema[]>(...items: T): TupleType<NormalizeSchemaArray<T>>;
9
- declare function strict<const T extends Schema[]>(...items: T): TupleType<NormalizeSchemaArray<T>>;
8
+ declare function loose<const T extends Schema[]>(...items: T): TupleType<NormalizeSchemaArray<T>, true>;
9
+ declare function strict<const T extends Schema[]>(...items: T): TupleType<NormalizeSchemaArray<T>, false>;
10
10
  declare const tuple: {
11
11
  vanilla: typeof vanilla;
12
12
  loose: typeof loose;
@@ -1,4 +1,3 @@
1
- import Loose from "#Loose";
2
1
  import TupleType from "#TupleType";
3
2
  import normalize from "#normalize";
4
3
  function vanilla(...items) {
@@ -8,15 +7,11 @@ function vanilla(...items) {
8
7
  }
9
8
  function loose(...items) {
10
9
  const parsed = items.map(normalize);
11
- const i = new TupleType(parsed);
12
- i[Loose] = true;
13
- return i;
10
+ return new TupleType(parsed, true);
14
11
  }
15
12
  function strict(...items) {
16
13
  const parsed = items.map(normalize);
17
- const i = new TupleType(parsed);
18
- i[Loose] = false;
19
- return i;
14
+ return new TupleType(parsed, false);
20
15
  }
21
16
  const tuple = { vanilla, loose, strict };
22
17
  export default tuple;
@@ -1,8 +1,8 @@
1
1
  import BigUintType from "#BigUintType";
2
2
  declare const u128: {
3
- vanilla: BigUintType<"u128">;
4
- loose: BigUintType<"u128">;
5
- strict: BigUintType<"u128">;
3
+ vanilla: BigUintType<"u128", undefined>;
4
+ loose: BigUintType<"u128", true>;
5
+ strict: BigUintType<"u128", false>;
6
6
  };
7
7
  export default u128;
8
8
  //# sourceMappingURL=u128.d.ts.map
@@ -1,13 +1,10 @@
1
1
  import BigUintType from "#BigUintType";
2
- import Loose from "#Loose";
3
2
  import range from "#validator/range";
4
3
  const from = 0n;
5
4
  const to = 2n ** 128n - 1n;
6
- const vanilla = new BigUintType("u128", [range(from, to)]);
7
- const loose = new BigUintType("u128", [range(from, to)]);
8
- loose[Loose] = true;
9
- const strict = new BigUintType("u128", [range(from, to)]);
10
- strict[Loose] = false;
5
+ const vanilla = new BigUintType("u128", undefined, [range(from, to)]);
6
+ const loose = new BigUintType("u128", true, [range(from, to)]);
7
+ const strict = new BigUintType("u128", false, [range(from, to)]);
11
8
  const u128 = { vanilla, loose, strict };
12
9
  export default u128;
13
10
  //# sourceMappingURL=u128.js.map
@@ -1,8 +1,8 @@
1
1
  import UintType from "#UintType";
2
2
  declare const u16: {
3
- vanilla: UintType<"u16">;
4
- loose: UintType<"u16">;
5
- strict: UintType<"u16">;
3
+ vanilla: UintType<"u16", undefined>;
4
+ loose: UintType<"u16", true>;
5
+ strict: UintType<"u16", false>;
6
6
  };
7
7
  export default u16;
8
8
  //# sourceMappingURL=u16.d.ts.map
@@ -1,13 +1,10 @@
1
- import Loose from "#Loose";
2
1
  import UintType from "#UintType";
3
2
  import range from "#validator/range";
4
3
  const from = 0;
5
4
  const to = 2 ** 16 - 1;
6
- const vanilla = new UintType("u16", [range(from, to)]);
7
- const loose = new UintType("u16", [range(from, to)]);
8
- loose[Loose] = true;
9
- const strict = new UintType("u16", [range(from, to)]);
10
- strict[Loose] = false;
5
+ const vanilla = new UintType("u16", undefined, [range(from, to)]);
6
+ const loose = new UintType("u16", true, [range(from, to)]);
7
+ const strict = new UintType("u16", false, [range(from, to)]);
11
8
  const u16 = { vanilla, loose, strict };
12
9
  export default u16;
13
10
  //# sourceMappingURL=u16.js.map
@@ -1,8 +1,8 @@
1
1
  import UintType from "#UintType";
2
2
  declare const u32: {
3
- vanilla: UintType<"u32">;
4
- loose: UintType<"u32">;
5
- strict: UintType<"u32">;
3
+ vanilla: UintType<"u32", undefined>;
4
+ loose: UintType<"u32", true>;
5
+ strict: UintType<"u32", false>;
6
6
  };
7
7
  export default u32;
8
8
  //# sourceMappingURL=u32.d.ts.map
@@ -1,16 +1,10 @@
1
- import Loose from "#Loose";
2
1
  import UintType from "#UintType";
3
2
  import range from "#validator/range";
4
3
  const from = 0;
5
4
  const to = 2 ** 32 - 1;
6
- /**
7
- * Value is an unsigned integer.
8
- */
9
- const vanilla = new UintType("u32", [range(from, to)]);
10
- const loose = new UintType("u32", [range(from, to)]);
11
- loose[Loose] = true;
12
- const strict = new UintType("u32", [range(from, to)]);
13
- strict[Loose] = false;
5
+ const vanilla = new UintType("u32", undefined, [range(from, to)]);
6
+ const loose = new UintType("u32", true, [range(from, to)]);
7
+ const strict = new UintType("u32", false, [range(from, to)]);
14
8
  const u32 = { vanilla, loose, strict };
15
9
  export default u32;
16
10
  //# sourceMappingURL=u32.js.map
@@ -1,8 +1,8 @@
1
1
  import BigUintType from "#BigUintType";
2
2
  declare const u64: {
3
- vanilla: BigUintType<"u64">;
4
- loose: BigUintType<"u64">;
5
- strict: BigUintType<"u64">;
3
+ vanilla: BigUintType<"u64", undefined>;
4
+ loose: BigUintType<"u64", true>;
5
+ strict: BigUintType<"u64", false>;
6
6
  };
7
7
  export default u64;
8
8
  //# sourceMappingURL=u64.d.ts.map
@@ -1,13 +1,10 @@
1
1
  import BigUintType from "#BigUintType";
2
- import Loose from "#Loose";
3
2
  import range from "#validator/range";
4
3
  const from = 0n;
5
4
  const to = 2n ** 64n - 1n;
6
- const vanilla = new BigUintType("u64", [range(from, to)]);
7
- const loose = new BigUintType("u64", [range(from, to)]);
8
- loose[Loose] = true;
9
- const strict = new BigUintType("u64", [range(from, to)]);
10
- strict[Loose] = false;
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)]);
11
8
  const u64 = { vanilla, loose, strict };
12
9
  export default u64;
13
10
  //# sourceMappingURL=u64.js.map
@@ -1,8 +1,8 @@
1
1
  import UintType from "#UintType";
2
2
  declare const u8: {
3
- vanilla: UintType<"u8">;
4
- loose: UintType<"u8">;
5
- strict: UintType<"u8">;
3
+ vanilla: UintType<"u8", undefined>;
4
+ loose: UintType<"u8", true>;
5
+ strict: UintType<"u8", false>;
6
6
  };
7
7
  export default u8;
8
8
  //# sourceMappingURL=u8.d.ts.map
package/lib/private/u8.js CHANGED
@@ -1,13 +1,10 @@
1
- import Loose from "#Loose";
2
1
  import UintType from "#UintType";
3
2
  import range from "#validator/range";
4
3
  const from = 0;
5
4
  const to = 2 ** 8 - 1;
6
- const vanilla = new UintType("u8", [range(from, to)]);
7
- const loose = new UintType("u8", [range(from, to)]);
8
- loose[Loose] = true;
9
- const strict = new UintType("u8", [range(from, to)]);
10
- strict[Loose] = false;
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)]);
11
8
  const u8 = { vanilla, loose, strict };
12
9
  export default u8;
13
10
  //# sourceMappingURL=u8.js.map
@@ -1,8 +1,8 @@
1
1
  import UndefinedType from "#UndefinedType";
2
- declare const undefined_: {
2
+ declare const _default: {
3
3
  vanilla: UndefinedType;
4
4
  loose: UndefinedType;
5
5
  strict: UndefinedType;
6
6
  };
7
- export default undefined_;
7
+ export default _default;
8
8
  //# sourceMappingURL=undefined.d.ts.map
@@ -1,10 +1,6 @@
1
- import Loose from "#Loose";
2
1
  import UndefinedType from "#UndefinedType";
3
2
  const vanilla = new UndefinedType();
4
3
  const loose = new UndefinedType();
5
- loose[Loose] = true;
6
4
  const strict = new UndefinedType();
7
- strict[Loose] = false;
8
- const undefined_ = { vanilla, loose, strict };
9
- export default undefined_;
5
+ export default { vanilla, loose, strict };
10
6
  //# sourceMappingURL=undefined.js.map
@@ -6,10 +6,10 @@ type NormalizeArray<T extends Schema[]> = {
6
6
  };
7
7
  declare function vanilla(): UnionType<[]>;
8
8
  declare function vanilla<const T extends Schema[]>(...types: T): UnionType<NormalizeArray<T>>;
9
- declare function loose(): UnionType<[]>;
10
- declare function loose<const T extends Schema[]>(...types: T): UnionType<NormalizeArray<T>>;
11
- declare function strict(): UnionType<[]>;
12
- declare function strict<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
13
  declare const union: {
14
14
  vanilla: typeof vanilla;
15
15
  loose: typeof loose;
@@ -1,18 +1,13 @@
1
- import Loose from "#Loose";
2
1
  import UnionType from "#UnionType";
3
2
  import normalize from "#normalize";
4
3
  function vanilla(...types) {
5
4
  return new UnionType(types.map(normalize));
6
5
  }
7
6
  function loose(...types) {
8
- const i = new UnionType(types.map(normalize));
9
- i[Loose] = true;
10
- return i;
7
+ return new UnionType(types.map(normalize), true);
11
8
  }
12
9
  function strict(...types) {
13
- const i = new UnionType(types.map(normalize));
14
- i[Loose] = false;
15
- return i;
10
+ return new UnionType(types.map(normalize), false);
16
11
  }
17
12
  const union = { vanilla, loose, strict };
18
13
  export default union;
@@ -1,8 +1,8 @@
1
1
  import UnknownType from "#UnknownType";
2
- declare const unknown: {
2
+ declare const _default: {
3
3
  vanilla: UnknownType;
4
4
  loose: UnknownType;
5
5
  strict: UnknownType;
6
6
  };
7
- export default unknown;
7
+ export default _default;
8
8
  //# sourceMappingURL=unknown.d.ts.map
@@ -1,13 +1,9 @@
1
- import Loose from "#Loose";
2
1
  import UnknownType from "#UnknownType";
3
2
  /**
4
3
  * Value is an unknown type.
5
4
  */
6
5
  const vanilla = new UnknownType();
7
6
  const loose = new UnknownType();
8
- loose[Loose] = true;
9
7
  const strict = new UnknownType();
10
- strict[Loose] = false;
11
- const unknown = { vanilla, loose, strict };
12
- export default unknown;
8
+ export default { vanilla, loose, strict };
13
9
  //# sourceMappingURL=unknown.js.map
@@ -1,8 +1,8 @@
1
1
  import URLType from "#URLType";
2
2
  declare const url: {
3
- vanilla: URLType;
4
- loose: URLType;
5
- strict: URLType;
3
+ vanilla: URLType<undefined>;
4
+ loose: URLType<true>;
5
+ strict: URLType<false>;
6
6
  };
7
7
  export default url;
8
8
  //# sourceMappingURL=url.d.ts.map
@@ -1,10 +1,7 @@
1
- import Loose from "#Loose";
2
1
  import URLType from "#URLType";
3
2
  const vanilla = new URLType();
4
- const loose = new URLType();
5
- loose[Loose] = true;
6
- const strict = new URLType();
7
- strict[Loose] = false;
3
+ const loose = new URLType(true);
4
+ const strict = new URLType(false);
8
5
  const url = { vanilla, loose, strict };
9
6
  export default url;
10
7
  //# sourceMappingURL=url.js.map
@@ -1,10 +1,7 @@
1
- import Loose from "#Loose";
2
1
  import UUIDType from "#UUIDType";
3
2
  const vanilla = new UUIDType();
4
3
  const loose = new UUIDType();
5
- loose[Loose] = true;
6
4
  const strict = new UUIDType();
7
- strict[Loose] = false;
8
5
  const uuid = { vanilla, loose, strict };
9
6
  export default uuid;
10
7
  //# sourceMappingURL=uuid.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pema",
3
- "version": "0.7.0",
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",
@@ -43,7 +43,7 @@
43
43
  }
44
44
  },
45
45
  "scripts": {
46
- "build": "npm run clean && tsc",
46
+ "build": "npm run clean && tsgo",
47
47
  "clean": "rm -rf ./lib",
48
48
  "lint": "eslint .",
49
49
  "lint:fix": "eslint . --fix",