@effect-app/vue 4.0.0-beta.2 → 4.0.0-beta.20
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 +132 -0
- package/dist/experimental/commander.d.ts +1 -1
- package/dist/experimental/commander.d.ts.map +1 -1
- package/dist/experimental/commander.js +4 -5
- package/dist/makeClient.d.ts +2 -2
- package/dist/makeClient.d.ts.map +1 -1
- package/dist/makeClient.js +2 -2
- package/dist/mutate.d.ts +1 -1
- package/dist/mutate.d.ts.map +1 -1
- package/dist/mutate.js +2 -2
- package/dist/query.d.ts +1 -1
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +13 -2
- package/package.json +8 -8
- package/src/experimental/commander.ts +4 -5
- package/src/makeClient.ts +1 -1
- package/src/mutate.ts +1 -1
- package/src/query.ts +13 -1
- package/test/dist/stubs.d.ts +17 -17
package/src/query.ts
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
|
3
3
|
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
4
4
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
5
|
-
import * as AsyncResult from "effect/unstable/reactivity/AsyncResult"
|
|
6
5
|
import { type DefaultError, type Enabled, type InitialDataFunction, type NonUndefinedGuard, type PlaceholderDataFunction, type QueryKey, type QueryObserverOptions, type QueryObserverResult, type RefetchOptions, useQuery as useTanstackQuery, useQueryClient, type UseQueryDefinedReturnType, type UseQueryReturnType } from "@tanstack/vue-query"
|
|
7
6
|
import { Array, Cause, Effect, Exit, flow, Option, S, type ServiceMap } from "effect-app"
|
|
8
7
|
import { type Req } from "effect-app/client"
|
|
@@ -10,6 +9,7 @@ import type { RequestHandler, RequestHandlerWithInput } from "effect-app/client/
|
|
|
10
9
|
import { ServiceUnavailableError } from "effect-app/client/errors"
|
|
11
10
|
import { type Span } from "effect/Tracer"
|
|
12
11
|
import { isHttpClientError } from "effect/unstable/http/HttpClientError"
|
|
12
|
+
import * as AsyncResult from "effect/unstable/reactivity/AsyncResult"
|
|
13
13
|
import { computed, type ComputedRef, type MaybeRefOrGetter, ref, shallowRef, watch, type WatchSource } from "vue"
|
|
14
14
|
import { makeQueryKey, reportRuntimeError } from "./lib.js"
|
|
15
15
|
|
|
@@ -151,9 +151,20 @@ export const makeQuery = <R>(getRuntime: () => ServiceMap.ServiceMap<R>) => {
|
|
|
151
151
|
const queryKey = makeQueryKey(q)
|
|
152
152
|
const handler = q.handler
|
|
153
153
|
|
|
154
|
+
const defaultOptions = {
|
|
155
|
+
// we do not want to throw errors, because we turn the success and error responses into a Result type
|
|
156
|
+
// why don't we turn the error/success response into a Result type before returning to tanstack query? because we want to leverage tanstack query's retry and caching mechanism, which relies on throwing errors to trigger retries, and we don't want to interfere with that by catching the errors too early.
|
|
157
|
+
// but if we allow tanstack query to throw, it will trigger the error boundary in Vue - via a "watcher callback" error - which we currently report and log, which is not what we want.
|
|
158
|
+
// TODO: we might want to rethink the strategy of how to handle errors that happen after the initial load.
|
|
159
|
+
// For suspense, the initial load is captured by the suspense boundary.
|
|
160
|
+
// For subsequent loads (or non suspense use) we currently are required to use the QueryResult component to conditionally render error/loading/etc.
|
|
161
|
+
throwOnError: false
|
|
162
|
+
}
|
|
163
|
+
|
|
154
164
|
const r = useTanstackQuery<A, KnownFiberFailure<E>, TData>(
|
|
155
165
|
Effect.isEffect(handler)
|
|
156
166
|
? {
|
|
167
|
+
...defaultOptions,
|
|
157
168
|
...options,
|
|
158
169
|
retry: (retryCount, error) => {
|
|
159
170
|
if (error instanceof KnownFiberFailure) {
|
|
@@ -177,6 +188,7 @@ export const makeQuery = <R>(getRuntime: () => ServiceMap.ServiceMap<R>) => {
|
|
|
177
188
|
)
|
|
178
189
|
}
|
|
179
190
|
: {
|
|
191
|
+
...defaultOptions,
|
|
180
192
|
...options,
|
|
181
193
|
retry: (retryCount, error) => {
|
|
182
194
|
if (error instanceof KnownFiberFailure) {
|
package/test/dist/stubs.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ export declare const fakeIntlLayer: (messages?: Record<string, string> | Record<
|
|
|
13
13
|
export declare const useExperimental: (options?: {
|
|
14
14
|
messages?: Record<string, string> | Record<string, MessageFormatElement[]>;
|
|
15
15
|
toasts: any[];
|
|
16
|
-
}) => import("../src/experimental/makeUseCommand.js").CommanderResolved<
|
|
16
|
+
}) => import("../src/experimental/makeUseCommand.js").CommanderResolved<I18n | WithToast | Toast.Toast, never>;
|
|
17
17
|
declare const RequestContextMap_base: (new () => {
|
|
18
18
|
readonly config: {};
|
|
19
19
|
}) & {
|
|
@@ -36,11 +36,11 @@ export declare const Req: <_Self>() => {
|
|
|
36
36
|
readonly success: C["success"] extends infer T ? T extends C["success"] ? T extends S.Top ? T : T extends S.Struct.Fields ? S.Struct<T> : S.Void : never : never;
|
|
37
37
|
readonly error: C extends {
|
|
38
38
|
error: infer E;
|
|
39
|
-
} ? E extends S.Top ? E : E extends S.Struct.Fields ? S.Struct<E> : S.Void :
|
|
39
|
+
} ? E extends S.Top ? E : E extends S.Struct.Fields ? S.Struct<E> : S.Void : never;
|
|
40
40
|
readonly config: Omit<C, "success" | "error">;
|
|
41
41
|
readonly "~decodingServices": S.Codec.DecodingServices<C["success"] extends infer T_1 ? T_1 extends C["success"] ? T_1 extends S.Top ? T_1 : T_1 extends S.Struct.Fields ? S.Struct<T_1> : S.Void : never : never> | S.Codec.DecodingServices<C extends {
|
|
42
42
|
error: infer E;
|
|
43
|
-
} ? E extends S.Top ? E : E extends S.Struct.Fields ? S.Struct<E> : S.Void :
|
|
43
|
+
} ? E extends S.Top ? E : E extends S.Struct.Fields ? S.Struct<E> : S.Void : never>;
|
|
44
44
|
};
|
|
45
45
|
<Tag extends string, Payload_1 extends S.Struct.Fields, C_1 extends Pick<{
|
|
46
46
|
success: S.Top | S.Struct.Fields;
|
|
@@ -54,11 +54,11 @@ export declare const Req: <_Self>() => {
|
|
|
54
54
|
readonly success: C_1["success"] extends infer T ? T extends C_1["success"] ? T extends S.Top ? T : T extends S.Struct.Fields ? S.Struct<T> : S.Void : never : never;
|
|
55
55
|
readonly error: C_1 extends {
|
|
56
56
|
error: infer E;
|
|
57
|
-
} ? E extends S.Top ? E : E extends S.Struct.Fields ? S.Struct<E> : S.Void :
|
|
57
|
+
} ? E extends S.Top ? E : E extends S.Struct.Fields ? S.Struct<E> : S.Void : never;
|
|
58
58
|
readonly config: Omit<C_1, "success" | "error">;
|
|
59
59
|
readonly "~decodingServices": S.Codec.DecodingServices<C_1["success"] extends infer T_1 ? T_1 extends C_1["success"] ? T_1 extends S.Top ? T_1 : T_1 extends S.Struct.Fields ? S.Struct<T_1> : S.Void : never : never> | S.Codec.DecodingServices<C_1 extends {
|
|
60
60
|
error: infer E;
|
|
61
|
-
} ? E extends S.Top ? E : E extends S.Struct.Fields ? S.Struct<E> : S.Void :
|
|
61
|
+
} ? E extends S.Top ? E : E extends S.Struct.Fields ? S.Struct<E> : S.Void : never>;
|
|
62
62
|
};
|
|
63
63
|
<Tag extends string, Payload_2 extends S.Struct.Fields, C_2 extends Pick<{
|
|
64
64
|
success: S.Top | S.Struct.Fields;
|
|
@@ -72,11 +72,11 @@ export declare const Req: <_Self>() => {
|
|
|
72
72
|
readonly success: S.Codec<void, void, never, never>;
|
|
73
73
|
readonly error: C_2 extends {
|
|
74
74
|
error: infer E;
|
|
75
|
-
} ? E extends S.Top ? E : E extends S.Struct.Fields ? S.Struct<E> : S.Void :
|
|
75
|
+
} ? E extends S.Top ? E : E extends S.Struct.Fields ? S.Struct<E> : S.Void : never;
|
|
76
76
|
readonly config: Omit<C_2, "success" | "error">;
|
|
77
77
|
readonly "~decodingServices": S.Codec.DecodingServices<C_2 extends {
|
|
78
78
|
error: infer E;
|
|
79
|
-
} ? E extends S.Top ? E : E extends S.Struct.Fields ? S.Struct<E> : S.Void :
|
|
79
|
+
} ? E extends S.Top ? E : E extends S.Struct.Fields ? S.Struct<E> : S.Void : never>;
|
|
80
80
|
};
|
|
81
81
|
<Tag extends string, Payload_3 extends S.Struct.Fields, C_3 extends Record<string, any>>(tag: Tag, fields: Payload_3, config: C_3 & RpcContextMap.GetContextConfig<{}>): S.TaggedStruct<Tag, Payload_3> & {
|
|
82
82
|
new (...args: any[]): any;
|
|
@@ -87,11 +87,11 @@ export declare const Req: <_Self>() => {
|
|
|
87
87
|
readonly success: S.Codec<void, void, never, never>;
|
|
88
88
|
readonly error: C_3 extends {
|
|
89
89
|
error: infer E;
|
|
90
|
-
} ? E extends S.Top ? E : E extends S.Struct.Fields ? S.Struct<E> : S.Void :
|
|
90
|
+
} ? E extends S.Top ? E : E extends S.Struct.Fields ? S.Struct<E> : S.Void : never;
|
|
91
91
|
readonly config: Omit<C_3, "success" | "error">;
|
|
92
92
|
readonly "~decodingServices": S.Codec.DecodingServices<C_3 extends {
|
|
93
93
|
error: infer E;
|
|
94
|
-
} ? E extends S.Top ? E : E extends S.Struct.Fields ? S.Struct<E> : S.Void :
|
|
94
|
+
} ? E extends S.Top ? E : E extends S.Struct.Fields ? S.Struct<E> : S.Void : never>;
|
|
95
95
|
};
|
|
96
96
|
<Tag extends string, Payload_4 extends S.Struct.Fields>(tag: Tag, fields: Payload_4): S.TaggedStruct<Tag, Payload_4> & {
|
|
97
97
|
new (...args: any[]): any;
|
|
@@ -116,7 +116,7 @@ declare const GetSomething2_base: S.TaggedStruct<"GetSomething2", {
|
|
|
116
116
|
id: S.String;
|
|
117
117
|
};
|
|
118
118
|
readonly success: S.NumberFromString;
|
|
119
|
-
readonly error:
|
|
119
|
+
readonly error: never;
|
|
120
120
|
readonly config: Omit<{
|
|
121
121
|
success: S.NumberFromString;
|
|
122
122
|
}, "success" | "error">;
|
|
@@ -155,14 +155,14 @@ export declare const useClient: (options?: {
|
|
|
155
155
|
messages?: Record<string, string> | Record<string, MessageFormatElement[]>;
|
|
156
156
|
toasts: any[];
|
|
157
157
|
}) => {
|
|
158
|
-
Command: import("../src/experimental/makeUseCommand.js").CommanderResolved<WithToast | (Commander | ApiClientFactory | LegacyMutation | (Toast.Toast
|
|
159
|
-
useCommand: () => import("../src/experimental/makeUseCommand.js").CommanderResolved<WithToast | (Commander | ApiClientFactory | LegacyMutation | (Toast.Toast
|
|
160
|
-
clientFor: <M extends import("effect-app/client").Requests>(m: M, queryInvalidation?: ((client: import("effect-app/client").RequestHandlers<never, never, M, M["meta"]["moduleName"]>) => import("../src/makeClient.js").QueryInvalidation<M>) | undefined) => { [Key in keyof import("effect-app/client").RequestHandlers<never, never, M, M["meta"]["moduleName"]>]: import("effect-app/client").RequestHandlers<never, never, M, M["meta"]["moduleName"]>[Key] & import("../src/makeClient.js").RequestWithExtensions<WithToast | (Commander | ApiClientFactory | LegacyMutation | (Toast.Toast
|
|
161
|
-
mutate: import("../src/makeClient.js").MutationWithExtensions<WithToast | (Commander | ApiClientFactory | LegacyMutation | (Toast.Toast
|
|
162
|
-
} & import("../src/makeClient.js").Queries<WithToast | (Commander | ApiClientFactory | LegacyMutation | (Toast.Toast
|
|
163
|
-
helpers: { [Key_1 in keyof import("effect-app/client").RequestHandlers<never, never, M, M["meta"]["moduleName"]> as `${import("../src/makeClient.js").ToCamel<string & Key_1>}Request`]: import("../src/makeClient.js").RequestWithExtensions<WithToast | (Commander | ApiClientFactory | LegacyMutation | (Toast.Toast
|
|
158
|
+
Command: import("../src/experimental/makeUseCommand.js").CommanderResolved<WithToast | (Commander | ApiClientFactory | LegacyMutation | (I18n | Toast.Toast)), never>;
|
|
159
|
+
useCommand: () => import("../src/experimental/makeUseCommand.js").CommanderResolved<WithToast | (Commander | ApiClientFactory | LegacyMutation | (I18n | Toast.Toast)), never>;
|
|
160
|
+
clientFor: <M extends import("effect-app/client").Requests>(m: M, queryInvalidation?: ((client: import("effect-app/client").RequestHandlers<never, never, M, M["meta"]["moduleName"]>) => import("../src/makeClient.js").QueryInvalidation<M>) | undefined) => { [Key in keyof import("effect-app/client").RequestHandlers<never, never, M, M["meta"]["moduleName"]>]: import("effect-app/client").RequestHandlers<never, never, M, M["meta"]["moduleName"]>[Key] & import("../src/makeClient.js").RequestWithExtensions<WithToast | (Commander | ApiClientFactory | LegacyMutation | (I18n | Toast.Toast)), import("effect-app/client").RequestHandlers<never, never, M, M["meta"]["moduleName"]>[Key]> & {
|
|
161
|
+
mutate: import("../src/makeClient.js").MutationWithExtensions<WithToast | (Commander | ApiClientFactory | LegacyMutation | (I18n | Toast.Toast)), import("effect-app/client").RequestHandlers<never, never, M, M["meta"]["moduleName"]>[Key]>;
|
|
162
|
+
} & import("../src/makeClient.js").Queries<WithToast | (Commander | ApiClientFactory | LegacyMutation | (I18n | Toast.Toast)), import("effect-app/client").RequestHandlers<never, never, M, M["meta"]["moduleName"]>[Key]>; } & {
|
|
163
|
+
helpers: { [Key_1 in keyof import("effect-app/client").RequestHandlers<never, never, M, M["meta"]["moduleName"]> as `${import("../src/makeClient.js").ToCamel<string & Key_1>}Request`]: import("../src/makeClient.js").RequestWithExtensions<WithToast | (Commander | ApiClientFactory | LegacyMutation | (I18n | Toast.Toast)), import("effect-app/client").RequestHandlers<never, never, M, M["meta"]["moduleName"]>[Key_1]>; } & { [Key_2 in keyof import("effect-app/client").RequestHandlers<never, never, M, M["meta"]["moduleName"]> as `${import("../src/makeClient.js").ToCamel<string & Key_2>}Mutation`]: import("../src/makeClient.js").MutationWithExtensions<WithToast | (Commander | ApiClientFactory | LegacyMutation | (I18n | Toast.Toast)), import("effect-app/client").RequestHandlers<never, never, M, M["meta"]["moduleName"]>[Key_2]>; } & { [Key_3 in keyof import("effect-app/client").RequestHandlers<never, never, M, M["meta"]["moduleName"]> as `${import("../src/makeClient.js").ToCamel<string & Key_3>}Query`]: import("../src/makeClient.js").Queries<WithToast | (Commander | ApiClientFactory | LegacyMutation | (I18n | Toast.Toast)), import("effect-app/client").RequestHandlers<never, never, M, M["meta"]["moduleName"]>[Key_3]>["query"]; } & { [Key_4 in keyof import("effect-app/client").RequestHandlers<never, never, M, M["meta"]["moduleName"]> as `${import("../src/makeClient.js").ToCamel<string & Key_4>}SuspenseQuery`]: import("../src/makeClient.js").Queries<WithToast | (Commander | ApiClientFactory | LegacyMutation | (I18n | Toast.Toast)), import("effect-app/client").RequestHandlers<never, never, M, M["meta"]["moduleName"]>[Key_4]>["suspense"]; };
|
|
164
164
|
};
|
|
165
|
-
legacy: import("../src/makeClient.js").Legacy<WithToast | (Commander | ApiClientFactory | LegacyMutation | (Toast.Toast
|
|
165
|
+
legacy: import("../src/makeClient.js").Legacy<WithToast | (Commander | ApiClientFactory | LegacyMutation | (I18n | Toast.Toast))>;
|
|
166
166
|
};
|
|
167
167
|
export {};
|
|
168
168
|
//# sourceMappingURL=stubs.d.ts.map
|