@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.
Files changed (103) hide show
  1. package/CHANGELOG.md +1383 -0
  2. package/dist/commander.d.ts +620 -0
  3. package/dist/commander.d.ts.map +1 -0
  4. package/dist/commander.js +1056 -0
  5. package/dist/confirm.d.ts +19 -0
  6. package/dist/confirm.d.ts.map +1 -0
  7. package/dist/confirm.js +24 -0
  8. package/dist/errorReporter.d.ts +4 -4
  9. package/dist/errorReporter.d.ts.map +1 -1
  10. package/dist/errorReporter.js +12 -18
  11. package/dist/form.d.ts +13 -4
  12. package/dist/form.d.ts.map +1 -1
  13. package/dist/form.js +41 -12
  14. package/dist/index.d.ts +1 -1
  15. package/dist/intl.d.ts +15 -0
  16. package/dist/intl.d.ts.map +1 -0
  17. package/dist/intl.js +9 -0
  18. package/dist/lib.d.ts +6 -8
  19. package/dist/lib.d.ts.map +1 -1
  20. package/dist/lib.js +34 -7
  21. package/dist/makeClient.d.ts +191 -292
  22. package/dist/makeClient.d.ts.map +1 -1
  23. package/dist/makeClient.js +217 -369
  24. package/dist/makeContext.d.ts +1 -1
  25. package/dist/makeContext.d.ts.map +1 -1
  26. package/dist/makeIntl.d.ts +1 -1
  27. package/dist/makeIntl.d.ts.map +1 -1
  28. package/dist/makeUseCommand.d.ts +8 -0
  29. package/dist/makeUseCommand.d.ts.map +1 -0
  30. package/dist/makeUseCommand.js +13 -0
  31. package/dist/mutate.d.ts +56 -25
  32. package/dist/mutate.d.ts.map +1 -1
  33. package/dist/mutate.js +132 -33
  34. package/dist/query.d.ts +24 -16
  35. package/dist/query.d.ts.map +1 -1
  36. package/dist/query.js +119 -37
  37. package/dist/routeParams.d.ts +1 -1
  38. package/dist/runtime.d.ts +5 -2
  39. package/dist/runtime.d.ts.map +1 -1
  40. package/dist/runtime.js +27 -17
  41. package/dist/toast.d.ts +46 -0
  42. package/dist/toast.d.ts.map +1 -0
  43. package/dist/toast.js +32 -0
  44. package/dist/withToast.d.ts +26 -0
  45. package/dist/withToast.d.ts.map +1 -0
  46. package/dist/withToast.js +54 -0
  47. package/eslint.config.mjs +2 -2
  48. package/examples/streamMutation.ts +70 -0
  49. package/package.json +48 -48
  50. package/src/commander.ts +3378 -0
  51. package/src/{experimental/confirm.ts → confirm.ts} +10 -14
  52. package/src/errorReporter.ts +62 -74
  53. package/src/form.ts +55 -16
  54. package/src/intl.ts +12 -0
  55. package/src/lib.ts +46 -13
  56. package/src/makeClient.ts +623 -1043
  57. package/src/{experimental/makeUseCommand.ts → makeUseCommand.ts} +6 -4
  58. package/src/mutate.ts +273 -72
  59. package/src/query.ts +181 -68
  60. package/src/runtime.ts +39 -18
  61. package/src/{experimental/toast.ts → toast.ts} +11 -25
  62. package/src/{experimental/withToast.ts → withToast.ts} +28 -10
  63. package/test/Mutation.test.ts +105 -11
  64. package/test/dist/form.test.d.ts.map +1 -1
  65. package/test/dist/lib.test.d.ts.map +1 -0
  66. package/test/dist/streamFinal.test.d.ts.map +1 -0
  67. package/test/dist/streamFn.test.d.ts.map +1 -0
  68. package/test/dist/stubs.d.ts +3289 -114
  69. package/test/dist/stubs.d.ts.map +1 -1
  70. package/test/dist/stubs.js +152 -25
  71. package/test/form-validation-errors.test.ts +23 -19
  72. package/test/form.test.ts +20 -2
  73. package/test/lib.test.ts +240 -0
  74. package/test/makeClient.test.ts +286 -38
  75. package/test/streamFinal.test.ts +63 -0
  76. package/test/streamFn.test.ts +436 -0
  77. package/test/stubs.ts +192 -42
  78. package/tsconfig.examples.json +20 -0
  79. package/tsconfig.json +0 -1
  80. package/tsconfig.json.bak +5 -2
  81. package/tsconfig.src.json +34 -34
  82. package/tsconfig.test.json +2 -2
  83. package/vitest.config.ts +5 -5
  84. package/dist/experimental/commander.d.ts +0 -359
  85. package/dist/experimental/commander.d.ts.map +0 -1
  86. package/dist/experimental/commander.js +0 -557
  87. package/dist/experimental/confirm.d.ts +0 -19
  88. package/dist/experimental/confirm.d.ts.map +0 -1
  89. package/dist/experimental/confirm.js +0 -28
  90. package/dist/experimental/intl.d.ts +0 -16
  91. package/dist/experimental/intl.d.ts.map +0 -1
  92. package/dist/experimental/intl.js +0 -5
  93. package/dist/experimental/makeUseCommand.d.ts +0 -8
  94. package/dist/experimental/makeUseCommand.d.ts.map +0 -1
  95. package/dist/experimental/makeUseCommand.js +0 -13
  96. package/dist/experimental/toast.d.ts +0 -47
  97. package/dist/experimental/toast.d.ts.map +0 -1
  98. package/dist/experimental/toast.js +0 -41
  99. package/dist/experimental/withToast.d.ts +0 -25
  100. package/dist/experimental/withToast.d.ts.map +0 -1
  101. package/dist/experimental/withToast.js +0 -45
  102. package/src/experimental/commander.ts +0 -1835
  103. package/src/experimental/intl.ts +0 -9
@@ -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/experimental/commander.js"
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(Effect.map((_) => _.name), Effect.tap((_) => Effect.sync(() => expect(_).toBe("Test Action"))))
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(Effect.map((_) => _.name), Effect.tap((_) => Effect.sync(() => expect(_).toBe("Test Action"))))
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(Effect.map((_) => _.name), Effect.tap((_) => Effect.sync(() => expect(_).toBe("Test Action"))))
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(Effect.map((_) => _.name), Effect.tap((_) => Effect.sync(() => expect(_).toBe("Test Action"))))
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].message).toBe("Test Action Failed:\nBoom!")
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].message).toBe("Test Action unexpected error, please try again shortly.")
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(Effect.map((_) => _.name), Effect.tap((_) => Effect.sync(() => expect(_).toBe("Test Action"))))
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(Effect.map((_) => _.name), Effect.tap((_) => Effect.sync(() => expect(_).toBe("Test Action"))))
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].message).toBe("Test Action Failed:\nBoom!")
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].message).toBe("Test Action unexpected error, please try again shortly.")
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;;;;;;;;;;;;;;;;;AAGtC,qBAAa,YAAa,SAAQ,iBAShC;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"}
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":""}