@effect-app/vue 4.0.0-beta.26 → 4.0.0-beta.261

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 (112) hide show
  1. package/CHANGELOG.md +1929 -0
  2. package/dist/commander.d.ts +634 -0
  3. package/dist/commander.d.ts.map +1 -0
  4. package/dist/commander.js +1070 -0
  5. package/dist/confirm.d.ts +21 -0
  6. package/dist/confirm.d.ts.map +1 -0
  7. package/dist/confirm.js +26 -0
  8. package/dist/dependencyMetadata.d.ts +8 -0
  9. package/dist/dependencyMetadata.d.ts.map +1 -0
  10. package/dist/dependencyMetadata.js +6 -0
  11. package/dist/errorReporter.d.ts +7 -5
  12. package/dist/errorReporter.d.ts.map +1 -1
  13. package/dist/errorReporter.js +14 -19
  14. package/dist/form.d.ts +15 -6
  15. package/dist/form.d.ts.map +1 -1
  16. package/dist/form.js +46 -13
  17. package/dist/index.d.ts +1 -1
  18. package/dist/intl.d.ts +15 -0
  19. package/dist/intl.d.ts.map +1 -0
  20. package/dist/intl.js +9 -0
  21. package/dist/lib.d.ts +8 -10
  22. package/dist/lib.d.ts.map +1 -1
  23. package/dist/lib.js +35 -10
  24. package/dist/makeClient.d.ts +157 -343
  25. package/dist/makeClient.d.ts.map +1 -1
  26. package/dist/makeClient.js +216 -376
  27. package/dist/makeContext.d.ts +1 -1
  28. package/dist/makeContext.d.ts.map +1 -1
  29. package/dist/makeIntl.d.ts +1 -1
  30. package/dist/makeIntl.d.ts.map +1 -1
  31. package/dist/makeUseCommand.d.ts +9 -0
  32. package/dist/makeUseCommand.d.ts.map +1 -0
  33. package/dist/makeUseCommand.js +13 -0
  34. package/dist/mutate.d.ts +97 -39
  35. package/dist/mutate.d.ts.map +1 -1
  36. package/dist/mutate.js +177 -49
  37. package/dist/query.d.ts +24 -39
  38. package/dist/query.d.ts.map +1 -1
  39. package/dist/query.js +156 -78
  40. package/dist/routeParams.d.ts +5 -5
  41. package/dist/routeParams.d.ts.map +1 -1
  42. package/dist/routeParams.js +4 -3
  43. package/dist/runtime.d.ts +2 -15
  44. package/dist/runtime.d.ts.map +1 -1
  45. package/dist/runtime.js +2 -26
  46. package/dist/toast.d.ts +2 -0
  47. package/dist/toast.d.ts.map +1 -0
  48. package/dist/toast.js +2 -0
  49. package/dist/withToast.d.ts +2 -0
  50. package/dist/withToast.d.ts.map +1 -0
  51. package/dist/withToast.js +2 -0
  52. package/examples/streamMutation.ts +72 -0
  53. package/package.json +29 -90
  54. package/src/commander.ts +3406 -0
  55. package/src/{experimental/confirm.ts → confirm.ts} +12 -14
  56. package/src/errorReporter.ts +65 -75
  57. package/src/form.ts +61 -18
  58. package/src/intl.ts +12 -0
  59. package/src/lib.ts +48 -20
  60. package/src/makeClient.ts +581 -1138
  61. package/src/{experimental/makeUseCommand.ts → makeUseCommand.ts} +8 -5
  62. package/src/mutate.ts +335 -134
  63. package/src/query.ts +241 -183
  64. package/src/routeParams.ts +7 -7
  65. package/src/runtime.ts +1 -31
  66. package/src/toast.ts +1 -0
  67. package/src/withToast.ts +1 -0
  68. package/test/Mutation.test.ts +181 -24
  69. package/test/dist/dependencyInvalidation.test.d.ts.map +1 -0
  70. package/test/dist/form.test.d.ts.map +1 -1
  71. package/test/dist/lib.test.d.ts.map +1 -0
  72. package/test/dist/streamFinal.test.d.ts.map +1 -0
  73. package/test/dist/streamFn.test.d.ts.map +1 -0
  74. package/test/dist/stubs.d.ts +3527 -122
  75. package/test/dist/stubs.d.ts.map +1 -1
  76. package/test/dist/stubs.js +187 -32
  77. package/test/form-validation-errors.test.ts +25 -20
  78. package/test/form.test.ts +22 -3
  79. package/test/lib.test.ts +240 -0
  80. package/test/makeClient.test.ts +327 -38
  81. package/test/streamFinal.test.ts +64 -0
  82. package/test/streamFn.test.ts +457 -0
  83. package/test/stubs.ts +223 -43
  84. package/tsconfig.examples.json +20 -0
  85. package/tsconfig.json +2 -1
  86. package/tsconfig.json.bak +5 -2
  87. package/tsconfig.src.json +34 -34
  88. package/tsconfig.test.json +2 -2
  89. package/vitest.config.ts +5 -5
  90. package/dist/experimental/commander.d.ts +0 -359
  91. package/dist/experimental/commander.d.ts.map +0 -1
  92. package/dist/experimental/commander.js +0 -557
  93. package/dist/experimental/confirm.d.ts +0 -19
  94. package/dist/experimental/confirm.d.ts.map +0 -1
  95. package/dist/experimental/confirm.js +0 -28
  96. package/dist/experimental/intl.d.ts +0 -16
  97. package/dist/experimental/intl.d.ts.map +0 -1
  98. package/dist/experimental/intl.js +0 -5
  99. package/dist/experimental/makeUseCommand.d.ts +0 -8
  100. package/dist/experimental/makeUseCommand.d.ts.map +0 -1
  101. package/dist/experimental/makeUseCommand.js +0 -13
  102. package/dist/experimental/toast.d.ts +0 -47
  103. package/dist/experimental/toast.d.ts.map +0 -1
  104. package/dist/experimental/toast.js +0 -41
  105. package/dist/experimental/withToast.d.ts +0 -25
  106. package/dist/experimental/withToast.d.ts.map +0 -1
  107. package/dist/experimental/withToast.js +0 -45
  108. package/eslint.config.mjs +0 -24
  109. package/src/experimental/commander.ts +0 -1835
  110. package/src/experimental/intl.ts +0 -9
  111. package/src/experimental/toast.ts +0 -66
  112. package/src/experimental/withToast.ts +0 -99
