@effect-app/vue 4.0.0-beta.19 → 4.0.0-beta.190
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 +1383 -0
- package/dist/commander.d.ts +620 -0
- package/dist/commander.d.ts.map +1 -0
- package/dist/commander.js +1056 -0
- package/dist/confirm.d.ts +19 -0
- package/dist/confirm.d.ts.map +1 -0
- package/dist/confirm.js +24 -0
- package/dist/errorReporter.d.ts +4 -4
- package/dist/errorReporter.d.ts.map +1 -1
- package/dist/errorReporter.js +12 -18
- package/dist/form.d.ts +13 -4
- package/dist/form.d.ts.map +1 -1
- package/dist/form.js +41 -12
- package/dist/index.d.ts +1 -1
- package/dist/intl.d.ts +15 -0
- package/dist/intl.d.ts.map +1 -0
- package/dist/intl.js +9 -0
- package/dist/lib.d.ts +6 -8
- package/dist/lib.d.ts.map +1 -1
- package/dist/lib.js +34 -7
- package/dist/makeClient.d.ts +191 -292
- package/dist/makeClient.d.ts.map +1 -1
- package/dist/makeClient.js +217 -369
- package/dist/makeContext.d.ts +1 -1
- package/dist/makeContext.d.ts.map +1 -1
- package/dist/makeIntl.d.ts +1 -1
- package/dist/makeIntl.d.ts.map +1 -1
- package/dist/makeUseCommand.d.ts +8 -0
- package/dist/makeUseCommand.d.ts.map +1 -0
- package/dist/makeUseCommand.js +13 -0
- package/dist/mutate.d.ts +56 -25
- package/dist/mutate.d.ts.map +1 -1
- package/dist/mutate.js +132 -33
- package/dist/query.d.ts +24 -16
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +119 -37
- package/dist/routeParams.d.ts +1 -1
- package/dist/runtime.d.ts +5 -2
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +27 -17
- package/dist/toast.d.ts +46 -0
- package/dist/toast.d.ts.map +1 -0
- package/dist/toast.js +32 -0
- package/dist/withToast.d.ts +26 -0
- package/dist/withToast.d.ts.map +1 -0
- package/dist/withToast.js +54 -0
- package/eslint.config.mjs +2 -2
- package/examples/streamMutation.ts +70 -0
- package/package.json +48 -48
- package/src/commander.ts +3378 -0
- package/src/{experimental/confirm.ts → confirm.ts} +10 -14
- package/src/errorReporter.ts +62 -74
- package/src/form.ts +55 -16
- package/src/intl.ts +12 -0
- package/src/lib.ts +46 -13
- package/src/makeClient.ts +623 -1043
- package/src/{experimental/makeUseCommand.ts → makeUseCommand.ts} +6 -4
- package/src/mutate.ts +273 -72
- package/src/query.ts +181 -68
- package/src/runtime.ts +39 -18
- package/src/{experimental/toast.ts → toast.ts} +11 -25
- package/src/{experimental/withToast.ts → withToast.ts} +28 -10
- package/test/Mutation.test.ts +105 -11
- package/test/dist/form.test.d.ts.map +1 -1
- package/test/dist/lib.test.d.ts.map +1 -0
- package/test/dist/streamFinal.test.d.ts.map +1 -0
- package/test/dist/streamFn.test.d.ts.map +1 -0
- package/test/dist/stubs.d.ts +3289 -114
- package/test/dist/stubs.d.ts.map +1 -1
- package/test/dist/stubs.js +152 -25
- package/test/form-validation-errors.test.ts +23 -19
- package/test/form.test.ts +20 -2
- package/test/lib.test.ts +240 -0
- package/test/makeClient.test.ts +286 -38
- package/test/streamFinal.test.ts +63 -0
- package/test/streamFn.test.ts +436 -0
- package/test/stubs.ts +192 -42
- package/tsconfig.examples.json +20 -0
- package/tsconfig.json +0 -1
- package/tsconfig.json.bak +5 -2
- package/tsconfig.src.json +34 -34
- package/tsconfig.test.json +2 -2
- package/vitest.config.ts +5 -5
- package/dist/experimental/commander.d.ts +0 -359
- package/dist/experimental/commander.d.ts.map +0 -1
- package/dist/experimental/commander.js +0 -557
- package/dist/experimental/confirm.d.ts +0 -19
- package/dist/experimental/confirm.d.ts.map +0 -1
- package/dist/experimental/confirm.js +0 -28
- package/dist/experimental/intl.d.ts +0 -16
- package/dist/experimental/intl.d.ts.map +0 -1
- package/dist/experimental/intl.js +0 -5
- package/dist/experimental/makeUseCommand.d.ts +0 -8
- package/dist/experimental/makeUseCommand.d.ts.map +0 -1
- package/dist/experimental/makeUseCommand.js +0 -13
- package/dist/experimental/toast.d.ts +0 -47
- package/dist/experimental/toast.d.ts.map +0 -1
- package/dist/experimental/toast.js +0 -41
- package/dist/experimental/withToast.d.ts +0 -25
- package/dist/experimental/withToast.d.ts.map +0 -1
- package/dist/experimental/withToast.js +0 -45
- package/src/experimental/commander.ts +0 -1835
- package/src/experimental/intl.ts +0 -9
package/test/Mutation.test.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
2
|
import { it } from "@effect/vitest"
|
|
3
3
|
import { Cause, Effect, Exit, Fiber, Option } from "effect-app"
|
|
4
|
-
import { CommandContext, DefaultIntl } from "../src/
|
|
4
|
+
import { CommandContext, DefaultIntl } from "../src/commander.js"
|
|
5
5
|
import { AsyncResult } from "../src/lib.js"
|
|
6
6
|
import { useExperimental } from "./stubs.js"
|
|
7
7
|
|
|
@@ -71,7 +71,10 @@ describe("alt2", () => {
|
|
|
71
71
|
expect(yield* Effect.currentSpan.pipe(Effect.map((_) => _.name))).toBe("Test Action")
|
|
72
72
|
})),
|
|
73
73
|
Effect.tap(() =>
|
|
74
|
-
Effect.currentSpan.pipe(
|
|
74
|
+
Effect.currentSpan.pipe(
|
|
75
|
+
Effect.map((_) => _.name),
|
|
76
|
+
Effect.tap((_) => Effect.sync(() => expect(_).toBe("Test Action")))
|
|
77
|
+
)
|
|
75
78
|
),
|
|
76
79
|
Effect.tap(() => Effect.sync(() => executed = true))
|
|
77
80
|
)
|
|
@@ -125,7 +128,10 @@ it.live("works", () =>
|
|
|
125
128
|
expect(yield* Effect.currentSpan.pipe(Effect.map((_) => _.name))).toBe("Test Action")
|
|
126
129
|
})),
|
|
127
130
|
Effect.tap(() =>
|
|
128
|
-
Effect.currentSpan.pipe(
|
|
131
|
+
Effect.currentSpan.pipe(
|
|
132
|
+
Effect.map((_) => _.name),
|
|
133
|
+
Effect.tap((_) => Effect.sync(() => expect(_).toBe("Test Action")))
|
|
134
|
+
)
|
|
129
135
|
),
|
|
130
136
|
Effect.tap(() => Effect.sync(() => executed = true))
|
|
131
137
|
)
|
|
@@ -175,7 +181,10 @@ it.live("works non-gen", () =>
|
|
|
175
181
|
expect(yield* Effect.currentSpan.pipe(Effect.map((_) => _.name))).toBe("Test Action")
|
|
176
182
|
})),
|
|
177
183
|
Effect.tap(() =>
|
|
178
|
-
Effect.currentSpan.pipe(
|
|
184
|
+
Effect.currentSpan.pipe(
|
|
185
|
+
Effect.map((_) => _.name),
|
|
186
|
+
Effect.tap((_) => Effect.sync(() => expect(_).toBe("Test Action")))
|
|
187
|
+
)
|
|
179
188
|
),
|
|
180
189
|
Effect.tap(() => Effect.sync(() => executed = true))
|
|
181
190
|
)
|
|
@@ -317,7 +326,10 @@ it.live("with toasts", () =>
|
|
|
317
326
|
expect(yield* Effect.currentSpan.pipe(Effect.map((_) => _.name))).toBe("Test Action")
|
|
318
327
|
})),
|
|
319
328
|
Effect.tap(() =>
|
|
320
|
-
Effect.currentSpan.pipe(
|
|
329
|
+
Effect.currentSpan.pipe(
|
|
330
|
+
Effect.map((_) => _.name),
|
|
331
|
+
Effect.tap((_) => Effect.sync(() => expect(_).toBe("Test Action")))
|
|
332
|
+
)
|
|
321
333
|
),
|
|
322
334
|
// WithToast.handle({
|
|
323
335
|
// onFailure: "failed",
|
|
@@ -388,9 +400,30 @@ it.live("fail", () =>
|
|
|
388
400
|
expect(command.waiting).toBe(false)
|
|
389
401
|
expect(Exit.isFailure(AsyncResult.toExit(command.result))).toBe(true)
|
|
390
402
|
expect(toasts.length).toBe(1) // toast should show error
|
|
391
|
-
expect(toasts[0].
|
|
403
|
+
expect(toasts[0].type).toBe("warning")
|
|
404
|
+
expect(toasts[0].message).toContain("Test Action Failed:\nBoom!")
|
|
405
|
+
expect(toasts[0].message).toMatch(/Trace: [a-f0-9]{32}/)
|
|
406
|
+
expect(toasts[0].message).toMatch(/Span: [a-f0-9]{16}/)
|
|
392
407
|
}))
|
|
393
408
|
|
|
409
|
+
it.live("fail with showSpanInfo disabled", () =>
|
|
410
|
+
Effect
|
|
411
|
+
.gen(function*() {
|
|
412
|
+
const toasts: any[] = []
|
|
413
|
+
const Command = useExperimental({ toasts, messages: DefaultIntl.en })
|
|
414
|
+
|
|
415
|
+
const command = Command.fn("Test Action")(
|
|
416
|
+
function*() {
|
|
417
|
+
return yield* Effect.fail({ message: "Boom!" })
|
|
418
|
+
},
|
|
419
|
+
Command.withDefaultToast({ showSpanInfo: false })
|
|
420
|
+
)
|
|
421
|
+
|
|
422
|
+
yield* Fiber.join(command.handle())
|
|
423
|
+
|
|
424
|
+
expect(toasts.length).toBe(1)
|
|
425
|
+
expect(toasts[0].message).toBe("Test Action Failed:\nBoom!")
|
|
426
|
+
}))
|
|
394
427
|
it.live("fail and recover", () =>
|
|
395
428
|
Effect
|
|
396
429
|
.gen(function*() {
|
|
@@ -444,7 +477,8 @@ it.live("defect", () =>
|
|
|
444
477
|
expect(command.waiting).toBe(false)
|
|
445
478
|
expect(Exit.isFailure(AsyncResult.toExit(command.result))).toBe(true)
|
|
446
479
|
expect(toasts.length).toBe(1) // toast should show error
|
|
447
|
-
expect(toasts[0].
|
|
480
|
+
expect(toasts[0].type).toBe("error")
|
|
481
|
+
expect(toasts[0].message).toContain("Test Action unexpected error, please try again shortly.")
|
|
448
482
|
}))
|
|
449
483
|
|
|
450
484
|
it.live("works with alt", () =>
|
|
@@ -471,7 +505,10 @@ it.live("works with alt", () =>
|
|
|
471
505
|
expect(yield* Effect.currentSpan.pipe(Effect.map((_) => _.name))).toBe("Test Action")
|
|
472
506
|
})),
|
|
473
507
|
Effect.tap(() =>
|
|
474
|
-
Effect.currentSpan.pipe(
|
|
508
|
+
Effect.currentSpan.pipe(
|
|
509
|
+
Effect.map((_) => _.name),
|
|
510
|
+
Effect.tap((_) => Effect.sync(() => expect(_).toBe("Test Action")))
|
|
511
|
+
)
|
|
475
512
|
),
|
|
476
513
|
Effect.tap(() => Effect.sync(() => executed = true))
|
|
477
514
|
)
|
|
@@ -624,7 +661,10 @@ it.live("with toasts with alt", () =>
|
|
|
624
661
|
expect(yield* Effect.currentSpan.pipe(Effect.map((_) => _.name))).toBe("Test Action")
|
|
625
662
|
})),
|
|
626
663
|
Effect.tap(() =>
|
|
627
|
-
Effect.currentSpan.pipe(
|
|
664
|
+
Effect.currentSpan.pipe(
|
|
665
|
+
Effect.map((_) => _.name),
|
|
666
|
+
Effect.tap((_) => Effect.sync(() => expect(_).toBe("Test Action")))
|
|
667
|
+
)
|
|
628
668
|
),
|
|
629
669
|
Command.withDefaultToast(),
|
|
630
670
|
Effect.tap(() => Effect.sync(() => executed = true))
|
|
@@ -696,7 +736,8 @@ it.live("fail with alt", () =>
|
|
|
696
736
|
expect(command.waiting).toBe(false)
|
|
697
737
|
expect(Exit.isFailure(AsyncResult.toExit(command.result))).toBe(true)
|
|
698
738
|
expect(toasts.length).toBe(1) // toast should show error
|
|
699
|
-
expect(toasts[0].
|
|
739
|
+
expect(toasts[0].type).toBe("warning")
|
|
740
|
+
expect(toasts[0].message).toContain("Test Action Failed:\nBoom!")
|
|
700
741
|
}))
|
|
701
742
|
|
|
702
743
|
it.live("fail and recover with alt", () =>
|
|
@@ -756,5 +797,58 @@ it.live("defect with alt", () =>
|
|
|
756
797
|
expect(command.waiting).toBe(false)
|
|
757
798
|
expect(Exit.isFailure(AsyncResult.toExit(command.result))).toBe(true)
|
|
758
799
|
expect(toasts.length).toBe(1) // toast should show error
|
|
759
|
-
expect(toasts[0].
|
|
800
|
+
expect(toasts[0].type).toBe("error")
|
|
801
|
+
expect(toasts[0].message).toContain("Test Action unexpected error, please try again shortly.")
|
|
760
802
|
}))
|
|
803
|
+
|
|
804
|
+
describe("state-in-toast", () => {
|
|
805
|
+
it("works", () => {
|
|
806
|
+
const toasts: any[] = []
|
|
807
|
+
const removeMutation = Object.assign(
|
|
808
|
+
Effect.fn(function*(_item: string) {
|
|
809
|
+
yield* Effect.sleep(1000)
|
|
810
|
+
}),
|
|
811
|
+
{ id: "remove_thing" }
|
|
812
|
+
)
|
|
813
|
+
|
|
814
|
+
const item = "x"
|
|
815
|
+
|
|
816
|
+
const Command = useExperimental({ toasts, messages: DefaultIntl.en })
|
|
817
|
+
|
|
818
|
+
Command.fn(removeMutation, {
|
|
819
|
+
state: () => ({ item }),
|
|
820
|
+
waitKey: (id) => `${id}.${item}`,
|
|
821
|
+
blockKey: () => `modify_thing.${item}`
|
|
822
|
+
// allowed: () => role.value === "admin"
|
|
823
|
+
})(
|
|
824
|
+
function*() {
|
|
825
|
+
// yield* Command.confirmOrInterrupt(yield* I18n.formatMessage({ id: "confirm.remove_item" }, { item }))
|
|
826
|
+
yield* removeMutation(item)
|
|
827
|
+
},
|
|
828
|
+
Command.withDefaultToast({
|
|
829
|
+
onSuccess: (a, b, c, d) => {
|
|
830
|
+
console.log("Success", { a, b, c, d })
|
|
831
|
+
expectTypeOf(d.state).toEqualTypeOf<{ readonly item: "x" }>()
|
|
832
|
+
}
|
|
833
|
+
})
|
|
834
|
+
)
|
|
835
|
+
|
|
836
|
+
Command.fn(removeMutation, {
|
|
837
|
+
state: () => ({ item }),
|
|
838
|
+
waitKey: (id) => `${id}.${item}`,
|
|
839
|
+
blockKey: () => `modify_thing.${item}`
|
|
840
|
+
// allowed: () => role.value === "admin"
|
|
841
|
+
})(
|
|
842
|
+
function*() {
|
|
843
|
+
// yield* Command.confirmOrInterrupt(yield* I18n.formatMessage({ id: "confirm.remove_item" }, { item }))
|
|
844
|
+
yield* removeMutation(item)
|
|
845
|
+
},
|
|
846
|
+
Command.withDefaultToast({
|
|
847
|
+
onSuccess: (a, b, c) => {
|
|
848
|
+
console.log("Success", { a, b, c })
|
|
849
|
+
expectTypeOf(c).toEqualTypeOf<undefined>()
|
|
850
|
+
}
|
|
851
|
+
})
|
|
852
|
+
)
|
|
853
|
+
})
|
|
854
|
+
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form.test.d.ts","sourceRoot":"","sources":["../form.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,CAAC,EAAE,MAAM,YAAY,CAAA
|
|
1
|
+
{"version":3,"file":"form.test.d.ts","sourceRoot":"","sources":["../form.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,CAAC,EAAE,MAAM,YAAY,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGtC,qBAAa,YAAa,SAAQ,iBAahC;CAAG;;;;AAEL,qBAAa,mBAAoB,SAAQ,wBAEvC;CAAG;;;;;;;;;;;;AAEL,qBAAa,WAAY,SAAQ,gBAK/B;CAAG;;;;;;;;;;;;;;;;;;;;;;;;AAEL,cAAM,MAAO,SAAQ,WAEnB;CAAG;;;;;;;;;;;;;;;;;;;;;;;;AAEL,cAAM,MAAO,SAAQ,WAEnB;CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEL,cAAM,QAAS,SAAQ,aAGrB;CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqBL,qBAAa,cAAe,SAAQ,mBAGlC;CAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lib.test.d.ts","sourceRoot":"","sources":["../lib.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streamFinal.test.d.ts","sourceRoot":"","sources":["../streamFinal.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streamFn.test.d.ts","sourceRoot":"","sources":["../streamFn.test.ts"],"names":[],"mappings":""}
|