@effect-app/vue 4.0.0-beta.33 → 4.0.0-beta.331
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 +2463 -0
- package/dist/atomQuery.d.ts +120 -0
- package/dist/atomQuery.d.ts.map +1 -0
- package/dist/atomQuery.js +434 -0
- package/dist/commander.d.ts +634 -0
- package/dist/commander.d.ts.map +1 -0
- package/dist/commander.js +1068 -0
- package/dist/{experimental/confirm.d.ts → confirm.d.ts} +6 -4
- package/dist/confirm.d.ts.map +1 -0
- package/dist/confirm.js +26 -0
- package/dist/dependencyMetadata.d.ts +18 -0
- package/dist/dependencyMetadata.d.ts.map +1 -0
- package/dist/dependencyMetadata.js +67 -0
- package/dist/errorReporter.d.ts +6 -4
- package/dist/errorReporter.d.ts.map +1 -1
- package/dist/errorReporter.js +14 -19
- package/dist/form.d.ts +5 -5
- package/dist/form.d.ts.map +1 -1
- package/dist/form.js +42 -16
- package/dist/internal/tanstackQuery.d.ts +9 -0
- package/dist/internal/tanstackQuery.d.ts.map +1 -0
- package/dist/internal/tanstackQuery.js +204 -0
- 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 +7 -9
- package/dist/lib.d.ts.map +1 -1
- package/dist/lib.js +35 -10
- package/dist/liveQueryInvalidation.d.ts +16 -0
- package/dist/liveQueryInvalidation.d.ts.map +1 -0
- package/dist/liveQueryInvalidation.js +115 -0
- package/dist/makeClient.d.ts +236 -336
- package/dist/makeClient.d.ts.map +1 -1
- package/dist/makeClient.js +417 -408
- package/dist/makeContext.d.ts.map +1 -1
- package/dist/makeIntl.d.ts.map +1 -1
- package/dist/{experimental/makeUseCommand.d.ts → makeUseCommand.d.ts} +4 -3
- package/dist/makeUseCommand.d.ts.map +1 -0
- package/dist/makeUseCommand.js +13 -0
- package/dist/mutate.d.ts +109 -40
- package/dist/mutate.d.ts.map +1 -1
- package/dist/mutate.js +235 -58
- package/dist/query.d.ts +158 -45
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +380 -122
- package/dist/queryLifetime.d.ts +25 -0
- package/dist/queryLifetime.d.ts.map +1 -0
- package/dist/queryLifetime.js +54 -0
- package/dist/routeParams.d.ts +4 -4
- package/dist/routeParams.d.ts.map +1 -1
- package/dist/routeParams.js +4 -3
- package/dist/runtime.d.ts +1 -14
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +2 -26
- package/dist/suspense.d.ts +19 -0
- package/dist/suspense.d.ts.map +1 -0
- package/dist/suspense.js +38 -0
- 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/docs/atom-query-api-redesign.md +207 -0
- package/docs/mutation-command-atoms.md +40 -0
- package/docs/query-key-invalidation.md +107 -0
- package/examples/streamMutation.ts +72 -0
- package/package.json +36 -95
- package/src/atomQuery.ts +600 -0
- package/src/commander.ts +3408 -0
- package/src/{experimental/confirm.ts → confirm.ts} +13 -15
- package/src/dependencyMetadata.ts +84 -0
- package/src/errorReporter.ts +65 -75
- package/src/form.ts +57 -21
- package/src/index.ts +7 -7
- package/src/internal/tanstackQuery.ts +308 -0
- package/src/intl.ts +12 -0
- package/src/lib.ts +49 -21
- package/src/liveQueryInvalidation.ts +138 -0
- package/src/makeClient.ts +971 -1159
- package/src/makeIntl.ts +2 -2
- package/src/{experimental/makeUseCommand.ts → makeUseCommand.ts} +9 -6
- package/src/mutate.ts +406 -153
- package/src/query.ts +763 -260
- package/src/queryLifetime.ts +74 -0
- package/src/routeParams.ts +7 -7
- package/src/runtime.ts +1 -31
- package/src/suspense.ts +43 -0
- package/src/toast.ts +1 -0
- package/src/withToast.ts +1 -0
- package/test/Mutation.test.ts +181 -24
- package/test/dependencyInvalidation.test.ts +444 -0
- package/test/dist/dependencyInvalidation.test.d.ts.map +1 -0
- package/test/dist/form.test.d.ts.map +1 -1
- package/test/dist/inactiveInvalidation.test.d.ts.map +1 -0
- package/test/dist/interrupt-refetch-repro.test.d.ts.map +1 -0
- package/test/dist/lib.test.d.ts.map +1 -0
- package/test/dist/liveQueryInvalidation.test.d.ts.map +1 -0
- package/test/dist/query-span.test.d.ts.map +1 -0
- package/test/dist/queryOptions.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 +3751 -120
- package/test/dist/stubs.d.ts.map +1 -1
- package/test/dist/stubs.js +190 -30
- package/test/dist/suspense-regression.test.d.ts.map +1 -0
- package/test/dist/suspense.test.d.ts.map +1 -0
- package/test/form-validation-errors.test.ts +24 -19
- package/test/form.test.ts +25 -6
- package/test/inactiveInvalidation.test.ts +172 -0
- package/test/interrupt-refetch-repro.test.ts +625 -0
- package/test/lib.test.ts +240 -0
- package/test/liveQueryInvalidation.test.ts +108 -0
- package/test/makeClient.test.ts +437 -38
- package/test/query-span.test.ts +92 -0
- package/test/queryOptions.test.ts +88 -0
- package/test/streamFinal.test.ts +64 -0
- package/test/streamFn.test.ts +457 -0
- package/test/stubs.ts +227 -42
- package/test/suspense-regression.test.ts +168 -0
- package/test/suspense.test.ts +160 -0
- package/tsconfig.examples.json +20 -0
- package/tsconfig.json +9 -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.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.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/tsconfig.json.bak +0 -12
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
|
-
}
|