effect 4.0.0-beta.83 → 4.0.0-beta.84
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/Array.d.ts +64 -64
- package/dist/Array.js +26 -26
- package/dist/Cache.d.ts +1 -1
- package/dist/Cache.js +1 -1
- package/dist/Cause.d.ts +68 -68
- package/dist/Cause.js +47 -47
- package/dist/Channel.d.ts +5 -5
- package/dist/Channel.js +3 -3
- package/dist/Clock.d.ts +1 -1
- package/dist/Clock.js +1 -1
- package/dist/Combiner.d.ts +9 -9
- package/dist/Combiner.js +8 -8
- package/dist/Config.d.ts +15 -94
- package/dist/Config.d.ts.map +1 -1
- package/dist/Config.js +22 -70
- package/dist/Config.js.map +1 -1
- package/dist/ConfigProvider.d.ts +58 -74
- package/dist/ConfigProvider.d.ts.map +1 -1
- package/dist/ConfigProvider.js +66 -41
- package/dist/ConfigProvider.js.map +1 -1
- package/dist/Console.d.ts +1 -1
- package/dist/Console.js +1 -1
- package/dist/Data.d.ts +15 -15
- package/dist/Data.js +3 -3
- package/dist/DateTime.d.ts +6 -6
- package/dist/DateTime.js +2 -2
- package/dist/Duration.d.ts +3 -3
- package/dist/Duration.js +3 -3
- package/dist/Effect.d.ts +84 -45
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +72 -33
- package/dist/Effect.js.map +1 -1
- package/dist/Equal.d.ts +7 -7
- package/dist/Equal.js +5 -5
- package/dist/Equivalence.d.ts +17 -17
- package/dist/Equivalence.js +13 -13
- package/dist/Exit.d.ts +3 -3
- package/dist/Exit.js +3 -3
- package/dist/Formatter.d.ts +5 -5
- package/dist/Formatter.js +4 -4
- package/dist/Function.d.ts +10 -10
- package/dist/Function.js +3 -3
- package/dist/HashMap.d.ts +3 -3
- package/dist/HashMap.js +1 -1
- package/dist/Iterable.d.ts +6 -6
- package/dist/Iterable.js +2 -2
- package/dist/JsonPatch.d.ts +2 -2
- package/dist/Layer.d.ts +1 -1
- package/dist/Layer.js +1 -1
- package/dist/Logger.d.ts +1 -1
- package/dist/Logger.js +1 -1
- package/dist/Match.d.ts +8 -8
- package/dist/Match.js +8 -8
- package/dist/Metric.d.ts +3 -3
- package/dist/Metric.js +3 -3
- package/dist/Optic.d.ts +30 -30
- package/dist/Optic.js +12 -12
- package/dist/Option.d.ts +7 -7
- package/dist/Option.js +7 -7
- package/dist/Order.d.ts +23 -23
- package/dist/Order.js +20 -20
- package/dist/Pool.d.ts +1 -1
- package/dist/Pool.js +1 -1
- package/dist/Predicate.d.ts +88 -88
- package/dist/Predicate.js +47 -47
- package/dist/PubSub.d.ts +3 -3
- package/dist/PubSub.js +3 -3
- package/dist/Reducer.d.ts +1 -1
- package/dist/Reducer.js +1 -1
- package/dist/Result.d.ts +18 -18
- package/dist/Result.js +8 -8
- package/dist/Runtime.d.ts +1 -1
- package/dist/Runtime.js +1 -1
- package/dist/Schema.d.ts +265 -120
- package/dist/Schema.d.ts.map +1 -1
- package/dist/Schema.js +285 -116
- package/dist/Schema.js.map +1 -1
- package/dist/SchemaAST.d.ts +1 -1
- package/dist/SchemaAST.d.ts.map +1 -1
- package/dist/SchemaAST.js +13 -9
- package/dist/SchemaAST.js.map +1 -1
- package/dist/SchemaGetter.d.ts +48 -48
- package/dist/SchemaGetter.js +44 -44
- package/dist/SchemaIssue.d.ts +3 -3
- package/dist/SchemaIssue.js +3 -3
- package/dist/SchemaParser.d.ts +122 -22
- package/dist/SchemaParser.d.ts.map +1 -1
- package/dist/SchemaParser.js +186 -50
- package/dist/SchemaParser.js.map +1 -1
- package/dist/SchemaRepresentation.d.ts +1 -1
- package/dist/SchemaRepresentation.d.ts.map +1 -1
- package/dist/SchemaRepresentation.js +96 -2
- package/dist/SchemaRepresentation.js.map +1 -1
- package/dist/SchemaTransformation.d.ts +20 -20
- package/dist/SchemaTransformation.js +18 -18
- package/dist/Stream.d.ts +3 -3
- package/dist/Stream.js +2 -2
- package/dist/Stream.js.map +1 -1
- package/dist/String.d.ts +1 -1
- package/dist/String.js +1 -1
- package/dist/Struct.d.ts +1 -1
- package/dist/Struct.js +1 -1
- package/dist/Types.d.ts +13 -13
- package/dist/internal/effect.js +23 -10
- package/dist/internal/effect.js.map +1 -1
- package/dist/internal/schema/cause.d.ts +2 -0
- package/dist/internal/schema/cause.d.ts.map +1 -0
- package/dist/internal/schema/cause.js +24 -0
- package/dist/internal/schema/cause.js.map +1 -0
- package/dist/internal/schema/schema.d.ts +8 -4
- package/dist/internal/schema/schema.d.ts.map +1 -1
- package/dist/internal/schema/schema.js +21 -8
- package/dist/internal/schema/schema.js.map +1 -1
- package/dist/testing/TestSchema.d.ts +3 -3
- package/dist/testing/TestSchema.js +1 -1
- package/dist/unstable/ai/AiError.d.ts +1 -1
- package/dist/unstable/ai/AiError.js +1 -1
- package/dist/unstable/ai/Chat.d.ts +1 -1
- package/dist/unstable/ai/Chat.js +1 -1
- package/dist/unstable/cli/Prompt.js +2 -2
- package/dist/unstable/cli/Prompt.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiScalar.d.ts +2 -2
- package/dist/unstable/rpc/Rpc.d.ts +1 -1
- package/dist/unstable/rpc/Rpc.js +1 -1
- package/dist/unstable/rpc/RpcGroup.d.ts.map +1 -1
- package/dist/unstable/rpc/RpcGroup.js +3 -4
- package/dist/unstable/rpc/RpcGroup.js.map +1 -1
- package/dist/unstable/sql/SqlResolver.d.ts.map +1 -1
- package/dist/unstable/sql/SqlResolver.js +15 -2
- package/dist/unstable/sql/SqlResolver.js.map +1 -1
- package/dist/unstable/workflow/Activity.d.ts +1 -0
- package/dist/unstable/workflow/Activity.d.ts.map +1 -1
- package/dist/unstable/workflow/Activity.js +1 -0
- package/dist/unstable/workflow/Activity.js.map +1 -1
- package/dist/unstable/workflow/WorkflowEngine.js +1 -1
- package/dist/unstable/workflow/WorkflowEngine.js.map +1 -1
- package/package.json +1 -1
- package/src/Array.ts +65 -65
- package/src/Cache.ts +1 -1
- package/src/Cause.ts +68 -68
- package/src/Channel.ts +5 -5
- package/src/Clock.ts +1 -1
- package/src/Combiner.ts +9 -9
- package/src/Config.ts +40 -108
- package/src/ConfigProvider.ts +139 -100
- package/src/Console.ts +1 -1
- package/src/Data.ts +15 -15
- package/src/DateTime.ts +6 -6
- package/src/Duration.ts +3 -3
- package/src/Effect.ts +89 -45
- package/src/Equal.ts +7 -7
- package/src/Equivalence.ts +17 -17
- package/src/Exit.ts +3 -3
- package/src/Formatter.ts +5 -5
- package/src/Function.ts +10 -10
- package/src/HashMap.ts +3 -3
- package/src/Iterable.ts +6 -6
- package/src/JsonPatch.ts +2 -2
- package/src/Layer.ts +1 -1
- package/src/Logger.ts +1 -1
- package/src/Match.ts +8 -8
- package/src/Metric.ts +3 -3
- package/src/Optic.ts +30 -30
- package/src/Option.ts +7 -7
- package/src/Order.ts +23 -23
- package/src/Pool.ts +1 -1
- package/src/Predicate.ts +88 -88
- package/src/PubSub.ts +3 -3
- package/src/Reducer.ts +1 -1
- package/src/Result.ts +20 -20
- package/src/Runtime.ts +1 -1
- package/src/Schema.ts +314 -131
- package/src/SchemaAST.ts +20 -11
- package/src/SchemaGetter.ts +48 -48
- package/src/SchemaIssue.ts +3 -3
- package/src/SchemaParser.ts +197 -58
- package/src/SchemaRepresentation.ts +73 -3
- package/src/SchemaTransformation.ts +20 -20
- package/src/Stream.ts +4 -4
- package/src/String.ts +1 -1
- package/src/Struct.ts +1 -1
- package/src/Types.ts +13 -13
- package/src/internal/effect.ts +29 -10
- package/src/internal/schema/cause.ts +26 -0
- package/src/internal/schema/schema.ts +36 -10
- package/src/testing/TestSchema.ts +3 -3
- package/src/unstable/ai/AiError.ts +1 -1
- package/src/unstable/ai/Chat.ts +1 -1
- package/src/unstable/cli/Prompt.ts +1 -1
- package/src/unstable/httpapi/HttpApiScalar.ts +2 -2
- package/src/unstable/rpc/Rpc.ts +1 -1
- package/src/unstable/rpc/RpcGroup.ts +3 -4
- package/src/unstable/sql/SqlResolver.ts +15 -2
- package/src/unstable/workflow/Activity.ts +2 -0
- package/src/unstable/workflow/WorkflowEngine.ts +1 -1
|
@@ -447,7 +447,7 @@ export function trim(): Transformation<string, string> {
|
|
|
447
447
|
* Encoding converts values such as `"myFieldName"` back to `"my_field_name"`.
|
|
448
448
|
* The transformation is round-trippable for standard snake_case and camelCase.
|
|
449
449
|
*
|
|
450
|
-
* **Example** (
|
|
450
|
+
* **Example** (Converting snake case to camel case)
|
|
451
451
|
*
|
|
452
452
|
* ```ts
|
|
453
453
|
* import { Schema, SchemaTransformation } from "effect"
|
|
@@ -722,7 +722,7 @@ export function passthrough<T>(): Transformation<T, T> {
|
|
|
722
722
|
* Both decode and encode are no-ops and return a shared singleton
|
|
723
723
|
* transformation.
|
|
724
724
|
*
|
|
725
|
-
* **Example** (
|
|
725
|
+
* **Example** (Passing through supertypes)
|
|
726
726
|
*
|
|
727
727
|
* ```ts
|
|
728
728
|
* import { SchemaTransformation } from "effect"
|
|
@@ -755,7 +755,7 @@ export function passthroughSupertype<T>(): Transformation<T, T> {
|
|
|
755
755
|
* - Both decode and encode are no-ops (same as {@link passthrough}).
|
|
756
756
|
* - Returns a shared singleton instance.
|
|
757
757
|
*
|
|
758
|
-
* **Example** (
|
|
758
|
+
* **Example** (Passing through subtypes)
|
|
759
759
|
*
|
|
760
760
|
* ```ts
|
|
761
761
|
* import { SchemaTransformation } from "effect"
|
|
@@ -790,7 +790,7 @@ export function passthroughSubtype<T>(): Transformation<T, T> {
|
|
|
790
790
|
* result is finite; combine with `Schema.Finite` or `Schema.Int` for stricter
|
|
791
791
|
* checks.
|
|
792
792
|
*
|
|
793
|
-
* **Example** (
|
|
793
|
+
* **Example** (Converting a string to a number)
|
|
794
794
|
*
|
|
795
795
|
* ```ts
|
|
796
796
|
* import { Schema, SchemaTransformation } from "effect"
|
|
@@ -826,7 +826,7 @@ export const numberFromString = new Transformation(
|
|
|
826
826
|
* the bigint to a string like `String(n)`. Decoding fails if the string is not
|
|
827
827
|
* a valid bigint representation.
|
|
828
828
|
*
|
|
829
|
-
* **Example** (
|
|
829
|
+
* **Example** (Converting a string to a BigInt)
|
|
830
830
|
*
|
|
831
831
|
* ```ts
|
|
832
832
|
* import { Schema, SchemaTransformation } from "effect"
|
|
@@ -861,7 +861,7 @@ export const bigintFromString = new Transformation(
|
|
|
861
861
|
* converts the `Date` to an ISO string like `date.toISOString()`, returning
|
|
862
862
|
* `"Invalid Date"` for invalid dates.
|
|
863
863
|
*
|
|
864
|
-
* **Example** (
|
|
864
|
+
* **Example** (Converting a string to a Date)
|
|
865
865
|
*
|
|
866
866
|
* ```ts
|
|
867
867
|
* import { Schema, SchemaTransformation } from "effect"
|
|
@@ -898,7 +898,7 @@ export const dateFromString: Transformation<globalThis.Date, string> = new Trans
|
|
|
898
898
|
* producing strings such as `"2000 millis"` or `"10 nanos"` that round-trip
|
|
899
899
|
* through the parser.
|
|
900
900
|
*
|
|
901
|
-
* **Example** (
|
|
901
|
+
* **Example** (Converting a string to a Duration)
|
|
902
902
|
*
|
|
903
903
|
* ```ts
|
|
904
904
|
* import { Schema, SchemaTransformation } from "effect"
|
|
@@ -942,7 +942,7 @@ export const durationFromString: Transformation<Duration.Duration, string> = tra
|
|
|
942
942
|
* fails with `InvalidValue` if the `Duration` cannot be represented as a
|
|
943
943
|
* `bigint`, such as `Duration.infinity`.
|
|
944
944
|
*
|
|
945
|
-
* **Example** (
|
|
945
|
+
* **Example** (Converting nanoseconds to a Duration)
|
|
946
946
|
*
|
|
947
947
|
* ```ts
|
|
948
948
|
* import { Schema, SchemaTransformation } from "effect"
|
|
@@ -983,7 +983,7 @@ export const durationFromNanos: Transformation<Duration.Duration, bigint> = tran
|
|
|
983
983
|
* Decode creates a duration from the number, and encode returns the duration
|
|
984
984
|
* length in milliseconds.
|
|
985
985
|
*
|
|
986
|
-
* **Example** (
|
|
986
|
+
* **Example** (Converting milliseconds to a Duration)
|
|
987
987
|
*
|
|
988
988
|
* ```ts
|
|
989
989
|
* import { Schema, SchemaTransformation } from "effect"
|
|
@@ -1098,7 +1098,7 @@ export const defectFromJson = (options?: ErrorOptions) =>
|
|
|
1098
1098
|
* `Option.some(value)`. Encoding maps `Option.none()` to `null` and
|
|
1099
1099
|
* `Option.some(value)` to `value`. The transformation is pure and synchronous.
|
|
1100
1100
|
*
|
|
1101
|
-
* **Example** (
|
|
1101
|
+
* **Example** (Converting nullable values to an Option)
|
|
1102
1102
|
*
|
|
1103
1103
|
* ```ts
|
|
1104
1104
|
* import { Schema, SchemaTransformation } from "effect"
|
|
@@ -1138,7 +1138,7 @@ export function optionFromNullOr<T>(): Transformation<Option.Option<T>, T | null
|
|
|
1138
1138
|
* `Option.some(value)`. Encoding maps `Option.none()` to `undefined` and
|
|
1139
1139
|
* `Option.some(value)` to `value`. The transformation is pure and synchronous.
|
|
1140
1140
|
*
|
|
1141
|
-
* **Example** (
|
|
1141
|
+
* **Example** (Converting undefined-or values to an Option)
|
|
1142
1142
|
*
|
|
1143
1143
|
* ```ts
|
|
1144
1144
|
* import { Schema, SchemaTransformation } from "effect"
|
|
@@ -1181,7 +1181,7 @@ export function optionFromUndefinedOr<T>(): Transformation<Option.Option<T>, T |
|
|
|
1181
1181
|
* `undefined` according to `options.onNoneEncoding`, and maps
|
|
1182
1182
|
* `Option.some(value)` to `value`. The transformation is pure and synchronous.
|
|
1183
1183
|
*
|
|
1184
|
-
* **Example** (Option
|
|
1184
|
+
* **Example** (Converting nullish values to an Option and encoding None as null)
|
|
1185
1185
|
*
|
|
1186
1186
|
* ```ts
|
|
1187
1187
|
* import { Schema, SchemaTransformation } from "effect"
|
|
@@ -1227,7 +1227,7 @@ export function optionFromNullishOr<T>(
|
|
|
1227
1227
|
* the key, and maps `Some(Some(v))` to `Some(v)`. This uses
|
|
1228
1228
|
* `transformOptional` under the hood.
|
|
1229
1229
|
*
|
|
1230
|
-
* **Example** (
|
|
1230
|
+
* **Example** (Converting an optional key to an Option)
|
|
1231
1231
|
*
|
|
1232
1232
|
* ```ts
|
|
1233
1233
|
* import { Schema, SchemaTransformation } from "effect"
|
|
@@ -1272,7 +1272,7 @@ export function optionFromOptionalKey<T>(): Transformation<Option.Option<T>, T>
|
|
|
1272
1272
|
* value, and maps `Some(Some(v))` to `Some(v)`. This uses
|
|
1273
1273
|
* `transformOptional` under the hood and filters out `undefined` on decode.
|
|
1274
1274
|
*
|
|
1275
|
-
* **Example** (
|
|
1275
|
+
* **Example** (Converting an optional value to an Option)
|
|
1276
1276
|
*
|
|
1277
1277
|
* ```ts
|
|
1278
1278
|
* import { Schema, SchemaTransformation } from "effect"
|
|
@@ -1315,7 +1315,7 @@ export function optionFromOptional<T>(): Transformation<Option.Option<T>, T | un
|
|
|
1315
1315
|
* Decoding calls `new URL(s)` and fails with `InvalidValue` if the string is
|
|
1316
1316
|
* not a valid URL. Encoding returns `url.href`.
|
|
1317
1317
|
*
|
|
1318
|
-
* **Example** (
|
|
1318
|
+
* **Example** (Converting a string to a URL)
|
|
1319
1319
|
*
|
|
1320
1320
|
* ```ts
|
|
1321
1321
|
* import { Schema, SchemaTransformation } from "effect"
|
|
@@ -1385,7 +1385,7 @@ export const bigDecimalFromString: Transformation<BigDecimal.BigDecimal, string>
|
|
|
1385
1385
|
* Decoding parses the Base64 string into bytes. Encoding writes the byte array
|
|
1386
1386
|
* as a Base64 string.
|
|
1387
1387
|
*
|
|
1388
|
-
* **Example** (
|
|
1388
|
+
* **Example** (Converting Base64 to a Uint8Array)
|
|
1389
1389
|
*
|
|
1390
1390
|
* ```ts
|
|
1391
1391
|
* import { Schema, SchemaTransformation } from "effect"
|
|
@@ -1420,7 +1420,7 @@ export const uint8ArrayFromBase64String: Transformation<Uint8Array<ArrayBufferLi
|
|
|
1420
1420
|
* Decoding parses the Base64 string into a UTF-8 string. Encoding writes the
|
|
1421
1421
|
* string as a Base64 string.
|
|
1422
1422
|
*
|
|
1423
|
-
* **Example** (
|
|
1423
|
+
* **Example** (Converting Base64 to a string)
|
|
1424
1424
|
*
|
|
1425
1425
|
* ```ts
|
|
1426
1426
|
* import { Schema, SchemaTransformation } from "effect"
|
|
@@ -1454,7 +1454,7 @@ export const stringFromBase64String: Transformation<string, string> = new Transf
|
|
|
1454
1454
|
* Decoding parses the Base64 URL string into a UTF-8 string. Encoding writes
|
|
1455
1455
|
* the string as a Base64 URL string.
|
|
1456
1456
|
*
|
|
1457
|
-
* **Example** (
|
|
1457
|
+
* **Example** (Converting Base64Url to a string)
|
|
1458
1458
|
*
|
|
1459
1459
|
* ```ts
|
|
1460
1460
|
* import { Schema, SchemaTransformation } from "effect"
|
|
@@ -1488,7 +1488,7 @@ export const stringFromBase64UrlString: Transformation<string, string> = new Tra
|
|
|
1488
1488
|
* Decoding parses the hex string into a UTF-8 string. Encoding writes the
|
|
1489
1489
|
* string as a hex string.
|
|
1490
1490
|
*
|
|
1491
|
-
* **Example** (
|
|
1491
|
+
* **Example** (Converting hex to a string)
|
|
1492
1492
|
*
|
|
1493
1493
|
* ```ts
|
|
1494
1494
|
* import { Schema, SchemaTransformation } from "effect"
|
|
@@ -1524,7 +1524,7 @@ export const stringFromHexString: Transformation<string, string> = new Transform
|
|
|
1524
1524
|
* Decoding calls `decodeURIComponent` and fails if the input contains malformed
|
|
1525
1525
|
* percent-encoding sequences. Encoding calls `encodeURIComponent`.
|
|
1526
1526
|
*
|
|
1527
|
-
* **Example** (URI component schema)
|
|
1527
|
+
* **Example** (Defining a URI component schema)
|
|
1528
1528
|
*
|
|
1529
1529
|
* ```ts
|
|
1530
1530
|
* import { Schema, SchemaTransformation } from "effect"
|
package/src/Stream.ts
CHANGED
|
@@ -2905,7 +2905,7 @@ export const tapSink: {
|
|
|
2905
2905
|
* multiple inner streams may run at the same time and their outputs are merged
|
|
2906
2906
|
* as they arrive.
|
|
2907
2907
|
*
|
|
2908
|
-
* **Example** (
|
|
2908
|
+
* **Example** (Flat mapping stream values)
|
|
2909
2909
|
*
|
|
2910
2910
|
* ```ts
|
|
2911
2911
|
* import { Console, Effect, Stream } from "effect"
|
|
@@ -2936,7 +2936,7 @@ export const flatMap: {
|
|
|
2936
2936
|
* multiple inner streams may run at the same time and their outputs are merged
|
|
2937
2937
|
* as they arrive.
|
|
2938
2938
|
*
|
|
2939
|
-
* **Example** (
|
|
2939
|
+
* **Example** (Flat mapping stream values)
|
|
2940
2940
|
*
|
|
2941
2941
|
* ```ts
|
|
2942
2942
|
* import { Console, Effect, Stream } from "effect"
|
|
@@ -2973,7 +2973,7 @@ export const flatMap: {
|
|
|
2973
2973
|
* multiple inner streams may run at the same time and their outputs are merged
|
|
2974
2974
|
* as they arrive.
|
|
2975
2975
|
*
|
|
2976
|
-
* **Example** (
|
|
2976
|
+
* **Example** (Flat mapping stream values)
|
|
2977
2977
|
*
|
|
2978
2978
|
* ```ts
|
|
2979
2979
|
* import { Console, Effect, Stream } from "effect"
|
|
@@ -19522,7 +19522,7 @@ export const runForEachWhile: {
|
|
|
19522
19522
|
if (!b) done = true
|
|
19523
19523
|
}
|
|
19524
19524
|
}),
|
|
19525
|
-
() => done
|
|
19525
|
+
() => !done
|
|
19526
19526
|
)
|
|
19527
19527
|
}))
|
|
19528
19528
|
|
package/src/String.ts
CHANGED
|
@@ -102,7 +102,7 @@ export const Equivalence: Equ.Equivalence<string> = Equ.String
|
|
|
102
102
|
*
|
|
103
103
|
* Use when you need the canonical empty string value from the `String` module.
|
|
104
104
|
*
|
|
105
|
-
* **Example** (
|
|
105
|
+
* **Example** (Referencing the empty string)
|
|
106
106
|
*
|
|
107
107
|
* ```ts
|
|
108
108
|
* import { String } from "effect"
|
package/src/Struct.ts
CHANGED
package/src/Types.ts
CHANGED
|
@@ -31,7 +31,7 @@ type TupleOf_<T, N extends number, R extends Array<unknown>> = `${N}` extends `-
|
|
|
31
31
|
* - If `N` is the general `number` type (non-literal), degrades to `Array<T>`.
|
|
32
32
|
* - Negative numbers produce `never`.
|
|
33
33
|
*
|
|
34
|
-
* **Example** (
|
|
34
|
+
* **Example** (Checking fixed-length tuples)
|
|
35
35
|
*
|
|
36
36
|
* ```ts
|
|
37
37
|
* import type { Types } from "effect"
|
|
@@ -66,7 +66,7 @@ export type TupleOf<N extends number, T> = N extends N ? number extends N ? Arra
|
|
|
66
66
|
*
|
|
67
67
|
* Produces a tuple with `N` fixed positions followed by `...Array<T>`.
|
|
68
68
|
*
|
|
69
|
-
* **Example** (
|
|
69
|
+
* **Example** (Checking minimum-length tuples)
|
|
70
70
|
*
|
|
71
71
|
* ```ts
|
|
72
72
|
* import type { Types } from "effect"
|
|
@@ -201,7 +201,7 @@ export type ExtractTag<E, K extends string> = E extends { readonly _tag: infer T
|
|
|
201
201
|
* - If the union members are incompatible (e.g. `string | number`), the
|
|
202
202
|
* result is `never`.
|
|
203
203
|
*
|
|
204
|
-
* **Example** (
|
|
204
|
+
* **Example** (Converting a union to an intersection)
|
|
205
205
|
*
|
|
206
206
|
* ```ts
|
|
207
207
|
* import type { Types } from "effect"
|
|
@@ -264,7 +264,7 @@ export type Simplify<A> = {
|
|
|
264
264
|
* distinguishing between `any`, `unknown`, `never`, and other types.
|
|
265
265
|
* - Resolves to `true` if `X` and `Y` are identical, `false` otherwise.
|
|
266
266
|
*
|
|
267
|
-
* **Example** (
|
|
267
|
+
* **Example** (Checking type equality)
|
|
268
268
|
*
|
|
269
269
|
* ```ts
|
|
270
270
|
* import type { Types } from "effect"
|
|
@@ -295,7 +295,7 @@ export type Equals<X, Y> = (<T>() => T extends X ? 1 : 2) extends <
|
|
|
295
295
|
*
|
|
296
296
|
* Returns `Y` when `A` and `B` are equal, `N` otherwise.
|
|
297
297
|
*
|
|
298
|
-
* **Example** (
|
|
298
|
+
* **Example** (Choosing a conditional type based on equality)
|
|
299
299
|
*
|
|
300
300
|
* ```ts
|
|
301
301
|
* import type { Types } from "effect"
|
|
@@ -324,7 +324,7 @@ export type EqualsWith<A, B, Y, N> = (<T>() => T extends A ? 1 : 2) extends (<T>
|
|
|
324
324
|
* Returns `true` if at least one key from `Key` exists in `A`, `false`
|
|
325
325
|
* otherwise.
|
|
326
326
|
*
|
|
327
|
-
* **Example** (
|
|
327
|
+
* **Example** (Checking key presence)
|
|
328
328
|
*
|
|
329
329
|
* ```ts
|
|
330
330
|
* import type { Types } from "effect"
|
|
@@ -352,7 +352,7 @@ export type Has<A, Key extends string> = (Key extends infer K ? K extends keyof
|
|
|
352
352
|
*
|
|
353
353
|
* Implemented as `MergeRight<Target, Source>`.
|
|
354
354
|
*
|
|
355
|
-
* **Example** (
|
|
355
|
+
* **Example** (Merging with left bias)
|
|
356
356
|
*
|
|
357
357
|
* ```ts
|
|
358
358
|
* import type { Types } from "effect"
|
|
@@ -423,7 +423,7 @@ export type MergeRight<Target, Source> = Simplify<
|
|
|
423
423
|
* - `"unbounded"` — run all effects concurrently with no limit.
|
|
424
424
|
* - `"inherit"` — inherit the concurrency from the surrounding context.
|
|
425
425
|
*
|
|
426
|
-
* **Example** (
|
|
426
|
+
* **Example** (Setting concurrency values)
|
|
427
427
|
*
|
|
428
428
|
* ```ts
|
|
429
429
|
* import type { Types } from "effect"
|
|
@@ -451,7 +451,7 @@ export type Concurrency = number | "unbounded" | "inherit"
|
|
|
451
451
|
*
|
|
452
452
|
* Only affects the top level; nested properties remain readonly.
|
|
453
453
|
*
|
|
454
|
-
* **Example** (
|
|
454
|
+
* **Example** (Converting shallowly to mutable types)
|
|
455
455
|
*
|
|
456
456
|
* ```ts
|
|
457
457
|
* import type { Types } from "effect"
|
|
@@ -492,7 +492,7 @@ export type Mutable<T> = {
|
|
|
492
492
|
* Recursion stops at primitives (`string`, `number`, `boolean`, `bigint`,
|
|
493
493
|
* `symbol`) and functions.
|
|
494
494
|
*
|
|
495
|
-
* **Example** (
|
|
495
|
+
* **Example** (Converting deeply to mutable types)
|
|
496
496
|
*
|
|
497
497
|
* ```ts
|
|
498
498
|
* import type { Types } from "effect"
|
|
@@ -557,7 +557,7 @@ export type NoInfer<A> = [A][A extends any ? 0 : never]
|
|
|
557
557
|
* A value of type `Invariant<A>` cannot be assigned to `Invariant<B>` unless
|
|
558
558
|
* `A` and `B` are the same type.
|
|
559
559
|
*
|
|
560
|
-
* **Example** (
|
|
560
|
+
* **Example** (Defining an invariant phantom type)
|
|
561
561
|
*
|
|
562
562
|
* ```ts
|
|
563
563
|
* import type { Types } from "effect"
|
|
@@ -625,7 +625,7 @@ export declare namespace Invariant {
|
|
|
625
625
|
* `Covariant<A>` is assignable to `Covariant<B>` when `A extends B`, following
|
|
626
626
|
* the subtype direction.
|
|
627
627
|
*
|
|
628
|
-
* **Example** (
|
|
628
|
+
* **Example** (Defining a covariant phantom type)
|
|
629
629
|
*
|
|
630
630
|
* ```ts
|
|
631
631
|
* import type { Types } from "effect"
|
|
@@ -693,7 +693,7 @@ export declare namespace Covariant {
|
|
|
693
693
|
* `Contravariant<A>` is assignable to `Contravariant<B>` when `B extends A`,
|
|
694
694
|
* following the supertype direction.
|
|
695
695
|
*
|
|
696
|
-
* **Example** (
|
|
696
|
+
* **Example** (Defining a contravariant phantom type)
|
|
697
697
|
*
|
|
698
698
|
* ```ts
|
|
699
699
|
* import type { Types } from "effect"
|
package/src/internal/effect.ts
CHANGED
|
@@ -933,6 +933,11 @@ export const succeedNone: Effect.Effect<Option.Option<never>> = succeed(
|
|
|
933
933
|
Option.none()
|
|
934
934
|
)
|
|
935
935
|
|
|
936
|
+
/** @internal */
|
|
937
|
+
export const transposeOption = <A = never, E = never, R = never>(
|
|
938
|
+
self: Option.Option<Effect.Effect<A, E, R>>
|
|
939
|
+
): Effect.Effect<Option.Option<A>, E, R> => Option.isNone(self) ? succeedNone : map(self.value, Option.some)
|
|
940
|
+
|
|
936
941
|
/** @internal */
|
|
937
942
|
export const failCauseSync = <E>(
|
|
938
943
|
evaluate: LazyArg<Cause.Cause<E>>
|
|
@@ -950,17 +955,24 @@ const void_: Effect.Effect<void> = succeed(void 0)
|
|
|
950
955
|
export { void_ as void }
|
|
951
956
|
|
|
952
957
|
/** @internal */
|
|
953
|
-
const try_ = <A, E>(
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
+
const try_ = <A, E = Cause.UnknownError>(
|
|
959
|
+
options: {
|
|
960
|
+
readonly try: LazyArg<A>
|
|
961
|
+
readonly catch: (error: unknown) => E
|
|
962
|
+
} | LazyArg<A>
|
|
963
|
+
): Effect.Effect<A, E> => {
|
|
964
|
+
const evaluate = typeof options === "function" ? options : options.try
|
|
965
|
+
const catcher = typeof options === "function"
|
|
966
|
+
? ((cause: unknown) => new UnknownError(cause, "An error occurred in Effect.try"))
|
|
967
|
+
: options.catch
|
|
968
|
+
return suspend(() => {
|
|
958
969
|
try {
|
|
959
|
-
return succeed(internalCall(
|
|
970
|
+
return succeed(internalCall(evaluate))
|
|
960
971
|
} catch (err) {
|
|
961
|
-
return fail(internalCall(() =>
|
|
972
|
+
return fail(internalCall(() => catcher(err)) as E)
|
|
962
973
|
}
|
|
963
974
|
})
|
|
975
|
+
}
|
|
964
976
|
/** @internal */
|
|
965
977
|
export { try_ as try }
|
|
966
978
|
|
|
@@ -987,15 +999,22 @@ export const tryPromise = <A, E = Cause.UnknownError>(
|
|
|
987
999
|
? ((cause: unknown) => new UnknownError(cause, "An error occurred in Effect.tryPromise"))
|
|
988
1000
|
: options.catch
|
|
989
1001
|
return callbackOptions<A, E>(function(resume, signal) {
|
|
1002
|
+
const failWithCatch = (cause: unknown) => {
|
|
1003
|
+
try {
|
|
1004
|
+
resume(fail(internalCall(() => catcher(cause)) as E))
|
|
1005
|
+
} catch (err) {
|
|
1006
|
+
resume(die(err))
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
990
1009
|
try {
|
|
991
1010
|
internalCall(() => f(signal!)).then(
|
|
992
1011
|
(a) => resume(succeed(a)),
|
|
993
|
-
|
|
1012
|
+
failWithCatch
|
|
994
1013
|
)
|
|
995
1014
|
} catch (err) {
|
|
996
|
-
|
|
1015
|
+
failWithCatch(err)
|
|
997
1016
|
}
|
|
998
|
-
},
|
|
1017
|
+
}, f.length !== 0)
|
|
999
1018
|
}
|
|
1000
1019
|
|
|
1001
1020
|
/** @internal */
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import * as Cause from "../../Cause.ts"
|
|
2
|
+
import * as SchemaIssue from "../../SchemaIssue.ts"
|
|
3
|
+
|
|
4
|
+
/** @internal */
|
|
5
|
+
export function getSchemaIssue(cause: Cause.Cause<SchemaIssue.Issue>): SchemaIssue.Issue | undefined {
|
|
6
|
+
let issue: SchemaIssue.Issue | undefined
|
|
7
|
+
for (const reason of cause.reasons) {
|
|
8
|
+
if (!Cause.isFailReason(reason) || !SchemaIssue.isIssue(reason.error)) {
|
|
9
|
+
return undefined
|
|
10
|
+
}
|
|
11
|
+
issue ??= reason.error
|
|
12
|
+
}
|
|
13
|
+
return issue
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/** @internal */
|
|
17
|
+
export function getSchemaIssueOrThrow(
|
|
18
|
+
cause: Cause.Cause<SchemaIssue.Issue>,
|
|
19
|
+
message: string
|
|
20
|
+
): SchemaIssue.Issue {
|
|
21
|
+
const issue = getSchemaIssue(cause)
|
|
22
|
+
if (issue === undefined) {
|
|
23
|
+
throw new Error(message, { cause })
|
|
24
|
+
}
|
|
25
|
+
return issue
|
|
26
|
+
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import * as Cause from "../../Cause.ts"
|
|
2
|
+
import * as Data from "../../Data.ts"
|
|
1
3
|
import * as Effect from "../../Effect.ts"
|
|
2
|
-
import
|
|
4
|
+
import * as Exit from "../../Exit.ts"
|
|
3
5
|
import * as Pipeable from "../../Pipeable.ts"
|
|
4
6
|
import type * as Schema from "../../Schema.ts"
|
|
5
7
|
import * as SchemaAST from "../../SchemaAST.ts"
|
|
@@ -33,7 +35,8 @@ export function make<S extends Schema.Top>(ast: S["ast"], options?: object): S {
|
|
|
33
35
|
}
|
|
34
36
|
self.ast = ast
|
|
35
37
|
self.rebuild = (ast: SchemaAST.AST) => make(ast, options)
|
|
36
|
-
self.makeEffect =
|
|
38
|
+
self.makeEffect = (input: S["~type.make.in"], options?: Schema.MakeOptions) =>
|
|
39
|
+
mapSchemaIssueEffect(SchemaParser.makeEffect(self)(input, options))
|
|
37
40
|
self.make = SchemaParser.make(self)
|
|
38
41
|
self.makeOption = SchemaParser.makeOption(self)
|
|
39
42
|
return self
|
|
@@ -42,23 +45,46 @@ export function make<S extends Schema.Top>(ast: S["ast"], options?: object): S {
|
|
|
42
45
|
/** @internal */
|
|
43
46
|
export const SchemaErrorTypeId = "~effect/Schema/SchemaError"
|
|
44
47
|
|
|
45
|
-
// not internal
|
|
46
|
-
export class SchemaError {
|
|
47
|
-
readonly [SchemaErrorTypeId] = SchemaErrorTypeId
|
|
48
|
-
readonly _tag = "SchemaError"
|
|
49
|
-
readonly name: string = "SchemaError"
|
|
48
|
+
// purposefully not internal
|
|
49
|
+
export class SchemaError extends Data.TaggedError("SchemaError")<{
|
|
50
50
|
readonly issue: Issue
|
|
51
|
+
}> {
|
|
52
|
+
readonly [SchemaErrorTypeId]: typeof SchemaErrorTypeId = SchemaErrorTypeId
|
|
51
53
|
constructor(issue: Issue) {
|
|
52
|
-
|
|
54
|
+
super({ issue })
|
|
53
55
|
}
|
|
54
|
-
get message() {
|
|
56
|
+
override get message() {
|
|
55
57
|
return this.issue.toString()
|
|
56
58
|
}
|
|
57
|
-
toString() {
|
|
59
|
+
override toString() {
|
|
58
60
|
return `SchemaError(${this.message})`
|
|
59
61
|
}
|
|
60
62
|
}
|
|
61
63
|
|
|
64
|
+
/** @internal */
|
|
65
|
+
export function mapSchemaIssueEffect<A, R>(
|
|
66
|
+
self: Effect.Effect<A, Issue, R>
|
|
67
|
+
): Effect.Effect<A, SchemaError, R> {
|
|
68
|
+
return Effect.catchCause(
|
|
69
|
+
self,
|
|
70
|
+
(cause) => Effect.failCauseSync(() => Cause.map(cause, (issue) => new SchemaError(issue)))
|
|
71
|
+
)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** @internal */
|
|
75
|
+
export function mapSchemaErrorEffect<A, R>(
|
|
76
|
+
self: Effect.Effect<A, SchemaError, R>
|
|
77
|
+
): Effect.Effect<A, Issue, R> {
|
|
78
|
+
return Effect.catchCause(self, (cause) => Effect.failCauseSync(() => Cause.map(cause, (error) => error.issue)))
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** @internal */
|
|
82
|
+
export function mapSchemaIssueExit<A>(exit: Exit.Exit<A, Issue>): Exit.Exit<A, SchemaError> {
|
|
83
|
+
return Exit.isSuccess(exit)
|
|
84
|
+
? Exit.succeed(exit.value)
|
|
85
|
+
: Exit.failCause(Cause.map(exit.cause, (issue) => new SchemaError(issue)))
|
|
86
|
+
}
|
|
87
|
+
|
|
62
88
|
/** @internal */
|
|
63
89
|
export const jsonReorder = makeReorder(getJsonPriority)
|
|
64
90
|
|
|
@@ -154,7 +154,7 @@ export class Asserts<S extends Schema.Top> {
|
|
|
154
154
|
*
|
|
155
155
|
* FastCheck generates arbitrary values matching the schema's `Type`. The assertion fails if any generated value does not round-trip. Pass `options.params` to control FastCheck parameters such as `numRuns`.
|
|
156
156
|
*
|
|
157
|
-
* **Example** (
|
|
157
|
+
* **Example** (Verifying round trips)
|
|
158
158
|
*
|
|
159
159
|
* ```ts
|
|
160
160
|
* import { Schema } from "effect"
|
|
@@ -338,7 +338,7 @@ export class Decoding<S extends Schema.Top> {
|
|
|
338
338
|
*
|
|
339
339
|
* Use to verify successful decoding for one input case.
|
|
340
340
|
*
|
|
341
|
-
* **Example** (
|
|
341
|
+
* **Example** (Testing identity and transformed decoding)
|
|
342
342
|
*
|
|
343
343
|
* ```ts
|
|
344
344
|
* import { Schema } from "effect"
|
|
@@ -478,7 +478,7 @@ export class Encoding<S extends Schema.Top> {
|
|
|
478
478
|
*
|
|
479
479
|
* Use to verify successful encoding for one input case.
|
|
480
480
|
*
|
|
481
|
-
* **Example** (
|
|
481
|
+
* **Example** (Testing identity and transformed encoding)
|
|
482
482
|
*
|
|
483
483
|
* ```ts
|
|
484
484
|
* import { Schema } from "effect"
|
|
@@ -181,7 +181,7 @@ export class NetworkError extends Schema.ErrorClass<NetworkError>(
|
|
|
181
181
|
* Provider-specific metadata is namespaced by provider name. Each provider
|
|
182
182
|
* value can contain arbitrary mutable JSON metadata or `null`.
|
|
183
183
|
*
|
|
184
|
-
* **Example** (
|
|
184
|
+
* **Example** (Inspecting metadata shape)
|
|
185
185
|
*
|
|
186
186
|
* ```ts
|
|
187
187
|
* const metadata = {
|
package/src/unstable/ai/Chat.ts
CHANGED
|
@@ -46,7 +46,7 @@ import type * as Tool from "./Tool.ts"
|
|
|
46
46
|
* enabling persistent conversational AI interactions with full context
|
|
47
47
|
* management.
|
|
48
48
|
*
|
|
49
|
-
* **Example** (
|
|
49
|
+
* **Example** (Accessing the Chat service)
|
|
50
50
|
*
|
|
51
51
|
* ```ts
|
|
52
52
|
* import { Effect } from "effect"
|
|
@@ -1422,7 +1422,7 @@ const runLoop = Effect.fnUntraced(
|
|
|
1422
1422
|
yield* Effect.orDie(terminal.display(msg))
|
|
1423
1423
|
if (loop.events) {
|
|
1424
1424
|
const takeInput = Queue.take(input).pipe(
|
|
1425
|
-
Effect.map((
|
|
1425
|
+
Effect.map((input) => ({ _tag: "Input" as const, input }))
|
|
1426
1426
|
)
|
|
1427
1427
|
const result = yield* Effect.raceFirst(
|
|
1428
1428
|
takeInput,
|
|
@@ -87,7 +87,7 @@ export type ScalarConfig = {
|
|
|
87
87
|
/**
|
|
88
88
|
* Path to a favicon image.
|
|
89
89
|
*
|
|
90
|
-
* **Example** (
|
|
90
|
+
* **Example** (Setting a relative favicon)
|
|
91
91
|
*
|
|
92
92
|
* ```ts
|
|
93
93
|
* const favicon = "/favicon.svg"
|
|
@@ -107,7 +107,7 @@ export type ScalarConfig = {
|
|
|
107
107
|
* Browsers can derive the origin from `window.location.origin`; server
|
|
108
108
|
* rendering needs this value supplied explicitly.
|
|
109
109
|
*
|
|
110
|
-
* **Example** (
|
|
110
|
+
* **Example** (Setting a local server URL)
|
|
111
111
|
*
|
|
112
112
|
* ```ts
|
|
113
113
|
* const baseServerURL = "http://localhost:3000"
|
package/src/unstable/rpc/Rpc.ts
CHANGED
|
@@ -955,7 +955,7 @@ export const make = <
|
|
|
955
955
|
/**
|
|
956
956
|
* Creates a custom `Rpc` constructor that can transform the output schemas.
|
|
957
957
|
*
|
|
958
|
-
* **Example** (
|
|
958
|
+
* **Example** (Defining a paginated RPC constructor)
|
|
959
959
|
*
|
|
960
960
|
* ```ts
|
|
961
961
|
* import { Schema } from "effect"
|
|
@@ -303,14 +303,13 @@ const RpcGroupProto = {
|
|
|
303
303
|
const services = yield* Effect.context<never>()
|
|
304
304
|
const handlers = Effect.isEffect(build) ? yield* build : build
|
|
305
305
|
const contextMap = new Map<string, unknown>()
|
|
306
|
-
|
|
307
|
-
const rpc = self.requests.get(tag)!
|
|
306
|
+
self.requests.forEach((rpc, tag) => {
|
|
308
307
|
contextMap.set(rpc.key, {
|
|
309
308
|
tag: rpc._tag,
|
|
310
|
-
handler,
|
|
309
|
+
handler: handlers[tag],
|
|
311
310
|
context: services
|
|
312
311
|
})
|
|
313
|
-
}
|
|
312
|
+
})
|
|
314
313
|
return Context.makeUnsafe(contextMap)
|
|
315
314
|
})
|
|
316
315
|
},
|
|
@@ -17,6 +17,7 @@ import * as Equal from "../../Equal.ts"
|
|
|
17
17
|
import * as Exit from "../../Exit.ts"
|
|
18
18
|
import * as Hash from "../../Hash.ts"
|
|
19
19
|
import * as MutableHashMap from "../../MutableHashMap.ts"
|
|
20
|
+
import * as Option from "../../Option.ts"
|
|
20
21
|
import * as Request from "../../Request.ts"
|
|
21
22
|
import * as RequestResolver from "../../RequestResolver.ts"
|
|
22
23
|
import * as Schema from "../../Schema.ts"
|
|
@@ -376,8 +377,20 @@ const partitionRequestsById = function*<In, A, E, R, InE>(
|
|
|
376
377
|
|
|
377
378
|
for (let i = 0; i < len; i++) {
|
|
378
379
|
entry = requests[i]
|
|
379
|
-
|
|
380
|
-
|
|
380
|
+
const existing = MutableHashMap.get(byIdMap, entry.request.payload)
|
|
381
|
+
if (Option.isSome(existing)) {
|
|
382
|
+
const duplicate = entry
|
|
383
|
+
MutableHashMap.set(byIdMap, entry.request.payload, {
|
|
384
|
+
...existing.value,
|
|
385
|
+
completeUnsafe(exit) {
|
|
386
|
+
existing.value.completeUnsafe(exit)
|
|
387
|
+
duplicate.completeUnsafe(exit)
|
|
388
|
+
}
|
|
389
|
+
})
|
|
390
|
+
} else {
|
|
391
|
+
yield (Effect.provideContext(handle(encode(entry.request.payload)), entry.context) as Effect.Effect<void>)
|
|
392
|
+
MutableHashMap.set(byIdMap, entry.request.payload, entry)
|
|
393
|
+
}
|
|
381
394
|
}
|
|
382
395
|
|
|
383
396
|
return [inputs, byIdMap] as const
|
|
@@ -49,6 +49,7 @@ export interface Activity<
|
|
|
49
49
|
readonly successSchema: Success
|
|
50
50
|
readonly errorSchema: Error
|
|
51
51
|
readonly exitSchema: Schema.Exit<Success, Error, Schema.Defect>
|
|
52
|
+
readonly exitSchemaPartial: Schema.Exit<Success, Error, Schema.Unknown>
|
|
52
53
|
readonly annotations: Context.Context<never>
|
|
53
54
|
annotate<I, S>(
|
|
54
55
|
key: Context.Key<I, S>,
|
|
@@ -153,6 +154,7 @@ export const make = <
|
|
|
153
154
|
successSchema,
|
|
154
155
|
errorSchema,
|
|
155
156
|
exitSchema: Schema.Exit(successSchemaJson, errorSchemaJson, Schema.Defect()),
|
|
157
|
+
exitSchemaPartial: Schema.Exit(successSchemaJson, errorSchemaJson, Schema.Unknown),
|
|
156
158
|
annotations: options.annotations ?? Context.empty(),
|
|
157
159
|
annotate(tag: Context.Key<any, any>, value: any) {
|
|
158
160
|
return make({
|