effect 4.0.0-beta.52 → 4.0.0-beta.54
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 +2 -1
- package/dist/Effect.d.ts.map +1 -1
- package/dist/Effect.js.map +1 -1
- package/dist/Effectable.d.ts +29 -0
- package/dist/Effectable.d.ts.map +1 -0
- package/dist/Effectable.js +31 -0
- package/dist/Effectable.js.map +1 -0
- package/dist/Schema.js +1 -1
- package/dist/Schema.js.map +1 -1
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -1
- package/dist/internal/effect.js +1 -1
- package/dist/internal/effect.js.map +1 -1
- package/dist/testing/TestClock.js +1 -1
- package/dist/testing/TestClock.js.map +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js +1 -1
- package/dist/unstable/cluster/ClusterWorkflowEngine.js.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.d.ts.map +1 -1
- package/dist/unstable/http/HttpIncomingMessage.js +4 -8
- package/dist/unstable/http/HttpIncomingMessage.js.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.d.ts +7 -4
- package/dist/unstable/reactivity/AtomHttpApi.d.ts.map +1 -1
- package/dist/unstable/reactivity/AtomHttpApi.js.map +1 -1
- package/dist/unstable/socket/Socket.d.ts +19 -0
- package/dist/unstable/socket/Socket.d.ts.map +1 -1
- package/dist/unstable/socket/Socket.js +15 -10
- package/dist/unstable/socket/Socket.js.map +1 -1
- package/dist/unstable/sql/Statement.d.ts +1 -3
- package/dist/unstable/sql/Statement.d.ts.map +1 -1
- package/dist/unstable/sql/Statement.js +12 -11
- package/dist/unstable/sql/Statement.js.map +1 -1
- package/dist/unstable/workflow/Activity.d.ts +1 -1
- package/dist/unstable/workflow/Activity.d.ts.map +1 -1
- package/dist/unstable/workflow/Activity.js +8 -7
- package/dist/unstable/workflow/Activity.js.map +1 -1
- package/dist/unstable/workflow/DurableDeferred.d.ts +1 -4
- package/dist/unstable/workflow/DurableDeferred.d.ts.map +1 -1
- package/dist/unstable/workflow/DurableDeferred.js +21 -3
- package/dist/unstable/workflow/DurableDeferred.js.map +1 -1
- package/dist/unstable/workflow/Workflow.d.ts +0 -3
- package/dist/unstable/workflow/Workflow.d.ts.map +1 -1
- package/dist/unstable/workflow/Workflow.js +12 -8
- package/dist/unstable/workflow/Workflow.js.map +1 -1
- package/package.json +1 -1
- package/src/Effect.ts +4 -1
- package/src/Effectable.ts +47 -0
- package/src/Schema.ts +1 -1
- package/src/index.ts +5 -0
- package/src/internal/effect.ts +1 -1
- package/src/testing/TestClock.ts +1 -1
- package/src/unstable/cluster/ClusterWorkflowEngine.ts +1 -1
- package/src/unstable/http/HttpIncomingMessage.ts +4 -4
- package/src/unstable/reactivity/AtomHttpApi.ts +14 -4
- package/src/unstable/socket/Socket.ts +63 -26
- package/src/unstable/sql/Statement.ts +19 -23
- package/src/unstable/workflow/Activity.ts +9 -9
- package/src/unstable/workflow/DurableDeferred.ts +23 -5
- package/src/unstable/workflow/Workflow.ts +14 -10
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @since 4.0.0
|
|
3
3
|
*/
|
|
4
|
+
import * as Arr from "../../Array.ts"
|
|
4
5
|
import * as Cause from "../../Cause.ts"
|
|
5
6
|
import * as Context from "../../Context.ts"
|
|
6
7
|
import * as Data from "../../Data.ts"
|
|
7
8
|
import * as Effect from "../../Effect.ts"
|
|
8
9
|
import * as Exit from "../../Exit.ts"
|
|
9
10
|
import * as Fiber from "../../Fiber.ts"
|
|
11
|
+
import * as Filter from "../../Filter.ts"
|
|
10
12
|
import { constFalse, constTrue, dual, identity } from "../../Function.ts"
|
|
11
13
|
import * as Layer from "../../Layer.ts"
|
|
12
14
|
import * as Option from "../../Option.ts"
|
|
@@ -578,13 +580,20 @@ export const intoResult = <A, E, R>(
|
|
|
578
580
|
Effect.scoped,
|
|
579
581
|
Effect.matchCauseEffect({
|
|
580
582
|
onSuccess: (value) => Effect.succeed(new Complete({ exit: Exit.succeed(value) })),
|
|
581
|
-
onFailure: (cause): Effect.Effect<Result<A, E>> =>
|
|
582
|
-
|
|
583
|
+
onFailure: (cause): Effect.Effect<Result<A, E>> => {
|
|
584
|
+
const [reasons, interrupts] = Arr.partition(
|
|
585
|
+
cause.reasons,
|
|
586
|
+
Filter.fromPredicate(Cause.isInterruptReason)
|
|
587
|
+
)
|
|
588
|
+
const hasInterruptsOnly = interrupts.length === cause.reasons.length
|
|
589
|
+
const filtered = reasons.length === 0 ? cause : Cause.fromReasons(reasons)
|
|
590
|
+
return instance.suspended && hasInterruptsOnly
|
|
583
591
|
? Effect.succeed(new Suspended({ cause: instance.cause }))
|
|
584
|
-
: (!instance.interrupted &&
|
|
592
|
+
: (!instance.interrupted && hasInterruptsOnly) ||
|
|
585
593
|
(!captureDefects && Cause.hasDies(cause))
|
|
586
|
-
? Effect.failCause(
|
|
587
|
-
: Effect.succeed(new Complete({ exit: Exit.failCause(
|
|
594
|
+
? Effect.failCause(filtered as Cause.Cause<never>)
|
|
595
|
+
: Effect.succeed(new Complete({ exit: Exit.failCause(filtered) }))
|
|
596
|
+
}
|
|
588
597
|
}),
|
|
589
598
|
(eff) =>
|
|
590
599
|
Effect.onExitPrimitive(eff, (exit) => {
|
|
@@ -610,11 +619,6 @@ export const wrapActivityResult = <A, E, R>(
|
|
|
610
619
|
Effect.contextWith((context: Context.Context<WorkflowInstance>) => {
|
|
611
620
|
const instance = Context.get(context, InstanceTag)
|
|
612
621
|
const state = instance.activityState
|
|
613
|
-
if (instance.suspended) {
|
|
614
|
-
return waitForZero(instance).pipe(
|
|
615
|
-
Effect.andThen(suspend(instance))
|
|
616
|
-
)
|
|
617
|
-
}
|
|
618
622
|
if (state.count === 0) state.latch.closeUnsafe()
|
|
619
623
|
state.count++
|
|
620
624
|
return Effect.onExit(effect, (exit) => {
|