effect 4.0.0-beta.26 → 4.0.0-beta.27
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/Cause.d.ts +1 -1
- package/dist/Data.d.ts +2 -2
- package/dist/Data.js +2 -2
- package/dist/Effect.d.ts +31 -22
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js +14 -11
- package/dist/Effect.js.map +1 -1
- package/dist/ErrorReporter.d.ts +2 -4
- package/dist/ErrorReporter.d.ts.map +1 -1
- package/dist/ErrorReporter.js +1 -3
- package/dist/ErrorReporter.js.map +1 -1
- package/dist/Layer.d.ts +112 -117
- package/dist/Layer.d.ts.map +1 -1
- package/dist/Layer.js +43 -44
- package/dist/Layer.js.map +1 -1
- package/dist/LayerMap.d.ts +4 -4
- package/dist/LayerMap.js +3 -3
- package/dist/ManagedRuntime.d.ts +1 -1
- package/dist/ManagedRuntime.js +1 -1
- package/dist/Metric.d.ts +2 -4
- package/dist/Metric.d.ts.map +1 -1
- package/dist/Metric.js +2 -4
- package/dist/Metric.js.map +1 -1
- package/dist/Schedule.d.ts +36 -36
- package/dist/Schedule.js +14 -14
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/unstable/cli/CliError.d.ts +4 -4
- package/dist/unstable/cli/CliError.js +4 -4
- package/dist/unstable/cli/Primitive.d.ts +1 -1
- package/dist/unstable/cli/Primitive.js +1 -1
- package/dist/unstable/http/Headers.d.ts +16 -0
- package/dist/unstable/http/Headers.d.ts.map +1 -1
- package/dist/unstable/http/Headers.js +11 -0
- package/dist/unstable/http/Headers.js.map +1 -1
- package/dist/unstable/httpapi/HttpApiBuilder.js +5 -0
- package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
- package/dist/unstable/schema/Model.d.ts +21 -0
- package/dist/unstable/schema/Model.d.ts.map +1 -1
- package/dist/unstable/schema/Model.js +15 -0
- package/dist/unstable/schema/Model.js.map +1 -1
- package/package.json +1 -1
- package/src/Cause.ts +1 -1
- package/src/Data.ts +2 -2
- package/src/Effect.ts +31 -22
- package/src/ErrorReporter.ts +2 -4
- package/src/Layer.ts +112 -117
- package/src/LayerMap.ts +4 -4
- package/src/ManagedRuntime.ts +1 -1
- package/src/Metric.ts +2 -4
- package/src/Schedule.ts +36 -36
- package/src/index.ts +1 -1
- package/src/unstable/cli/CliError.ts +4 -4
- package/src/unstable/cli/Primitive.ts +1 -1
- package/src/unstable/http/Headers.ts +34 -0
- package/src/unstable/httpapi/HttpApiBuilder.ts +3 -0
- package/src/unstable/schema/Model.ts +31 -0
package/src/LayerMap.ts
CHANGED
|
@@ -27,7 +27,7 @@ const TypeId = "~effect/LayerMap"
|
|
|
27
27
|
* // Create a LayerMap that provides different database configurations
|
|
28
28
|
* const createDatabaseLayerMap = LayerMap.make((env: string) =>
|
|
29
29
|
* Layer.succeed(DatabaseService)({
|
|
30
|
-
* query: (sql) => Effect.succeed(`${env}: ${sql}`)
|
|
30
|
+
* query: Effect.fn("DatabaseService.query")((sql) => Effect.succeed(`${env}: ${sql}`))
|
|
31
31
|
* })
|
|
32
32
|
* )
|
|
33
33
|
*
|
|
@@ -91,7 +91,7 @@ export interface LayerMap<in out K, in out I, in out E = never> {
|
|
|
91
91
|
* const layerMap = yield* LayerMap.make(
|
|
92
92
|
* (env: string) =>
|
|
93
93
|
* Layer.succeed(DatabaseService)({
|
|
94
|
-
* query: (sql) => Effect.succeed(`${env}: ${sql}`)
|
|
94
|
+
* query: Effect.fn("DatabaseService.query")((sql) => Effect.succeed(`${env}: ${sql}`))
|
|
95
95
|
* }),
|
|
96
96
|
* { idleTimeToLive: "5 seconds" }
|
|
97
97
|
* )
|
|
@@ -171,10 +171,10 @@ export const make: <
|
|
|
171
171
|
* // Create predefined layers
|
|
172
172
|
* const layers = {
|
|
173
173
|
* development: Layer.succeed(DevDatabase)({
|
|
174
|
-
* query: (sql) => Effect.succeed(`DEV: ${sql}`)
|
|
174
|
+
* query: Effect.fn("DevDatabase.query")((sql) => Effect.succeed(`DEV: ${sql}`))
|
|
175
175
|
* }),
|
|
176
176
|
* production: Layer.succeed(ProdDatabase)({
|
|
177
|
-
* query: (sql) => Effect.succeed(`PROD: ${sql}`)
|
|
177
|
+
* query: Effect.fn("ProdDatabase.query")((sql) => Effect.succeed(`PROD: ${sql}`))
|
|
178
178
|
* })
|
|
179
179
|
* } as const
|
|
180
180
|
*
|
package/src/ManagedRuntime.ts
CHANGED
|
@@ -141,7 +141,7 @@ export interface ManagedRuntime<in R, out ER> {
|
|
|
141
141
|
* readonly notify: (message: string) => Effect.Effect<void>
|
|
142
142
|
* }>()("Notifications") {
|
|
143
143
|
* static readonly layer = Layer.succeed(this)({
|
|
144
|
-
* notify: (message) => Console.log(message)
|
|
144
|
+
* notify: Effect.fn("Notifications.notify")((message) => Console.log(message))
|
|
145
145
|
* })
|
|
146
146
|
* }
|
|
147
147
|
*
|
package/src/Metric.ts
CHANGED
|
@@ -4801,7 +4801,7 @@ export const FiberRuntimeMetricsImpl: FiberRuntimeMetricsService = {
|
|
|
4801
4801
|
* Effect.gen(function*() {
|
|
4802
4802
|
* yield* Effect.sleep(`${50 + id * 10} millis`)
|
|
4803
4803
|
* if (id % 7 === 0) {
|
|
4804
|
-
* yield*
|
|
4804
|
+
* return yield* new AppError({ operation: `fetch-user-${id}` })
|
|
4805
4805
|
* }
|
|
4806
4806
|
* return { id, name: `User ${id}`, email: `user${id}@example.com` }
|
|
4807
4807
|
* })
|
|
@@ -4940,9 +4940,7 @@ export const disableRuntimeMetricsLayer = Layer.succeed(FiberRuntimeMetrics)(und
|
|
|
4940
4940
|
* yield* Effect.sleep(`${100 + i * 50} millis`)
|
|
4941
4941
|
* if (i % 4 === 0) {
|
|
4942
4942
|
* // Simulate some failures
|
|
4943
|
-
* yield*
|
|
4944
|
-
* new RuntimeMetricsError({ operation: `task-${i}` })
|
|
4945
|
-
* )
|
|
4943
|
+
* return yield* new RuntimeMetricsError({ operation: `task-${i}` })
|
|
4946
4944
|
* }
|
|
4947
4945
|
* return `Task ${i} completed`
|
|
4948
4946
|
* }).pipe(
|
package/src/Schedule.ts
CHANGED
|
@@ -72,7 +72,7 @@ const randomNext: Effect<number> = random.Random.useSync((random) => random.next
|
|
|
72
72
|
* const program = Effect.gen(function*() {
|
|
73
73
|
* // Using retry schedule
|
|
74
74
|
* const result1 = yield* Effect.retry(
|
|
75
|
-
* Effect.fail("temporary error"),
|
|
75
|
+
* Effect.suspend(() => Math.random() > 0.5 ? Effect.fail("temporary error") : Effect.succeed("Success")),
|
|
76
76
|
* retrySchedule
|
|
77
77
|
* )
|
|
78
78
|
*
|
|
@@ -200,7 +200,7 @@ export const CurrentMetadata = ServiceMap.Reference<Metadata>("effect/Schedule/C
|
|
|
200
200
|
* Effect.gen(function*() {
|
|
201
201
|
* attempt++
|
|
202
202
|
* if (attempt < 3) {
|
|
203
|
-
* yield* Effect.fail(`Attempt ${attempt} failed`)
|
|
203
|
+
* return yield* Effect.fail(`Attempt ${attempt} failed`)
|
|
204
204
|
* }
|
|
205
205
|
* return `Success on attempt ${attempt}`
|
|
206
206
|
* }),
|
|
@@ -619,7 +619,7 @@ export const toStepWithSleep = <Output, Input, Error, Env>(
|
|
|
619
619
|
* Effect.gen(function*() {
|
|
620
620
|
* attempt++
|
|
621
621
|
* if (attempt < 5) {
|
|
622
|
-
* yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
622
|
+
* return yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
623
623
|
* }
|
|
624
624
|
* return `Success on attempt ${attempt}`
|
|
625
625
|
* }),
|
|
@@ -736,7 +736,7 @@ export const addDelay: {
|
|
|
736
736
|
* Effect.gen(function*() {
|
|
737
737
|
* attempt++
|
|
738
738
|
* if (attempt < 5) {
|
|
739
|
-
* yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
739
|
+
* return yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
740
740
|
* }
|
|
741
741
|
* return `Success on attempt ${attempt}`
|
|
742
742
|
* }),
|
|
@@ -855,7 +855,7 @@ export const addDelay: {
|
|
|
855
855
|
* Effect.gen(function*() {
|
|
856
856
|
* attempt++
|
|
857
857
|
* if (attempt < 5) {
|
|
858
|
-
* yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
858
|
+
* return yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
859
859
|
* }
|
|
860
860
|
* return `Success on attempt ${attempt}`
|
|
861
861
|
* }),
|
|
@@ -909,7 +909,7 @@ export const addDelay: {
|
|
|
909
909
|
* attempt++
|
|
910
910
|
* yield* Console.log(`Attempt ${attempt}`)
|
|
911
911
|
* if (attempt < 6) {
|
|
912
|
-
* yield* Effect.fail(new Error(`Failure ${attempt}`))
|
|
912
|
+
* return yield* Effect.fail(new Error(`Failure ${attempt}`))
|
|
913
913
|
* }
|
|
914
914
|
* return `Success on attempt ${attempt}`
|
|
915
915
|
* }),
|
|
@@ -948,7 +948,7 @@ export const andThen: {
|
|
|
948
948
|
* attempt++
|
|
949
949
|
* yield* Console.log(`Attempt ${attempt}`)
|
|
950
950
|
* if (attempt < 6) {
|
|
951
|
-
* yield* Effect.fail(new Error(`Failure ${attempt}`))
|
|
951
|
+
* return yield* Effect.fail(new Error(`Failure ${attempt}`))
|
|
952
952
|
* }
|
|
953
953
|
* return `Success on attempt ${attempt}`
|
|
954
954
|
* }),
|
|
@@ -989,7 +989,7 @@ export const andThen: {
|
|
|
989
989
|
* attempt++
|
|
990
990
|
* yield* Console.log(`Attempt ${attempt}`)
|
|
991
991
|
* if (attempt < 6) {
|
|
992
|
-
* yield* Effect.fail(new Error(`Failure ${attempt}`))
|
|
992
|
+
* return yield* Effect.fail(new Error(`Failure ${attempt}`))
|
|
993
993
|
* }
|
|
994
994
|
* return `Success on attempt ${attempt}`
|
|
995
995
|
* }),
|
|
@@ -1397,7 +1397,7 @@ export const andThenResult: {
|
|
|
1397
1397
|
* yield* Console.log(`Retry attempt ${attempt}`)
|
|
1398
1398
|
*
|
|
1399
1399
|
* if (attempt < 3) {
|
|
1400
|
-
* yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
1400
|
+
* return yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
1401
1401
|
* }
|
|
1402
1402
|
*
|
|
1403
1403
|
* return `Success on attempt ${attempt}`
|
|
@@ -1465,7 +1465,7 @@ export const both: {
|
|
|
1465
1465
|
* yield* Console.log(`Retry attempt ${attempt}`)
|
|
1466
1466
|
*
|
|
1467
1467
|
* if (attempt < 3) {
|
|
1468
|
-
* yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
1468
|
+
* return yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
1469
1469
|
* }
|
|
1470
1470
|
*
|
|
1471
1471
|
* return `Success on attempt ${attempt}`
|
|
@@ -1535,7 +1535,7 @@ export const both: {
|
|
|
1535
1535
|
* yield* Console.log(`Retry attempt ${attempt}`)
|
|
1536
1536
|
*
|
|
1537
1537
|
* if (attempt < 3) {
|
|
1538
|
-
* yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
1538
|
+
* return yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
1539
1539
|
* }
|
|
1540
1540
|
*
|
|
1541
1541
|
* return `Success on attempt ${attempt}`
|
|
@@ -1966,7 +1966,7 @@ export const bothWith: {
|
|
|
1966
1966
|
* yield* Console.log(`Attempt ${attempt}`)
|
|
1967
1967
|
*
|
|
1968
1968
|
* if (attempt < 7) { // Needs both phases to succeed
|
|
1969
|
-
* yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
1969
|
+
* return yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
1970
1970
|
* }
|
|
1971
1971
|
*
|
|
1972
1972
|
* return `Success on attempt ${attempt}`
|
|
@@ -2029,7 +2029,7 @@ export const compose: {
|
|
|
2029
2029
|
* yield* Console.log(`Attempt ${attempt}`)
|
|
2030
2030
|
*
|
|
2031
2031
|
* if (attempt < 7) { // Needs both phases to succeed
|
|
2032
|
-
* yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
2032
|
+
* return yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
2033
2033
|
* }
|
|
2034
2034
|
*
|
|
2035
2035
|
* return `Success on attempt ${attempt}`
|
|
@@ -2094,7 +2094,7 @@ export const compose: {
|
|
|
2094
2094
|
* yield* Console.log(`Attempt ${attempt}`)
|
|
2095
2095
|
*
|
|
2096
2096
|
* if (attempt < 7) { // Needs both phases to succeed
|
|
2097
|
-
* yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
2097
|
+
* return yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
2098
2098
|
* }
|
|
2099
2099
|
*
|
|
2100
2100
|
* return `Success on attempt ${attempt}`
|
|
@@ -2642,7 +2642,7 @@ export const collectWhile: {
|
|
|
2642
2642
|
* yield* Console.log("Complex scheduled task...")
|
|
2643
2643
|
* // Simulate occasional failures
|
|
2644
2644
|
* if (Math.random() < 0.3) {
|
|
2645
|
-
* yield* Effect.fail(new Error("Scheduled task failed"))
|
|
2645
|
+
* return yield* Effect.fail(new Error("Scheduled task failed"))
|
|
2646
2646
|
* }
|
|
2647
2647
|
* return "success"
|
|
2648
2648
|
* }),
|
|
@@ -2766,7 +2766,7 @@ export const cron: {
|
|
|
2766
2766
|
* yield* Console.log("Complex scheduled task...")
|
|
2767
2767
|
* // Simulate occasional failures
|
|
2768
2768
|
* if (Math.random() < 0.3) {
|
|
2769
|
-
* yield* Effect.fail(new Error("Scheduled task failed"))
|
|
2769
|
+
* return yield* Effect.fail(new Error("Scheduled task failed"))
|
|
2770
2770
|
* }
|
|
2771
2771
|
* return "success"
|
|
2772
2772
|
* }),
|
|
@@ -2890,7 +2890,7 @@ export const cron: {
|
|
|
2890
2890
|
* yield* Console.log("Complex scheduled task...")
|
|
2891
2891
|
* // Simulate occasional failures
|
|
2892
2892
|
* if (Math.random() < 0.3) {
|
|
2893
|
-
* yield* Effect.fail(new Error("Scheduled task failed"))
|
|
2893
|
+
* return yield* Effect.fail(new Error("Scheduled task failed"))
|
|
2894
2894
|
* }
|
|
2895
2895
|
* return "success"
|
|
2896
2896
|
* }),
|
|
@@ -3098,7 +3098,7 @@ export const duration = (durationInput: Duration.Input): Schedule<Duration.Durat
|
|
|
3098
3098
|
* yield* Console.log(`Retry attempt ${attempt}`)
|
|
3099
3099
|
*
|
|
3100
3100
|
* if (Math.random() < 0.8) { // 80% failure rate
|
|
3101
|
-
* yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
3101
|
+
* return yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
3102
3102
|
* }
|
|
3103
3103
|
*
|
|
3104
3104
|
* return `Success on attempt ${attempt}`
|
|
@@ -3172,7 +3172,7 @@ export const during = (duration: Duration.Input): Schedule<Duration.Duration> =>
|
|
|
3172
3172
|
* yield* Console.log(`Retry attempt ${attempt}`)
|
|
3173
3173
|
*
|
|
3174
3174
|
* if (attempt < 6) {
|
|
3175
|
-
* yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
3175
|
+
* return yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
3176
3176
|
* }
|
|
3177
3177
|
*
|
|
3178
3178
|
* return `Success on attempt ${attempt}`
|
|
@@ -3242,7 +3242,7 @@ export const either: {
|
|
|
3242
3242
|
* yield* Console.log(`Retry attempt ${attempt}`)
|
|
3243
3243
|
*
|
|
3244
3244
|
* if (attempt < 6) {
|
|
3245
|
-
* yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
3245
|
+
* return yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
3246
3246
|
* }
|
|
3247
3247
|
*
|
|
3248
3248
|
* return `Success on attempt ${attempt}`
|
|
@@ -3314,7 +3314,7 @@ export const either: {
|
|
|
3314
3314
|
* yield* Console.log(`Retry attempt ${attempt}`)
|
|
3315
3315
|
*
|
|
3316
3316
|
* if (attempt < 6) {
|
|
3317
|
-
* yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
3317
|
+
* return yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
3318
3318
|
* }
|
|
3319
3319
|
*
|
|
3320
3320
|
* return `Success on attempt ${attempt}`
|
|
@@ -3841,7 +3841,7 @@ export const elapsed: Schedule<Duration.Duration> = fromStepWithMetadata(
|
|
|
3841
3841
|
* attempt++
|
|
3842
3842
|
* if (attempt < 4) {
|
|
3843
3843
|
* yield* Console.log(`Attempt ${attempt} failed, retrying...`)
|
|
3844
|
-
* yield* Effect.fail(new Error(`Failure ${attempt}`))
|
|
3844
|
+
* return yield* Effect.fail(new Error(`Failure ${attempt}`))
|
|
3845
3845
|
* }
|
|
3846
3846
|
* return `Success on attempt ${attempt}`
|
|
3847
3847
|
* }),
|
|
@@ -3891,7 +3891,7 @@ export const exponential = (
|
|
|
3891
3891
|
* yield* Console.log(`Attempt ${attempt}`)
|
|
3892
3892
|
*
|
|
3893
3893
|
* if (attempt < 5) {
|
|
3894
|
-
* yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
3894
|
+
* return yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
3895
3895
|
* }
|
|
3896
3896
|
*
|
|
3897
3897
|
* return `Success on attempt ${attempt}`
|
|
@@ -4436,7 +4436,7 @@ export const passthrough = <Output, Input, Error, Env>(
|
|
|
4436
4436
|
* yield* Console.log(`Attempt ${attempt}`)
|
|
4437
4437
|
*
|
|
4438
4438
|
* if (attempt < 4) {
|
|
4439
|
-
* yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
4439
|
+
* return yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
4440
4440
|
* }
|
|
4441
4441
|
*
|
|
4442
4442
|
* return `Success on attempt ${attempt}`
|
|
@@ -4923,7 +4923,7 @@ export const spaced = (duration: Duration.Input): Schedule<number> => {
|
|
|
4923
4923
|
* Effect.gen(function*() {
|
|
4924
4924
|
* attempt++
|
|
4925
4925
|
* if (attempt < 4) {
|
|
4926
|
-
* yield* Effect.fail(new Error(`Network timeout on attempt ${attempt}`))
|
|
4926
|
+
* return yield* Effect.fail(new Error(`Network timeout on attempt ${attempt}`))
|
|
4927
4927
|
* }
|
|
4928
4928
|
* return `Success on attempt ${attempt}`
|
|
4929
4929
|
* }),
|
|
@@ -4994,7 +4994,7 @@ export const spaced = (duration: Duration.Input): Schedule<number> => {
|
|
|
4994
4994
|
* const errorType = isCritical
|
|
4995
4995
|
* ? "critical database failure"
|
|
4996
4996
|
* : "temporary network issue"
|
|
4997
|
-
* yield* Effect.fail(new Error(errorType))
|
|
4997
|
+
* return yield* Effect.fail(new Error(errorType))
|
|
4998
4998
|
* }),
|
|
4999
4999
|
* alertingSchedule
|
|
5000
5000
|
* ).pipe(
|
|
@@ -5046,7 +5046,7 @@ export const tapInput: {
|
|
|
5046
5046
|
* Effect.gen(function*() {
|
|
5047
5047
|
* attempt++
|
|
5048
5048
|
* if (attempt < 4) {
|
|
5049
|
-
* yield* Effect.fail(new Error(`Network timeout on attempt ${attempt}`))
|
|
5049
|
+
* return yield* Effect.fail(new Error(`Network timeout on attempt ${attempt}`))
|
|
5050
5050
|
* }
|
|
5051
5051
|
* return `Success on attempt ${attempt}`
|
|
5052
5052
|
* }),
|
|
@@ -5117,7 +5117,7 @@ export const tapInput: {
|
|
|
5117
5117
|
* const errorType = isCritical
|
|
5118
5118
|
* ? "critical database failure"
|
|
5119
5119
|
* : "temporary network issue"
|
|
5120
|
-
* yield* Effect.fail(new Error(errorType))
|
|
5120
|
+
* return yield* Effect.fail(new Error(errorType))
|
|
5121
5121
|
* }),
|
|
5122
5122
|
* alertingSchedule
|
|
5123
5123
|
* ).pipe(
|
|
@@ -5171,7 +5171,7 @@ export const tapInput: {
|
|
|
5171
5171
|
* Effect.gen(function*() {
|
|
5172
5172
|
* attempt++
|
|
5173
5173
|
* if (attempt < 4) {
|
|
5174
|
-
* yield* Effect.fail(new Error(`Network timeout on attempt ${attempt}`))
|
|
5174
|
+
* return yield* Effect.fail(new Error(`Network timeout on attempt ${attempt}`))
|
|
5175
5175
|
* }
|
|
5176
5176
|
* return `Success on attempt ${attempt}`
|
|
5177
5177
|
* }),
|
|
@@ -5242,7 +5242,7 @@ export const tapInput: {
|
|
|
5242
5242
|
* const errorType = isCritical
|
|
5243
5243
|
* ? "critical database failure"
|
|
5244
5244
|
* : "temporary network issue"
|
|
5245
|
-
* yield* Effect.fail(new Error(errorType))
|
|
5245
|
+
* return yield* Effect.fail(new Error(errorType))
|
|
5246
5246
|
* }),
|
|
5247
5247
|
* alertingSchedule
|
|
5248
5248
|
* ).pipe(
|
|
@@ -5304,7 +5304,7 @@ export const tapInput: {
|
|
|
5304
5304
|
* Effect.gen(function*() {
|
|
5305
5305
|
* attempt++
|
|
5306
5306
|
* if (attempt < 4) {
|
|
5307
|
-
* yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
5307
|
+
* return yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
5308
5308
|
* }
|
|
5309
5309
|
* return `Success on attempt ${attempt}`
|
|
5310
5310
|
* }),
|
|
@@ -5388,7 +5388,7 @@ export const tapOutput: {
|
|
|
5388
5388
|
* Effect.gen(function*() {
|
|
5389
5389
|
* attempt++
|
|
5390
5390
|
* if (attempt < 4) {
|
|
5391
|
-
* yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
5391
|
+
* return yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
5392
5392
|
* }
|
|
5393
5393
|
* return `Success on attempt ${attempt}`
|
|
5394
5394
|
* }),
|
|
@@ -5474,7 +5474,7 @@ export const tapOutput: {
|
|
|
5474
5474
|
* Effect.gen(function*() {
|
|
5475
5475
|
* attempt++
|
|
5476
5476
|
* if (attempt < 4) {
|
|
5477
|
-
* yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
5477
|
+
* return yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
5478
5478
|
* }
|
|
5479
5479
|
* return `Success on attempt ${attempt}`
|
|
5480
5480
|
* }),
|
|
@@ -5588,7 +5588,7 @@ export const tapOutput: {
|
|
|
5588
5588
|
* yield* Console.log(`Attempt ${attempt}`)
|
|
5589
5589
|
*
|
|
5590
5590
|
* if (attempt < 5) { // Will fail more than 3 times
|
|
5591
|
-
* yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
5591
|
+
* return yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
5592
5592
|
* }
|
|
5593
5593
|
*
|
|
5594
5594
|
* return `Success on attempt ${attempt}`
|
|
@@ -5667,7 +5667,7 @@ export const take: {
|
|
|
5667
5667
|
* yield* Console.log(`Attempt ${attempt}`)
|
|
5668
5668
|
*
|
|
5669
5669
|
* if (attempt < 5) { // Will fail more than 3 times
|
|
5670
|
-
* yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
5670
|
+
* return yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
5671
5671
|
* }
|
|
5672
5672
|
*
|
|
5673
5673
|
* return `Success on attempt ${attempt}`
|
|
@@ -5748,7 +5748,7 @@ export const take: {
|
|
|
5748
5748
|
* yield* Console.log(`Attempt ${attempt}`)
|
|
5749
5749
|
*
|
|
5750
5750
|
* if (attempt < 5) { // Will fail more than 3 times
|
|
5751
|
-
* yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
5751
|
+
* return yield* Effect.fail(new Error(`Attempt ${attempt} failed`))
|
|
5752
5752
|
* }
|
|
5753
5753
|
*
|
|
5754
5754
|
* return `Success on attempt ${attempt}`
|
package/src/index.ts
CHANGED
|
@@ -1160,7 +1160,7 @@ export * as Equivalence from "./Equivalence.ts"
|
|
|
1160
1160
|
*
|
|
1161
1161
|
* // Opt in to error reporting with Effect.withErrorReporting
|
|
1162
1162
|
* const program = Effect.gen(function*() {
|
|
1163
|
-
* yield* new RateLimitError({ retryAfter: 60 })
|
|
1163
|
+
* return yield* new RateLimitError({ retryAfter: 60 })
|
|
1164
1164
|
* }).pipe(
|
|
1165
1165
|
* Effect.withErrorReporting,
|
|
1166
1166
|
* Effect.provide(ErrorReporter.layer([consoleReporter]))
|
|
@@ -108,7 +108,7 @@ export type CliError =
|
|
|
108
108
|
* // In CLI parsing context
|
|
109
109
|
* const parseCommand = Effect.gen(function*() {
|
|
110
110
|
* // If parsing encounters unknown flag
|
|
111
|
-
* return yield*
|
|
111
|
+
* return yield* unrecognizedError
|
|
112
112
|
* })
|
|
113
113
|
* ```
|
|
114
114
|
*
|
|
@@ -201,7 +201,7 @@ export class DuplicateOption extends Schema.ErrorClass(`${TypeId}/DuplicateOptio
|
|
|
201
201
|
* Effect.gen(function*() {
|
|
202
202
|
* const apiKey = options["api-key"]
|
|
203
203
|
* if (!apiKey) {
|
|
204
|
-
* return yield*
|
|
204
|
+
* return yield* missingOptionError
|
|
205
205
|
* }
|
|
206
206
|
* return apiKey
|
|
207
207
|
* })
|
|
@@ -246,7 +246,7 @@ export class MissingOption extends Schema.ErrorClass(`${TypeId}/MissingOption`)(
|
|
|
246
246
|
* const parseArguments = (args: Array<string>) =>
|
|
247
247
|
* Effect.gen(function*() {
|
|
248
248
|
* if (args.length === 0) {
|
|
249
|
-
* return yield*
|
|
249
|
+
* return yield* missingArgError
|
|
250
250
|
* }
|
|
251
251
|
* return args[0]
|
|
252
252
|
* })
|
|
@@ -354,7 +354,7 @@ export class InvalidValue extends Schema.ErrorClass(`${TypeId}/InvalidValue`)({
|
|
|
354
354
|
* Effect.gen(function*() {
|
|
355
355
|
* const validCommands = ["deploy", "destroy", "status"]
|
|
356
356
|
* if (!validCommands.includes(subcommand)) {
|
|
357
|
-
* return yield*
|
|
357
|
+
* return yield* unknownSubcommandError
|
|
358
358
|
* }
|
|
359
359
|
* return subcommand
|
|
360
360
|
* })
|
|
@@ -645,7 +645,7 @@ export const keyValuePair: Primitive<Record<string, string>> = makePrimitive(
|
|
|
645
645
|
*
|
|
646
646
|
* const program = Effect.gen(function*() {
|
|
647
647
|
* // This will always fail - useful for boolean flags
|
|
648
|
-
*
|
|
648
|
+
* return yield* Primitive.none.parse("any-value")
|
|
649
649
|
* })
|
|
650
650
|
*
|
|
651
651
|
* // The above effect will fail with "This option does not accept values"
|
|
@@ -352,6 +352,40 @@ export const remove: {
|
|
|
352
352
|
return out
|
|
353
353
|
})
|
|
354
354
|
|
|
355
|
+
/**
|
|
356
|
+
* @since 4.0.0
|
|
357
|
+
* @category combinators
|
|
358
|
+
*/
|
|
359
|
+
export const removeMany: {
|
|
360
|
+
/**
|
|
361
|
+
* @since 4.0.0
|
|
362
|
+
* @category combinators
|
|
363
|
+
*/
|
|
364
|
+
(keys: Iterable<string>): (self: Headers) => Headers
|
|
365
|
+
/**
|
|
366
|
+
* @since 4.0.0
|
|
367
|
+
* @category combinators
|
|
368
|
+
*/
|
|
369
|
+
(self: Headers, keys: Iterable<string>): Headers
|
|
370
|
+
} = dual<
|
|
371
|
+
/**
|
|
372
|
+
* @since 4.0.0
|
|
373
|
+
* @category combinators
|
|
374
|
+
*/
|
|
375
|
+
(keys: Iterable<string>) => (self: Headers) => Headers,
|
|
376
|
+
/**
|
|
377
|
+
* @since 4.0.0
|
|
378
|
+
* @category combinators
|
|
379
|
+
*/
|
|
380
|
+
(self: Headers, keys: Iterable<string>) => Headers
|
|
381
|
+
>(2, (self, keys) => {
|
|
382
|
+
const out = make(self)
|
|
383
|
+
for (const key of keys) {
|
|
384
|
+
delete out[key.toLowerCase()]
|
|
385
|
+
}
|
|
386
|
+
return out
|
|
387
|
+
})
|
|
388
|
+
|
|
355
389
|
/**
|
|
356
390
|
* @since 4.0.0
|
|
357
391
|
* @category combinators
|
|
@@ -743,6 +743,9 @@ function getResponseEncode<E>(
|
|
|
743
743
|
switch (encoding._tag) {
|
|
744
744
|
case "Json": {
|
|
745
745
|
return ((e) => {
|
|
746
|
+
if (e === undefined) {
|
|
747
|
+
return Effect.succeed(Response.empty({ status }))
|
|
748
|
+
}
|
|
746
749
|
try {
|
|
747
750
|
const s = JSON.stringify(e)
|
|
748
751
|
return Effect.succeed(Response.text(s, { status, contentType: encoding.contentType }))
|
|
@@ -301,6 +301,37 @@ export const FieldOption: <Field extends VariantSchema.Field<any> | Schema.Top>(
|
|
|
301
301
|
jsonUpdate: optionalOption
|
|
302
302
|
}) as any
|
|
303
303
|
|
|
304
|
+
/**
|
|
305
|
+
* @since 4.0.0
|
|
306
|
+
* @category booleans
|
|
307
|
+
*/
|
|
308
|
+
export interface BooleanSqlite extends
|
|
309
|
+
VariantSchema.Field<{
|
|
310
|
+
readonly select: Schema.BooleanFromBit
|
|
311
|
+
readonly insert: Schema.BooleanFromBit
|
|
312
|
+
readonly update: Schema.BooleanFromBit
|
|
313
|
+
readonly json: Schema.Boolean
|
|
314
|
+
readonly jsonCreate: Schema.Boolean
|
|
315
|
+
readonly jsonUpdate: Schema.Boolean
|
|
316
|
+
}>
|
|
317
|
+
{}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* A schema for sqlite booleans that are represented as `0 | 1` in database
|
|
321
|
+
* variants and `boolean` in JSON variants.
|
|
322
|
+
*
|
|
323
|
+
* @since 4.0.0
|
|
324
|
+
* @category booleans
|
|
325
|
+
*/
|
|
326
|
+
export const BooleanSqlite: BooleanSqlite = Field({
|
|
327
|
+
select: Schema.BooleanFromBit,
|
|
328
|
+
insert: Schema.BooleanFromBit,
|
|
329
|
+
update: Schema.BooleanFromBit,
|
|
330
|
+
json: Schema.Boolean,
|
|
331
|
+
jsonCreate: Schema.Boolean,
|
|
332
|
+
jsonUpdate: Schema.Boolean
|
|
333
|
+
})
|
|
334
|
+
|
|
304
335
|
/**
|
|
305
336
|
* @since 4.0.0
|
|
306
337
|
* @category date & time
|