effect 4.0.0-beta.39 → 4.0.0-beta.40
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/dist/Effect.d.ts +5 -5
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +1 -1
- package/dist/Equivalence.d.ts +8 -3
- package/dist/Equivalence.d.ts.map +1 -1
- package/dist/Equivalence.js +18 -13
- package/dist/Equivalence.js.map +1 -1
- package/dist/Order.d.ts +6 -1
- package/dist/Order.d.ts.map +1 -1
- package/dist/Order.js +19 -14
- package/dist/Order.js.map +1 -1
- package/dist/Schema.d.ts +9 -4
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +28 -22
- package/dist/Schema.js.map +1 -1
- package/dist/Stream.d.ts +22 -0
- package/dist/Stream.d.ts.map +1 -1
- package/dist/Stream.js +45 -3
- package/dist/Stream.js.map +1 -1
- package/dist/internal/effect.js +2 -2
- package/dist/internal/effect.js.map +1 -1
- package/dist/unstable/socket/Socket.js +1 -1
- package/dist/unstable/socket/Socket.js.map +1 -1
- package/package.json +1 -1
- package/src/Effect.ts +5 -5
- package/src/Equivalence.ts +58 -52
- package/src/Order.ts +39 -32
- package/src/Schema.ts +44 -36
- package/src/Stream.ts +87 -5
- package/src/internal/effect.ts +5 -5
- package/src/unstable/socket/Socket.ts +1 -1
package/dist/Schema.js
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
*
|
|
23
23
|
* - Define a struct: {@link Struct}
|
|
24
24
|
* - Define a union: {@link Union}, {@link TaggedUnion}, {@link Literals}
|
|
25
|
-
* - Define an array: {@link
|
|
25
|
+
* - Define an array: {@link ArraySchema}, {@link NonEmptyArray}
|
|
26
26
|
* - Define a record: {@link Record}
|
|
27
27
|
* - Define a tuple: {@link Tuple}, {@link TupleWithRest}
|
|
28
28
|
* - Validate unknown data synchronously: {@link decodeUnknownSync}
|
|
@@ -1518,6 +1518,14 @@ export function TupleWithRest(schema, rest) {
|
|
|
1518
1518
|
rest
|
|
1519
1519
|
});
|
|
1520
1520
|
}
|
|
1521
|
+
/**
|
|
1522
|
+
* @category Constructors
|
|
1523
|
+
* @since 4.0.0
|
|
1524
|
+
*/
|
|
1525
|
+
const ArraySchema = /*#__PURE__*/Struct_.lambda(schema => make(new AST.Arrays(false, [], [schema.ast]), {
|
|
1526
|
+
schema
|
|
1527
|
+
}));
|
|
1528
|
+
export {
|
|
1521
1529
|
/**
|
|
1522
1530
|
* Defines a `ReadonlyArray` schema for a given element schema.
|
|
1523
1531
|
*
|
|
@@ -1536,9 +1544,7 @@ export function TupleWithRest(schema, rest) {
|
|
|
1536
1544
|
* @category Constructors
|
|
1537
1545
|
* @since 4.0.0
|
|
1538
1546
|
*/
|
|
1539
|
-
|
|
1540
|
-
schema
|
|
1541
|
-
}));
|
|
1547
|
+
ArraySchema as Array };
|
|
1542
1548
|
/**
|
|
1543
1549
|
* Defines a non-empty `ReadonlyArray` schema — at least one element required.
|
|
1544
1550
|
* Type is `readonly [T, ...T[]]`.
|
|
@@ -1575,7 +1581,7 @@ export const NonEmptyArray = /*#__PURE__*/Struct_.lambda(schema => make(new AST.
|
|
|
1575
1581
|
* @since 4.0.0
|
|
1576
1582
|
*/
|
|
1577
1583
|
export function ArrayEnsure(schema) {
|
|
1578
|
-
return Union([schema,
|
|
1584
|
+
return Union([schema, ArraySchema(schema)]).pipe(decodeTo(ArraySchema(toType(schema)), Transformation.transform({
|
|
1579
1585
|
decode: Arr.ensure,
|
|
1580
1586
|
encode: array => array.length === 1 ? array[0] : array
|
|
1581
1587
|
})));
|
|
@@ -1590,7 +1596,7 @@ export function ArrayEnsure(schema) {
|
|
|
1590
1596
|
* @since 4.0.0
|
|
1591
1597
|
*/
|
|
1592
1598
|
export function UniqueArray(item) {
|
|
1593
|
-
return
|
|
1599
|
+
return ArraySchema(item).check(isUnique());
|
|
1594
1600
|
}
|
|
1595
1601
|
/**
|
|
1596
1602
|
* Makes an array or tuple schema mutable, removing the `readonly` modifier.
|
|
@@ -4506,7 +4512,7 @@ function causeReasonToFormatter(error, defect) {
|
|
|
4506
4512
|
*/
|
|
4507
4513
|
export function Cause(error, defect) {
|
|
4508
4514
|
const schema = declareConstructor()([error, defect], ([error, defect]) => {
|
|
4509
|
-
const failures =
|
|
4515
|
+
const failures = ArraySchema(CauseReason(error, defect));
|
|
4510
4516
|
return (input, ast, options) => {
|
|
4511
4517
|
if (!Cause_.isCause(input)) {
|
|
4512
4518
|
return Effect.fail(new Issue.InvalidType(ast, Option_.some(input)));
|
|
@@ -4526,7 +4532,7 @@ export function Cause(error, defect) {
|
|
|
4526
4532
|
importDeclaration: `import * as Cause from "effect/Cause"`
|
|
4527
4533
|
},
|
|
4528
4534
|
expected: "Cause",
|
|
4529
|
-
toCodec: ([error, defect]) => link()(
|
|
4535
|
+
toCodec: ([error, defect]) => link()(ArraySchema(CauseReason(error, defect)), Transformation.transform({
|
|
4530
4536
|
decode: Cause_.fromReasons,
|
|
4531
4537
|
encode: ({
|
|
4532
4538
|
reasons: failures
|
|
@@ -4728,7 +4734,7 @@ export function Exit(value, error, defect) {
|
|
|
4728
4734
|
*/
|
|
4729
4735
|
export function ReadonlyMap(key, value) {
|
|
4730
4736
|
const schema = declareConstructor()([key, value], ([key, value]) => {
|
|
4731
|
-
const array =
|
|
4737
|
+
const array = ArraySchema(Tuple([key, value]));
|
|
4732
4738
|
return (input, ast, options) => {
|
|
4733
4739
|
if (input instanceof globalThis.Map) {
|
|
4734
4740
|
return Effect.mapBothEager(Parser.decodeUnknownEffect(array)([...input], options), {
|
|
@@ -4747,7 +4753,7 @@ export function ReadonlyMap(key, value) {
|
|
|
4747
4753
|
Type: `globalThis.ReadonlyMap<?, ?>`
|
|
4748
4754
|
},
|
|
4749
4755
|
expected: "ReadonlyMap",
|
|
4750
|
-
toCodec: ([key, value]) => link()(
|
|
4756
|
+
toCodec: ([key, value]) => link()(ArraySchema(Tuple([key, value])), Transformation.transform({
|
|
4751
4757
|
decode: e => new globalThis.Map(e),
|
|
4752
4758
|
encode: map => [...map.entries()]
|
|
4753
4759
|
})),
|
|
@@ -4781,7 +4787,7 @@ export function ReadonlyMap(key, value) {
|
|
|
4781
4787
|
*/
|
|
4782
4788
|
export function HashMap(key, value) {
|
|
4783
4789
|
const schema = declareConstructor()([key, value], ([key, value]) => {
|
|
4784
|
-
const entries =
|
|
4790
|
+
const entries = ArraySchema(Tuple([key, value]));
|
|
4785
4791
|
return (input, ast, options) => {
|
|
4786
4792
|
if (HashMap_.isHashMap(input)) {
|
|
4787
4793
|
return Effect.mapBothEager(Parser.decodeUnknownEffect(entries)(HashMap_.toEntries(input), options), {
|
|
@@ -4801,7 +4807,7 @@ export function HashMap(key, value) {
|
|
|
4801
4807
|
importDeclaration: `import * as HashMap from "effect/HashMap"`
|
|
4802
4808
|
},
|
|
4803
4809
|
expected: "HashMap",
|
|
4804
|
-
toCodec: ([key, value]) => link()(
|
|
4810
|
+
toCodec: ([key, value]) => link()(ArraySchema(Tuple([key, value])), Transformation.transform({
|
|
4805
4811
|
decode: HashMap_.fromIterable,
|
|
4806
4812
|
encode: HashMap_.toEntries
|
|
4807
4813
|
})),
|
|
@@ -4832,7 +4838,7 @@ export function HashMap(key, value) {
|
|
|
4832
4838
|
*/
|
|
4833
4839
|
export function ReadonlySet(value) {
|
|
4834
4840
|
const schema = declareConstructor()([value], ([value]) => {
|
|
4835
|
-
const array =
|
|
4841
|
+
const array = ArraySchema(value);
|
|
4836
4842
|
return (input, ast, options) => {
|
|
4837
4843
|
if (input instanceof globalThis.Set) {
|
|
4838
4844
|
return Effect.mapBothEager(Parser.decodeUnknownEffect(array)([...input], options), {
|
|
@@ -4851,7 +4857,7 @@ export function ReadonlySet(value) {
|
|
|
4851
4857
|
Type: `globalThis.ReadonlySet<?>`
|
|
4852
4858
|
},
|
|
4853
4859
|
expected: "ReadonlySet",
|
|
4854
|
-
toCodec: ([value]) => link()(
|
|
4860
|
+
toCodec: ([value]) => link()(ArraySchema(value), Transformation.transform({
|
|
4855
4861
|
decode: e => new globalThis.Set(e),
|
|
4856
4862
|
encode: set => [...set.values()]
|
|
4857
4863
|
})),
|
|
@@ -4884,7 +4890,7 @@ export function ReadonlySet(value) {
|
|
|
4884
4890
|
*/
|
|
4885
4891
|
export function HashSet(value) {
|
|
4886
4892
|
const schema = declareConstructor()([value], ([value]) => {
|
|
4887
|
-
const values =
|
|
4893
|
+
const values = ArraySchema(value);
|
|
4888
4894
|
return (input, ast, options) => {
|
|
4889
4895
|
if (HashSet_.isHashSet(input)) {
|
|
4890
4896
|
return Effect.mapBothEager(Parser.decodeUnknownEffect(values)(Arr.fromIterable(input), options), {
|
|
@@ -4903,7 +4909,7 @@ export function HashSet(value) {
|
|
|
4903
4909
|
Type: `HashSet.HashSet<?>`
|
|
4904
4910
|
},
|
|
4905
4911
|
expected: "HashSet",
|
|
4906
|
-
toCodec: ([value]) => link()(
|
|
4912
|
+
toCodec: ([value]) => link()(ArraySchema(value), Transformation.transform({
|
|
4907
4913
|
decode: HashSet_.fromIterable,
|
|
4908
4914
|
encode: Arr.fromIterable
|
|
4909
4915
|
})),
|
|
@@ -4936,7 +4942,7 @@ export function HashSet(value) {
|
|
|
4936
4942
|
*/
|
|
4937
4943
|
export function Chunk(value) {
|
|
4938
4944
|
const schema = declareConstructor()([value], ([value]) => {
|
|
4939
|
-
const values =
|
|
4945
|
+
const values = ArraySchema(value);
|
|
4940
4946
|
return (input, ast, options) => {
|
|
4941
4947
|
if (Chunk_.isChunk(input)) {
|
|
4942
4948
|
return Effect.mapBothEager(Parser.decodeUnknownEffect(values)(Arr.fromIterable(input), options), {
|
|
@@ -4955,7 +4961,7 @@ export function Chunk(value) {
|
|
|
4955
4961
|
Type: `Chunk.Chunk<?>`
|
|
4956
4962
|
},
|
|
4957
4963
|
expected: "Chunk",
|
|
4958
|
-
toCodec: ([value]) => link()(
|
|
4964
|
+
toCodec: ([value]) => link()(ArraySchema(value), Transformation.transform({
|
|
4959
4965
|
decode: Chunk_.fromIterable,
|
|
4960
4966
|
encode: Arr.fromIterable
|
|
4961
4967
|
})),
|
|
@@ -5406,7 +5412,7 @@ export const FormData = /*#__PURE__*/instanceOf(globalThis.FormData, {
|
|
|
5406
5412
|
Type: `globalThis.FormData`
|
|
5407
5413
|
},
|
|
5408
5414
|
expected: "FormData",
|
|
5409
|
-
toCodecJson: () => link()(
|
|
5415
|
+
toCodecJson: () => link()(ArraySchema(Tuple([String, Union([Struct({
|
|
5410
5416
|
_tag: tag("String"),
|
|
5411
5417
|
value: String
|
|
5412
5418
|
}), Struct({
|
|
@@ -5696,9 +5702,9 @@ export const PropertyKey = /*#__PURE__*/Union([Finite, Symbol, String]);
|
|
|
5696
5702
|
* @since 4.0.0
|
|
5697
5703
|
*/
|
|
5698
5704
|
export const StandardSchemaV1FailureResult = /*#__PURE__*/Struct({
|
|
5699
|
-
issues: /*#__PURE__*/
|
|
5705
|
+
issues: /*#__PURE__*/ArraySchema(/*#__PURE__*/Struct({
|
|
5700
5706
|
message: String,
|
|
5701
|
-
path: /*#__PURE__*/optional(/*#__PURE__*/
|
|
5707
|
+
path: /*#__PURE__*/optional(/*#__PURE__*/ArraySchema(/*#__PURE__*/Union([PropertyKey, /*#__PURE__*/Struct({
|
|
5702
5708
|
key: PropertyKey
|
|
5703
5709
|
})])))
|
|
5704
5710
|
}))
|
|
@@ -6830,7 +6836,7 @@ export function toDifferJsonPatch(schema) {
|
|
|
6830
6836
|
*/
|
|
6831
6837
|
export function Tree(node) {
|
|
6832
6838
|
const Tree$ref = suspend(() => Tree);
|
|
6833
|
-
const Tree = Union([node,
|
|
6839
|
+
const Tree = Union([node, ArraySchema(Tree$ref), Record(String, Tree$ref)]);
|
|
6834
6840
|
return Tree;
|
|
6835
6841
|
}
|
|
6836
6842
|
/**
|