@effect-app/vue 4.0.0-beta.186 → 4.0.0-beta.188
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/CHANGELOG.md +21 -0
- package/dist/commander.d.ts +23 -82
- package/dist/commander.d.ts.map +1 -1
- package/dist/commander.js +31 -108
- package/dist/makeClient.d.ts +5 -59
- package/dist/makeClient.d.ts.map +1 -1
- package/dist/makeClient.js +4 -59
- package/dist/makeUseCommand.d.ts +1 -1
- package/dist/mutate.d.ts +5 -11
- package/dist/mutate.d.ts.map +1 -1
- package/dist/mutate.js +5 -53
- package/examples/streamMutation.ts +4 -23
- package/package.json +2 -2
- package/src/commander.ts +147 -221
- package/src/makeClient.ts +6 -167
- package/src/makeUseCommand.ts +1 -1
- package/src/mutate.ts +4 -80
- package/test/Mutation.test.ts +0 -26
- package/test/dist/streamFn.test.d.ts.map +1 -0
- package/test/dist/stubs.d.ts +2 -151
- package/test/dist/stubs.d.ts.map +1 -1
- package/test/makeClient.test.ts +2 -24
- package/test/streamFinal.test.ts +2 -49
- package/test/streamFn.test.ts +436 -0
package/test/dist/stubs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stubs.d.ts","sourceRoot":"","sources":["../stubs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,oCAAoC,CAAA;AAG9E,OAAO,EAAU,KAAK,EAA0B,CAAC,EAAE,MAAM,YAAY,CAAA;AACrE,OAAO,EAAE,gBAAgB,EAAiB,MAAM,mBAAmB,CAAA;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAI9C,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC/C,OAAO,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAA;AAErC,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAExD,OAAO,KAAK,KAAK,MAA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
|
|
3
|
-
import {
|
|
3
|
+
import { S } from "effect-app"
|
|
4
4
|
import { configureInvalidation, makeQueryKey } from "effect-app/client"
|
|
5
5
|
import * as Exit from "effect/Exit"
|
|
6
|
-
import {
|
|
6
|
+
import { Something, SomethingElse, SomethingElseReq, SomethingReq, useClient, useExperimental } from "./stubs.js"
|
|
7
7
|
|
|
8
8
|
const somethingInvalidationResources = {
|
|
9
9
|
Something: {
|
|
@@ -273,25 +273,3 @@ it.skip("works", () => {
|
|
|
273
273
|
projectedStruct
|
|
274
274
|
})
|
|
275
275
|
})
|
|
276
|
-
|
|
277
|
-
it.skip("stream final type tests", () => {
|
|
278
|
-
const { clientFor } = useClient()
|
|
279
|
-
const client = clientFor(Something, undefined, somethingInvalidationResources)
|
|
280
|
-
|
|
281
|
-
const execNoFinal = client.StreamWithoutFinal.mutateToResult()
|
|
282
|
-
const execWithFinal = client.StreamWithFinal.mutateToResult()
|
|
283
|
-
|
|
284
|
-
// Without `final`: execute input is {id: string} and resolves with void
|
|
285
|
-
const _execNoFinalResult: ReturnType<typeof execNoFinal> = execNoFinal({ id: "test" })
|
|
286
|
-
// @ts-expect-error result of execNoFinal should be void-typed, not ExportComplete
|
|
287
|
-
const _badAssign: Effect.Effect<ExportComplete, never, never> = _execNoFinalResult
|
|
288
|
-
|
|
289
|
-
// With `final: ExportComplete`: execute resolves with ExportComplete
|
|
290
|
-
const _execWithFinalResult: ReturnType<typeof execWithFinal> = execWithFinal({ id: "test" })
|
|
291
|
-
// Assignment should compile — result IS Effect<ExportComplete, ...>
|
|
292
|
-
const _goodAssign: Effect.Effect<ExportComplete, never, never> = _execWithFinalResult
|
|
293
|
-
void _execNoFinalResult
|
|
294
|
-
void _execWithFinalResult
|
|
295
|
-
void _goodAssign
|
|
296
|
-
void _badAssign
|
|
297
|
-
})
|
package/test/streamFinal.test.ts
CHANGED
|
@@ -2,23 +2,13 @@
|
|
|
2
2
|
* Runtime and type tests for the `final` schema on stream requests.
|
|
3
3
|
*
|
|
4
4
|
* The `final` option on a stream request schema lets callers model which type
|
|
5
|
-
* the last emitted stream element is.
|
|
6
|
-
* by `mutateToResult` resolves with that final value instead of `void`.
|
|
5
|
+
* the last emitted stream element is.
|
|
7
6
|
*/
|
|
8
7
|
import { expect, it } from "@effect/vitest"
|
|
9
8
|
import { Effect, S } from "effect-app"
|
|
10
9
|
import * as Stream from "effect/Stream"
|
|
11
10
|
import { asStreamResult } from "../src/mutate.js"
|
|
12
|
-
import { ExportComplete, OperationProgress, Something
|
|
13
|
-
|
|
14
|
-
const somethingInvalidationResources = {
|
|
15
|
-
Something: {
|
|
16
|
-
GetSomething2: Something.GetSomething2,
|
|
17
|
-
GetSomething2WithDependencies: Something.GetSomething2WithDependencies,
|
|
18
|
-
GetSomething3: Something.GetSomething3,
|
|
19
|
-
GetSomething4: Something.GetSomething4
|
|
20
|
-
}
|
|
21
|
-
}
|
|
11
|
+
import { ExportComplete, OperationProgress, Something } from "./stubs.js"
|
|
22
12
|
|
|
23
13
|
// ---------------------------------------------------------------------------
|
|
24
14
|
// asStreamResult — low-level primitive, always returns void
|
|
@@ -39,43 +29,6 @@ it.live("asStreamResult returns void and updates ref with each element", () =>
|
|
|
39
29
|
}
|
|
40
30
|
}))
|
|
41
31
|
|
|
42
|
-
// ---------------------------------------------------------------------------
|
|
43
|
-
// mutateToResult with no `final` — execute resolves with void (type-level)
|
|
44
|
-
// ---------------------------------------------------------------------------
|
|
45
|
-
|
|
46
|
-
it.skip("mutateToResult without final: execute resolves void (type-level)", () => {
|
|
47
|
-
const { clientFor } = useClient()
|
|
48
|
-
const client = clientFor(Something, undefined, somethingInvalidationResources)
|
|
49
|
-
|
|
50
|
-
const execute = client.StreamWithoutFinal.mutateToResult()
|
|
51
|
-
|
|
52
|
-
// execute returns void — assigning to ExportComplete Effect should fail
|
|
53
|
-
const result = execute({ id: "test" })
|
|
54
|
-
// @ts-expect-error result should be void-typed, not ExportComplete
|
|
55
|
-
const _bad: Effect.Effect<ExportComplete, never, never> = result
|
|
56
|
-
void _bad
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
// ---------------------------------------------------------------------------
|
|
60
|
-
// mutateToResult with `final` — execute resolves with Final type (type-level)
|
|
61
|
-
// ---------------------------------------------------------------------------
|
|
62
|
-
|
|
63
|
-
it.skip("mutateToResult with final: execute resolves with ExportComplete (type-level)", () => {
|
|
64
|
-
const { clientFor } = useClient()
|
|
65
|
-
const client = clientFor(Something, undefined, somethingInvalidationResources)
|
|
66
|
-
|
|
67
|
-
const execute = client.StreamWithFinal.mutateToResult()
|
|
68
|
-
|
|
69
|
-
// execute returns ExportComplete — assignment should compile cleanly
|
|
70
|
-
const result = execute({ id: "test" })
|
|
71
|
-
const _ok: Effect.Effect<ExportComplete, never, never> = result
|
|
72
|
-
void _ok
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
// ---------------------------------------------------------------------------
|
|
76
|
-
// Request class — final schema stored on class
|
|
77
|
-
// ---------------------------------------------------------------------------
|
|
78
|
-
|
|
79
32
|
it("stream request without final: .final is undefined", () => {
|
|
80
33
|
const req = Something.StreamWithoutFinal
|
|
81
34
|
expect((req as any).final).toBeUndefined()
|
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
import { expect, it } from "@effect/vitest"
|
|
2
|
+
import { Deferred, Effect, Fiber } from "effect-app"
|
|
3
|
+
import * as Stream from "effect/Stream"
|
|
4
|
+
import { CommanderStatic } from "../src/commander.js"
|
|
5
|
+
import { AsyncResult } from "../src/lib.js"
|
|
6
|
+
import { useExperimental } from "./stubs.js"
|
|
7
|
+
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
// Helpers
|
|
10
|
+
// ---------------------------------------------------------------------------
|
|
11
|
+
|
|
12
|
+
/** Wait for the fiber spawned by `cmd.handle()` to finish. */
|
|
13
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
+
const join = (fiber: Fiber.Fiber<any, any>) => Fiber.join(fiber)
|
|
15
|
+
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
// Non-generator form — (arg) => Stream
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
|
|
20
|
+
it.live("streamFn: non-generator returning Stream runs stream and updates result", () =>
|
|
21
|
+
Effect.gen(function*() {
|
|
22
|
+
const Command = useExperimental({ toasts: [] })
|
|
23
|
+
|
|
24
|
+
const cmd = Command.streamFn("test-stream-plain")(
|
|
25
|
+
(_arg: number) => Stream.make(10, 20, 30)
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
expect(cmd.waiting).toBe(false)
|
|
29
|
+
yield* join(cmd.handle(1))
|
|
30
|
+
|
|
31
|
+
expect(cmd.result._tag).toBe("Success")
|
|
32
|
+
if (cmd.result._tag === "Success") {
|
|
33
|
+
expect(cmd.result.value).toBe(30)
|
|
34
|
+
expect(cmd.result.waiting).toBe(false)
|
|
35
|
+
}
|
|
36
|
+
}))
|
|
37
|
+
|
|
38
|
+
// ---------------------------------------------------------------------------
|
|
39
|
+
// Generator form — function*(arg) { yield* effect; return Stream }
|
|
40
|
+
// ---------------------------------------------------------------------------
|
|
41
|
+
|
|
42
|
+
it.live("streamFn: generator form executes yielded effects and subscribes to returned stream", () =>
|
|
43
|
+
Effect.gen(function*() {
|
|
44
|
+
const Command = useExperimental({ toasts: [] })
|
|
45
|
+
|
|
46
|
+
let generatorBodyExecuted = false
|
|
47
|
+
|
|
48
|
+
const cmd = Command.streamFn("test-stream-gen")(
|
|
49
|
+
function*(arg: number) {
|
|
50
|
+
generatorBodyExecuted = true
|
|
51
|
+
const doubled = yield* Effect.succeed(arg * 2)
|
|
52
|
+
return Stream.make(doubled, doubled + 1, doubled + 2)
|
|
53
|
+
}
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
yield* join(cmd.handle(5))
|
|
57
|
+
|
|
58
|
+
// Generator body MUST have run
|
|
59
|
+
expect(generatorBodyExecuted).toBe(true)
|
|
60
|
+
|
|
61
|
+
// Stream emitted three values: 10, 11, 12; last one should be in result
|
|
62
|
+
expect(cmd.result._tag).toBe("Success")
|
|
63
|
+
if (cmd.result._tag === "Success") {
|
|
64
|
+
expect(cmd.result.value).toBe(12)
|
|
65
|
+
expect(cmd.result.waiting).toBe(false)
|
|
66
|
+
}
|
|
67
|
+
}))
|
|
68
|
+
|
|
69
|
+
// ---------------------------------------------------------------------------
|
|
70
|
+
// Generator form with async effect (Effect.promise)
|
|
71
|
+
// ---------------------------------------------------------------------------
|
|
72
|
+
|
|
73
|
+
it.live("streamFn: generator form with async Effect.promise works", () =>
|
|
74
|
+
Effect.gen(function*() {
|
|
75
|
+
const Command = useExperimental({ toasts: [] })
|
|
76
|
+
|
|
77
|
+
let asyncValueReceived: string | undefined
|
|
78
|
+
|
|
79
|
+
const cmd = Command.streamFn("test-stream-gen-async")(
|
|
80
|
+
function*(arg: string) {
|
|
81
|
+
// Simulate the pattern from the bug report: yield* Effect.promise(...)
|
|
82
|
+
const result = yield* Effect.promise(() => Promise.resolve(`processed:${arg}`))
|
|
83
|
+
asyncValueReceived = result
|
|
84
|
+
return Stream.make(result, result + "!")
|
|
85
|
+
}
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
yield* join(cmd.handle("hello"))
|
|
89
|
+
|
|
90
|
+
expect(asyncValueReceived).toBe("processed:hello")
|
|
91
|
+
expect(cmd.result._tag).toBe("Success")
|
|
92
|
+
if (cmd.result._tag === "Success") {
|
|
93
|
+
expect(cmd.result.value).toBe("processed:hello!")
|
|
94
|
+
}
|
|
95
|
+
}))
|
|
96
|
+
|
|
97
|
+
// ---------------------------------------------------------------------------
|
|
98
|
+
// Non-generator returning Effect<Stream>
|
|
99
|
+
// ---------------------------------------------------------------------------
|
|
100
|
+
|
|
101
|
+
it.live("streamFn: non-generator returning Effect<Stream> runs stream", () =>
|
|
102
|
+
Effect.gen(function*() {
|
|
103
|
+
const Command = useExperimental({ toasts: [] })
|
|
104
|
+
|
|
105
|
+
const cmd = Command.streamFn("test-stream-effect-stream")(
|
|
106
|
+
(arg: number) => Effect.succeed(Stream.make(arg * 3, arg * 3 + 1))
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
yield* join(cmd.handle(4))
|
|
110
|
+
|
|
111
|
+
expect(cmd.result._tag).toBe("Success")
|
|
112
|
+
if (cmd.result._tag === "Success") {
|
|
113
|
+
expect(cmd.result.value).toBe(13) // 4*3+1 = 13
|
|
114
|
+
}
|
|
115
|
+
}))
|
|
116
|
+
|
|
117
|
+
// ---------------------------------------------------------------------------
|
|
118
|
+
// Generator form — waiting state flips correctly
|
|
119
|
+
// ---------------------------------------------------------------------------
|
|
120
|
+
|
|
121
|
+
it.live("streamFn: generator form sets waiting=true during execution then false after", () =>
|
|
122
|
+
Effect.gen(function*() {
|
|
123
|
+
const Command = useExperimental({ toasts: [] })
|
|
124
|
+
|
|
125
|
+
const cmd = Command.streamFn("test-stream-gen-waiting")(
|
|
126
|
+
function*(_arg: void) {
|
|
127
|
+
return Stream.make(1, 2, 3)
|
|
128
|
+
}
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
expect(cmd.waiting).toBe(false)
|
|
132
|
+
const fiber = cmd.handle()
|
|
133
|
+
|
|
134
|
+
// result transitions to initial(true) = waiting synchronously inside runStream
|
|
135
|
+
// after the fiber runs, waiting should settle to false
|
|
136
|
+
yield* join(fiber)
|
|
137
|
+
expect(cmd.waiting).toBe(false)
|
|
138
|
+
|
|
139
|
+
expect(AsyncResult.isSuccess(cmd.result)).toBe(true)
|
|
140
|
+
}))
|
|
141
|
+
|
|
142
|
+
// ---------------------------------------------------------------------------
|
|
143
|
+
// Generator form with a stream-transformer combinator
|
|
144
|
+
// ---------------------------------------------------------------------------
|
|
145
|
+
|
|
146
|
+
it.live("streamFn: generator form with combinator — combinator transforms the stream", () =>
|
|
147
|
+
Effect.gen(function*() {
|
|
148
|
+
const Command = useExperimental({ toasts: [] })
|
|
149
|
+
|
|
150
|
+
const emittedByCombinator: number[] = []
|
|
151
|
+
|
|
152
|
+
// A combinator that records each element it sees.
|
|
153
|
+
// The first argument may be a Stream or an Effect<Stream> (for generator-form handlers),
|
|
154
|
+
// matching how withDefaultToastStream handles it.
|
|
155
|
+
const spyCombinator = (
|
|
156
|
+
input: Stream.Stream<number, never, never> | Effect.Effect<Stream.Stream<number, never, never>>
|
|
157
|
+
) => {
|
|
158
|
+
const stream: Stream.Stream<number, never, never> = Stream.isStream(input)
|
|
159
|
+
? input
|
|
160
|
+
: Stream.unwrap(input as Effect.Effect<Stream.Stream<number, never, never>>)
|
|
161
|
+
return stream.pipe(
|
|
162
|
+
Stream.tap((v) =>
|
|
163
|
+
Effect.sync(() => {
|
|
164
|
+
emittedByCombinator.push(v)
|
|
165
|
+
})
|
|
166
|
+
)
|
|
167
|
+
)
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const cmd = Command.streamFn("test-stream-gen-combinator")(
|
|
171
|
+
function*(arg: number) {
|
|
172
|
+
const base = yield* Effect.succeed(arg * 10)
|
|
173
|
+
return Stream.make(base, base + 1, base + 2)
|
|
174
|
+
},
|
|
175
|
+
// combinator receives (input, arg, ctx) — input is Stream or Effect<Stream> depending on handler form
|
|
176
|
+
(input: Stream.Stream<number, never, never> | Effect.Effect<Stream.Stream<number, never, never>>) =>
|
|
177
|
+
spyCombinator(input)
|
|
178
|
+
)
|
|
179
|
+
|
|
180
|
+
yield* join(cmd.handle(3))
|
|
181
|
+
|
|
182
|
+
// combinator must have seen all elements: 30, 31, 32
|
|
183
|
+
expect(emittedByCombinator).toEqual([30, 31, 32])
|
|
184
|
+
|
|
185
|
+
expect(cmd.result._tag).toBe("Success")
|
|
186
|
+
if (cmd.result._tag === "Success") {
|
|
187
|
+
expect(cmd.result.value).toBe(32)
|
|
188
|
+
}
|
|
189
|
+
}))
|
|
190
|
+
|
|
191
|
+
// ---------------------------------------------------------------------------
|
|
192
|
+
// Generator form — Stream.ensuring runs after stream completes
|
|
193
|
+
// ---------------------------------------------------------------------------
|
|
194
|
+
|
|
195
|
+
it.live("streamFn: generator form Stream.ensuring cleanup runs after stream ends", () =>
|
|
196
|
+
Effect.gen(function*() {
|
|
197
|
+
const Command = useExperimental({ toasts: [] })
|
|
198
|
+
|
|
199
|
+
let cleanupRan = false
|
|
200
|
+
|
|
201
|
+
const cmd = Command.streamFn("test-stream-gen-ensuring")(
|
|
202
|
+
function*(arg: number) {
|
|
203
|
+
const value = yield* Effect.succeed(arg + 100)
|
|
204
|
+
return Stream.make(value).pipe(
|
|
205
|
+
Stream.ensuring(Effect.sync(() => {
|
|
206
|
+
cleanupRan = true
|
|
207
|
+
}))
|
|
208
|
+
)
|
|
209
|
+
}
|
|
210
|
+
)
|
|
211
|
+
|
|
212
|
+
yield* join(cmd.handle(7))
|
|
213
|
+
|
|
214
|
+
expect(cleanupRan).toBe(true)
|
|
215
|
+
expect(cmd.result._tag).toBe("Success")
|
|
216
|
+
if (cmd.result._tag === "Success") {
|
|
217
|
+
expect(cmd.result.value).toBe(107)
|
|
218
|
+
}
|
|
219
|
+
}))
|
|
220
|
+
|
|
221
|
+
// ---------------------------------------------------------------------------
|
|
222
|
+
// Command.mapProgress — updates progress ref for each element
|
|
223
|
+
// ---------------------------------------------------------------------------
|
|
224
|
+
|
|
225
|
+
it.live("streamFn: Command.mapProgress updates progress ref for each stream element", () =>
|
|
226
|
+
Effect.gen(function*() {
|
|
227
|
+
const Command = useExperimental({ toasts: [] })
|
|
228
|
+
|
|
229
|
+
const cmd = Command.streamFn("test-map-progress")(
|
|
230
|
+
function*(_arg: void) {
|
|
231
|
+
return Stream.make(1, 2, 3).pipe(
|
|
232
|
+
CommanderStatic.mapProgress((r) =>
|
|
233
|
+
AsyncResult.isSuccess(r)
|
|
234
|
+
? { text: `item-${r.value}`, percentage: r.value * 10 }
|
|
235
|
+
: undefined
|
|
236
|
+
)
|
|
237
|
+
)
|
|
238
|
+
}
|
|
239
|
+
)
|
|
240
|
+
|
|
241
|
+
// progress starts undefined (reactive unwraps the ref)
|
|
242
|
+
expect(cmd.progress).toBeUndefined()
|
|
243
|
+
|
|
244
|
+
yield* join(cmd.handle())
|
|
245
|
+
|
|
246
|
+
// after stream drains, last mapped progress value should be set
|
|
247
|
+
expect(cmd.progress).toEqual({ text: "item-3", percentage: 30 })
|
|
248
|
+
}))
|
|
249
|
+
|
|
250
|
+
// ---------------------------------------------------------------------------
|
|
251
|
+
// Command.updateProgress — imperative progress update from stream
|
|
252
|
+
// ---------------------------------------------------------------------------
|
|
253
|
+
|
|
254
|
+
it.live("streamFn: Command.updateProgress imperatively drives the progress ref", () =>
|
|
255
|
+
Effect.gen(function*() {
|
|
256
|
+
const Command = useExperimental({ toasts: [] })
|
|
257
|
+
|
|
258
|
+
const cmd = Command.streamFn("test-update-progress")(
|
|
259
|
+
function*(_arg: void) {
|
|
260
|
+
return Stream.make("a", "b").pipe(
|
|
261
|
+
Stream.tap((v) => CommanderStatic.updateProgress(`processing ${v}`))
|
|
262
|
+
)
|
|
263
|
+
}
|
|
264
|
+
)
|
|
265
|
+
|
|
266
|
+
expect(cmd.progress).toBeUndefined()
|
|
267
|
+
yield* join(cmd.handle())
|
|
268
|
+
|
|
269
|
+
expect(cmd.progress).toBe("processing b")
|
|
270
|
+
}))
|
|
271
|
+
|
|
272
|
+
// ---------------------------------------------------------------------------
|
|
273
|
+
// Command.withDefaultToastStream — in-progress (waiting) initial toast
|
|
274
|
+
// ---------------------------------------------------------------------------
|
|
275
|
+
|
|
276
|
+
it.live("withDefaultToastStream: shows info toast while stream is running", () =>
|
|
277
|
+
Effect.gen(function*() {
|
|
278
|
+
const toasts: any[] = []
|
|
279
|
+
const Command = useExperimental({ toasts, messages: { "handle.waiting": "{action} waiting…" } })
|
|
280
|
+
|
|
281
|
+
// Gate that lets us inspect toast state while the stream is paused mid-flight.
|
|
282
|
+
const streamPaused = yield* Deferred.make<void>()
|
|
283
|
+
const resume = yield* Deferred.make<void>()
|
|
284
|
+
|
|
285
|
+
const cmd = Command.streamFn("doWork")(
|
|
286
|
+
function*(_arg: void) {
|
|
287
|
+
return Stream.make(1).pipe(
|
|
288
|
+
Stream.tap(() =>
|
|
289
|
+
Effect.gen(function*() {
|
|
290
|
+
yield* Deferred.succeed(streamPaused, undefined)
|
|
291
|
+
yield* Deferred.await(resume)
|
|
292
|
+
})
|
|
293
|
+
)
|
|
294
|
+
)
|
|
295
|
+
},
|
|
296
|
+
Command.withDefaultToastStream()
|
|
297
|
+
)
|
|
298
|
+
|
|
299
|
+
const fiber = cmd.handle()
|
|
300
|
+
|
|
301
|
+
// Wait until the stream has emitted its first element (and paused).
|
|
302
|
+
yield* Deferred.await(streamPaused)
|
|
303
|
+
|
|
304
|
+
// The waiting info toast should exist before the stream finishes.
|
|
305
|
+
expect(toasts.some((t) => t.type === "info")).toBe(true)
|
|
306
|
+
const infoToast = toasts.find((t) => t.type === "info")
|
|
307
|
+
expect(infoToast.message).toContain("doWork")
|
|
308
|
+
|
|
309
|
+
// Let the stream finish.
|
|
310
|
+
yield* Deferred.succeed(resume, undefined)
|
|
311
|
+
yield* join(fiber)
|
|
312
|
+
|
|
313
|
+
// After completion the same toast slot is replaced with a success toast.
|
|
314
|
+
expect(toasts.some((t) => t.type === "success")).toBe(true)
|
|
315
|
+
}))
|
|
316
|
+
|
|
317
|
+
// ---------------------------------------------------------------------------
|
|
318
|
+
// Command.withDefaultToastStream — progress text/percent updates the toast
|
|
319
|
+
// ---------------------------------------------------------------------------
|
|
320
|
+
|
|
321
|
+
it.live("withDefaultToastStream: progress option updates waiting toast message", () =>
|
|
322
|
+
Effect.gen(function*() {
|
|
323
|
+
const toasts: any[] = []
|
|
324
|
+
const Command = useExperimental({
|
|
325
|
+
toasts,
|
|
326
|
+
messages: { "handle.waiting": "Working…", "handle.success": "{action} done" }
|
|
327
|
+
})
|
|
328
|
+
|
|
329
|
+
const progressSnapshots: string[] = []
|
|
330
|
+
|
|
331
|
+
const cmd = Command.streamFn("doWorkProgress")(
|
|
332
|
+
function*(_arg: void) {
|
|
333
|
+
return Stream.make(10, 50, 100).pipe(
|
|
334
|
+
Stream.tap((pct) =>
|
|
335
|
+
Effect.sync(() => {
|
|
336
|
+
progressSnapshots.push(`${pct}%`)
|
|
337
|
+
})
|
|
338
|
+
)
|
|
339
|
+
)
|
|
340
|
+
},
|
|
341
|
+
Command.withDefaultToastStream({
|
|
342
|
+
progress: (r) =>
|
|
343
|
+
AsyncResult.isSuccess(r)
|
|
344
|
+
? { text: `${r.value}%`, percentage: r.value }
|
|
345
|
+
: undefined
|
|
346
|
+
})
|
|
347
|
+
)
|
|
348
|
+
|
|
349
|
+
yield* join(cmd.handle())
|
|
350
|
+
|
|
351
|
+
// All three stream elements were visited by the tap above
|
|
352
|
+
expect(progressSnapshots).toEqual(["10%", "50%", "100%"])
|
|
353
|
+
|
|
354
|
+
// cmd.progress reflects the last mapped value (reactive unwraps the ref)
|
|
355
|
+
expect(cmd.progress).toEqual({ text: "100%", percentage: 100 })
|
|
356
|
+
|
|
357
|
+
// A success toast should appear after the stream completes
|
|
358
|
+
expect(toasts.some((t) => t.type === "success")).toBe(true)
|
|
359
|
+
}))
|
|
360
|
+
|
|
361
|
+
// ---------------------------------------------------------------------------
|
|
362
|
+
// Command.withDefaultToastStream — failure shows warning/error toast
|
|
363
|
+
// ---------------------------------------------------------------------------
|
|
364
|
+
|
|
365
|
+
it.live("withDefaultToastStream: failure shows failure toast, not success toast", () =>
|
|
366
|
+
Effect.gen(function*() {
|
|
367
|
+
const toasts: any[] = []
|
|
368
|
+
const Command = useExperimental({ toasts })
|
|
369
|
+
|
|
370
|
+
class BoomError {
|
|
371
|
+
readonly _tag = "BoomError"
|
|
372
|
+
readonly message = "boom"
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
const cmd = Command.streamFn("doWorkFail")(
|
|
376
|
+
function*(_arg: void) {
|
|
377
|
+
return Stream.fail(new BoomError())
|
|
378
|
+
},
|
|
379
|
+
Command.withDefaultToastStream()
|
|
380
|
+
)
|
|
381
|
+
|
|
382
|
+
yield* join(cmd.handle())
|
|
383
|
+
|
|
384
|
+
// Typed errors → withDefaultToastStream calls toast.warning (level: "warn")
|
|
385
|
+
expect(toasts.some((t) => t.type === "warning" || t.type === "error")).toBe(true)
|
|
386
|
+
expect(toasts.some((t) => t.type === "success")).toBe(false)
|
|
387
|
+
}))
|
|
388
|
+
|
|
389
|
+
// ---------------------------------------------------------------------------
|
|
390
|
+
// Command.withDefaultToastStream — die (defect) shows error toast
|
|
391
|
+
// ---------------------------------------------------------------------------
|
|
392
|
+
|
|
393
|
+
it.live("withDefaultToastStream: die/defect shows error toast, not warning or success", () =>
|
|
394
|
+
Effect.gen(function*() {
|
|
395
|
+
const toasts: any[] = []
|
|
396
|
+
const Command = useExperimental({ toasts })
|
|
397
|
+
|
|
398
|
+
const cmd = Command.streamFn("doWorkDie")(
|
|
399
|
+
function*(_arg: void) {
|
|
400
|
+
// Stream.die produces a defect — Cause.findErrorOption returns Option.none()
|
|
401
|
+
// so defaultFailureMessageHandler returns a plain string → toast.error
|
|
402
|
+
return Stream.die(new Error("unexpected defect"))
|
|
403
|
+
},
|
|
404
|
+
Command.withDefaultToastStream()
|
|
405
|
+
)
|
|
406
|
+
|
|
407
|
+
yield* join(cmd.handle())
|
|
408
|
+
|
|
409
|
+
expect(toasts.some((t) => t.type === "error")).toBe(true)
|
|
410
|
+
expect(toasts.some((t) => t.type === "warning")).toBe(false)
|
|
411
|
+
expect(toasts.some((t) => t.type === "success")).toBe(false)
|
|
412
|
+
}))
|
|
413
|
+
|
|
414
|
+
// ---------------------------------------------------------------------------
|
|
415
|
+
// Command.withDefaultToastStream — success shows success toast
|
|
416
|
+
// ---------------------------------------------------------------------------
|
|
417
|
+
|
|
418
|
+
it.live("withDefaultToastStream: success shows success toast after stream drains", () =>
|
|
419
|
+
Effect.gen(function*() {
|
|
420
|
+
const toasts: any[] = []
|
|
421
|
+
const Command = useExperimental({ toasts, messages: { "handle.success": "{action} complete" } })
|
|
422
|
+
|
|
423
|
+
const cmd = Command.streamFn("doWorkSuccess")(
|
|
424
|
+
function*(_arg: void) {
|
|
425
|
+
return Stream.make(42)
|
|
426
|
+
},
|
|
427
|
+
Command.withDefaultToastStream()
|
|
428
|
+
)
|
|
429
|
+
|
|
430
|
+
yield* join(cmd.handle())
|
|
431
|
+
|
|
432
|
+
const successToast = toasts.find((t) => t.type === "success")
|
|
433
|
+
expect(successToast).toBeDefined()
|
|
434
|
+
expect(successToast.message).toContain("doWorkSuccess")
|
|
435
|
+
expect(toasts.some((t) => t.type === "error")).toBe(false)
|
|
436
|
+
}))
|