@effect-app/vue 4.0.0-beta.26 → 4.0.0-beta.260
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 +1923 -0
- package/dist/commander.d.ts +634 -0
- package/dist/commander.d.ts.map +1 -0
- package/dist/commander.js +1070 -0
- package/dist/confirm.d.ts +21 -0
- package/dist/confirm.d.ts.map +1 -0
- package/dist/confirm.js +26 -0
- package/dist/errorReporter.d.ts +7 -5
- package/dist/errorReporter.d.ts.map +1 -1
- package/dist/errorReporter.js +14 -19
- package/dist/form.d.ts +15 -6
- package/dist/form.d.ts.map +1 -1
- package/dist/form.js +46 -13
- 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 +8 -10
- package/dist/lib.d.ts.map +1 -1
- package/dist/lib.js +35 -10
- package/dist/makeClient.d.ts +157 -343
- package/dist/makeClient.d.ts.map +1 -1
- package/dist/makeClient.js +216 -376
- 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 +9 -0
- package/dist/makeUseCommand.d.ts.map +1 -0
- package/dist/makeUseCommand.js +13 -0
- package/dist/mutate.d.ts +97 -39
- package/dist/mutate.d.ts.map +1 -1
- package/dist/mutate.js +177 -49
- package/dist/query.d.ts +24 -39
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +156 -78
- package/dist/routeParams.d.ts +5 -5
- package/dist/routeParams.d.ts.map +1 -1
- package/dist/routeParams.js +4 -3
- package/dist/runtime.d.ts +2 -15
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +2 -26
- package/dist/toast.d.ts +2 -0
- package/dist/toast.d.ts.map +1 -0
- package/dist/toast.js +2 -0
- package/dist/withToast.d.ts +2 -0
- package/dist/withToast.d.ts.map +1 -0
- package/dist/withToast.js +2 -0
- package/examples/streamMutation.ts +72 -0
- package/package.json +29 -90
- package/src/commander.ts +3406 -0
- package/src/{experimental/confirm.ts → confirm.ts} +12 -14
- package/src/errorReporter.ts +65 -75
- package/src/form.ts +61 -18
- package/src/intl.ts +12 -0
- package/src/lib.ts +48 -20
- package/src/makeClient.ts +581 -1138
- package/src/{experimental/makeUseCommand.ts → makeUseCommand.ts} +8 -5
- package/src/mutate.ts +335 -134
- package/src/query.ts +241 -183
- package/src/routeParams.ts +7 -7
- package/src/runtime.ts +1 -31
- package/src/toast.ts +1 -0
- package/src/withToast.ts +1 -0
- package/test/Mutation.test.ts +181 -24
- 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 +3527 -122
- package/test/dist/stubs.d.ts.map +1 -1
- package/test/dist/stubs.js +187 -32
- package/test/form-validation-errors.test.ts +25 -20
- package/test/form.test.ts +22 -3
- package/test/lib.test.ts +240 -0
- package/test/makeClient.test.ts +327 -38
- package/test/streamFinal.test.ts +64 -0
- package/test/streamFn.test.ts +457 -0
- package/test/stubs.ts +223 -43
- package/tsconfig.examples.json +20 -0
- package/tsconfig.json +2 -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/eslint.config.mjs +0 -24
- package/src/experimental/commander.ts +0 -1835
- package/src/experimental/intl.ts +0 -9
- package/src/experimental/toast.ts +0 -66
- package/src/experimental/withToast.ts +0 -99
package/src/experimental/intl.ts
DELETED
|
@@ -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
|
-
}
|