@@ -1,9 +0,0 @@
1
- import { ServiceMap } from "effect-app"
2
- import { proxify } from "effect-app/ServiceMap"
3
- import { type MakeIntlReturn } from "../makeIntl.js"
4
-
5
- export class I18n extends proxify(ServiceMap.Opaque<I18n, ReturnType<MakeIntlReturn<string>["useIntl"]>>()("I18n"))<
6
- I18n,
7
- ReturnType<MakeIntlReturn<string>["useIntl"]>
8
- >() {
9
- }
@@ -1,66 +0,0 @@
1
- import { Effect, Option, ServiceMap } from "effect-app"
2
- import { proxify } from "effect-app/ServiceMap"
3
-
4
- export type ToastId = string | number
5
- export type ToastOpts = { id?: ToastId; timeout?: number }
6
- export type ToastOptsInternal = { id?: ToastId | null; timeout?: number }
7
-
8
- export type UseToast = () => {
9
- error: (this: void, message: string, options?: ToastOpts) => ToastId
10
- warning: (this: void, message: string, options?: ToastOpts) => ToastId
11
- success: (this: void, message: string, options?: ToastOpts) => ToastId
12
- info: (this: void, message: string, options?: ToastOpts) => ToastId
13
- dismiss: (this: void, id: ToastId) => void
14
- }
15
-
16
- export class CurrentToastId extends ServiceMap.Opaque<CurrentToastId, { toastId: ToastId }>()("CurrentToastId") {}
17
-
18
- /** fallback to CurrentToastId when available unless id is explicitly set to a value or null */
19
- export const wrap = (toast: ReturnType<UseToast>) => {
20
- const wrap = (toastHandler: (message: string, options?: ToastOpts) => ToastId) => {
21
- return (message: string, options?: ToastOptsInternal) =>
22
- Effect.serviceOption(CurrentToastId).pipe(
23
- Effect.flatMap((currentToast) =>
24
- Effect.sync(() => {
25
- const { id: _id, ...rest } = options ?? {}
26
- const id = _id !== undefined
27
- ? _id ?? undefined
28
- : Option.getOrUndefined(Option.map(currentToast, (_) => _.toastId))
29
- // when id is undefined, we may end up with no toast at all..
30
- return toastHandler(message, id !== undefined ? { ...rest, id } : rest)
31
- })
32
- )
33
- )
34
- }
35
- return {
36
- error: wrap(toast.error),
37
- info: wrap(toast.info),
38
- success: wrap(toast.success),
39
- warning: wrap(toast.warning),
40
- dismiss: (toastId: ToastId) => Effect.sync(() => toast.dismiss(toastId))
41
- }
42
- }
43
-
44
- export class Toast
45
- extends proxify(ServiceMap.Opaque<Toast, ReturnType<typeof wrap>>()("Toast"))<Toast, ReturnType<typeof wrap>>()
46
- {
47
- }
48
-
49
- // const a = Layer.effect(Toast, Effect.sync(() => Toast.of(null as any)))
50
-
51
- // const A = Toast.of({
52
- // error: () => Effect.succeed(null as any),
53
- // info: () => Effect.succeed(null as any),
54
- // success: () => Effect.succeed(null as any),
55
- // warning: () => Effect.succeed(null as any),
56
- // dismiss: () => Effect.succeed(null as any)
57
- // })
58
-
59
- // const b = Toast.info("test")
60
-
61
- // const a2 = Toast.use((_) => _.error("test"))
62
-
63
- // const b2 = Effect.gen(function*() {
64
- // const toast = yield* Toast
65
- // toast.error("test")
66
- // })
@@ -1,99 +0,0 @@
1
- import { Cause, Effect, Layer, type Option, ServiceMap } from "effect-app"
2
- import { wrapEffect } from "effect-app/utils"
3
- import { CurrentToastId, Toast } from "./toast.js"
4
-
5
- export interface ToastOptions<A, E, Args extends ReadonlyArray<unknown>, WaiR, SucR, ErrR> {
6
- stableToastId?: undefined | string | ((...args: Args) => string | undefined)
7
- timeout?: number
8
- onWaiting:
9
- | string
10
- | ((...args: Args) => string | null)
11
- | null
12
- | ((
13
- ...args: Args
14
- ) => Effect.Effect<string | null, never, WaiR>)
15
- onSuccess:
16
- | string
17
- | ((a: A, ...args: Args) => string | null)
18
- | null
19
- | ((
20
- a: A,
21
- ...args: Args
22
- ) => Effect.Effect<string | null, never, SucR>)
23
- onFailure:
24
- | string
25
- | ((
26
- error: Option.Option<E>,
27
- ...args: Args
28
- ) => string | { level: "warn" | "error"; message: string })
29
- | ((
30
- error: Option.Option<E>,
31
- ...args: Args
32
- ) => Effect.Effect<string | { level: "warn" | "error"; message: string }, never, ErrR>)
33
- }
34
-
35
- // @effect-diagnostics-next-line missingEffectServiceDependency:off
36
- export class WithToast extends ServiceMap.Service<WithToast>()("WithToast", {
37
- make: Effect.gen(function*() {
38
- const toast = yield* Toast
39
- return <A, E, Args extends Array<unknown>, R, WaiR = never, SucR = never, ErrR = never>(
40
- options: ToastOptions<A, E, Args, WaiR, SucR, ErrR>
41
- ) =>
42
- Effect.fnUntraced(function*(self: Effect.Effect<A, E, R>, ...args: Args) {
43
- const baseTimeout = options.timeout ?? 3_000
44
-
45
- const stableToastId = typeof options.stableToastId === "function"
46
- ? options.stableToastId(...args)
47
- : options.stableToastId
48
-
49
- const t = yield* wrapEffect(options.onWaiting)(...args)
50
- const toastId = t === null ? stableToastId : yield* toast.info(
51
- t,
52
- { id: stableToastId ?? null } // TODO: timeout forever?
53
- )
54
- return yield* self.pipe(
55
- Effect.tap(Effect.fnUntraced(function*(a) {
56
- const t = yield* wrapEffect(options.onSuccess)(a, ...args)
57
- if (t === null) {
58
- return
59
- }
60
- yield* toast.success(
61
- t,
62
- toastId !== undefined ? { id: toastId, timeout: baseTimeout } : { timeout: baseTimeout }
63
- )
64
- })),
65
- Effect.tapCause(Effect.fnUntraced(function*(cause) {
66
- yield* Effect.logDebug(
67
- "WithToast - caught error cause: " + Cause.squash(cause),
68
- Cause.hasInterruptsOnly(cause),
69
- cause
70
- )
71
-
72
- if (Cause.hasInterruptsOnly(cause)) {
73
- if (toastId) yield* toast.dismiss(toastId)
74
- return
75
- }
76
-
77
- const t = yield* wrapEffect(options.onFailure)(Cause.findErrorOption(cause), ...args)
78
- const opts = { timeout: baseTimeout * 2 }
79
-
80
- if (typeof t === "object") {
81
- return t.level === "warn"
82
- ? yield* toast.warning(t.message, toastId !== undefined ? { ...opts, id: toastId } : opts)
83
- : yield* toast.error(t.message, toastId !== undefined ? { ...opts, id: toastId } : opts)
84
- }
85
- yield* toast.error(t, toastId !== undefined ? { ...opts, id: toastId } : opts)
86
- }, Effect.uninterruptible)),
87
- toastId !== undefined ? Effect.provideService(CurrentToastId, CurrentToastId.of({ toastId })) : (_) => _
88
- )
89
- })
90
- })
91
- }) {
92
- static readonly DefaultWithoutDependencies = Layer.effect(this, this.make)
93
- static readonly Default = this.DefaultWithoutDependencies
94
-
95
- static readonly handle = <A, E, Args extends Array<unknown>, R, WaiR = never, SucR = never, ErrR = never>(
96
- options: ToastOptions<A, E, Args, WaiR, SucR, ErrR>
97
- ): (self: Effect.Effect<A, E, R>, ...args: Args) => Effect.Effect<A, E, R | WaiR | SucR | ErrR | WithToast> =>
98
- (self, ...args) => this.use((_) => _<A, E, Args, R, WaiR, SucR, ErrR>(options)(self, ...args))
99
- }