@effect-app/vue 2.85.0 → 2.87.0
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 +12 -0
- package/dist/experimental/commander.d.ts +77 -74
- package/dist/experimental/commander.d.ts.map +1 -1
- package/dist/experimental/commander.js +7 -7
- package/dist/makeClient.d.ts +11 -13
- package/dist/makeClient.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/experimental/commander.ts +349 -316
- package/src/makeClient.ts +4 -10
- package/test/Mutation.test.ts +24 -15
package/src/makeClient.ts
CHANGED
|
@@ -1515,21 +1515,15 @@ export type ToCamel<S extends string | number | symbol> = S extends string
|
|
|
1515
1515
|
: Uncapitalize<S>
|
|
1516
1516
|
: never
|
|
1517
1517
|
|
|
1518
|
-
export interface CommandBase<I
|
|
1519
|
-
handle: (
|
|
1518
|
+
export interface CommandBase<I = void, A = void> {
|
|
1519
|
+
handle: (input: I) => A
|
|
1520
1520
|
waiting: boolean
|
|
1521
1521
|
action: string
|
|
1522
1522
|
label: string
|
|
1523
1523
|
}
|
|
1524
1524
|
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
export interface EffectCommand<I extends ReadonlyArray<any>, A = unknown, E = unknown>
|
|
1528
|
-
extends CommandBase<I, RuntimeFiber<A, E>>
|
|
1529
|
-
{}
|
|
1530
|
-
|
|
1531
|
-
export interface UnaryCommand<I, A = unknown, E = unknown> extends CommandBase<[I], RuntimeFiber<A, E>> {}
|
|
1525
|
+
export interface EffectCommand<I = void, A = unknown, E = unknown> extends CommandBase<I, RuntimeFiber<A, E>> {}
|
|
1532
1526
|
|
|
1533
1527
|
export interface CommandFromRequest<I extends abstract new(...args: any) => any, A = unknown, E = unknown>
|
|
1534
|
-
extends
|
|
1528
|
+
extends EffectCommand<ConstructorParameters<I>[0], A, E>
|
|
1535
1529
|
{}
|
package/test/Mutation.test.ts
CHANGED
|
@@ -24,10 +24,10 @@ describe("alt2", () => {
|
|
|
24
24
|
|
|
25
25
|
const someMutation = {
|
|
26
26
|
id: "Test Action",
|
|
27
|
-
mutate: (() => {}) as unknown as (a: number
|
|
27
|
+
mutate: (() => {}) as unknown as (a: number) => Effect.Effect<string, number, CommandContext>
|
|
28
28
|
} as const
|
|
29
29
|
const someMutation2 = Object.assign(
|
|
30
|
-
(() => {}) as unknown as (a: number
|
|
30
|
+
(() => {}) as unknown as (a: number) => Effect.Effect<string, number, CommandContext>,
|
|
31
31
|
{
|
|
32
32
|
id: "Test Action"
|
|
33
33
|
} as const
|
|
@@ -252,16 +252,19 @@ it.live("can receive and use input", () =>
|
|
|
252
252
|
let executed = false
|
|
253
253
|
|
|
254
254
|
const command = Command.fn("Test Action")(
|
|
255
|
-
function*(input1: number, input2
|
|
255
|
+
function*(input1: number, input2) {
|
|
256
256
|
expect(yield* Effect.currentSpan.pipe(Effect.map((_) => _.name))).toBe("Test Action")
|
|
257
257
|
|
|
258
258
|
return { input1, input2 }
|
|
259
259
|
},
|
|
260
260
|
Effect.tap(() => executed = true)
|
|
261
261
|
)
|
|
262
|
-
const r = yield* unwrap(command.handle(1
|
|
262
|
+
const r = yield* unwrap(command.handle(1))
|
|
263
263
|
|
|
264
|
-
expect(r).
|
|
264
|
+
expect(r.input1).toBe(1) // to confirm that the initial function has ran and received input.
|
|
265
|
+
const { handle, result, waiting, ...rest } = command
|
|
266
|
+
const ctx = { ...rest, state: undefined }
|
|
267
|
+
expect(JSON.stringify(r.input2)).equal(JSON.stringify(ctx))
|
|
265
268
|
expect(executed).toBe(true) // to confirm that the combinators have ran.
|
|
266
269
|
}))
|
|
267
270
|
|
|
@@ -547,19 +550,25 @@ it.live("can receive and use input with alt", () =>
|
|
|
547
550
|
|
|
548
551
|
let executed = false
|
|
549
552
|
|
|
550
|
-
const command = Command.alt("Test Action")(
|
|
551
|
-
Effect
|
|
552
|
-
|
|
553
|
-
|
|
553
|
+
const command = Command.alt("Test Action")((input1: number, input2) =>
|
|
554
|
+
Effect
|
|
555
|
+
.gen(
|
|
556
|
+
function*() {
|
|
557
|
+
expect(yield* Effect.currentSpan.pipe(Effect.map((_) => _.name))).toBe("Test Action")
|
|
554
558
|
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
+
return { input1, input2 }
|
|
560
|
+
}
|
|
561
|
+
)
|
|
562
|
+
.pipe(
|
|
563
|
+
Effect.tap(() => executed = true)
|
|
564
|
+
)
|
|
559
565
|
)
|
|
560
|
-
const r = yield* unwrap(command.handle(1
|
|
566
|
+
const r = yield* unwrap(command.handle(1))
|
|
561
567
|
|
|
562
|
-
|
|
568
|
+
const { handle, result, waiting, ...rest } = command
|
|
569
|
+
const ctx = { ...rest, state: undefined }
|
|
570
|
+
expect(r.input1).toBe(1)
|
|
571
|
+
expect(JSON.stringify(r.input2)).equal(JSON.stringify(ctx)) // to confirm that the initial function has ran and received input.
|
|
563
572
|
expect(executed).toBe(true) // to confirm that the combinators have ran.
|
|
564
573
|
}))
|
|
565
574
|
|