@tiesen/effect-tanstack-query 0.0.6 → 0.0.8
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/README.md +53 -27
- package/dist/index.d.mts +13 -35
- package/dist/index.mjs +1 -1
- package/dist/react.d.mts +7 -0
- package/dist/react.mjs +1 -0
- package/dist/types-BGHsAv5y.d.mts +54 -0
- package/package.json +11 -5
package/README.md
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
# effect-tanstack-query
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<p align="center">
|
|
4
|
+
<a href="https://npmx.dev/package/@tiesen/effect-tanstack-query"><img src="https://img.shields.io/npm/dw/%40tiesen%2Feffect-tanstack-query" alt="Total Downloads"></a>
|
|
5
|
+
<a href="https://npmx.dev/package/@tiesen/effect-tanstack-query"><img src="https://img.shields.io/npm/v/%40tiesen%2Feffect-tanstack-query" alt="Latest Stable Version"></a>
|
|
6
|
+
<a href="https://npmx.dev/package/@tiesen/effect-tanstack-query"><img src="https://img.shields.io/npm/l/%40tiesen%2Feffect-tanstack-query" alt="License"></a>
|
|
7
|
+
</p>
|
|
8
|
+
|
|
9
|
+
Effortlessly bridge **Effect HTTP API clients** with **TanStack Query**. Enjoy end-to-end type safety, zero-boilerplate options (`queryOptions`, `mutationOptions`, `subscriptionOptions`), and built-in streaming support out of the box.
|
|
4
10
|
|
|
5
11
|
## Features
|
|
6
12
|
|
|
7
13
|
- **Seamless Integration**: Effortlessly map Effect `HttpApiClient` endpoints to TanStack Query config objects.
|
|
8
|
-
- **End-to-End Type Safety**: Automatically infers inputs (`params`, `query`, `
|
|
9
|
-
- **
|
|
10
|
-
- **
|
|
14
|
+
- **End-to-End Type Safety**: Automatically infers inputs (`params`, `query`, `payload`), response types, and error types directly from your Effect schemas.
|
|
15
|
+
- **Event Streaming Support**: Native handling for live streams and Server-Sent Events (SSE) via `subscriptionOptions` and `useSubscription`.
|
|
16
|
+
- **Zero Boilerplate**: Generates `queryKey`, and execution logic under the hood using ES6 Proxies.
|
|
17
|
+
- **Smart Developer Experience**: Auto-manages Fiber lifecycles and abort signals, with smart optional parameters when no inputs are required.
|
|
11
18
|
|
|
12
19
|
## Installation
|
|
13
20
|
|
|
@@ -15,16 +22,16 @@ Install using your preferred package manager:
|
|
|
15
22
|
|
|
16
23
|
```bash
|
|
17
24
|
# Using npm
|
|
18
|
-
npm install @tiesen/effect-tanstack-query
|
|
25
|
+
npm install @tiesen/effect-tanstack-query @tanstack/react-query effect@beta
|
|
19
26
|
|
|
20
27
|
# Using yarn
|
|
21
|
-
yarn add @tiesen/effect-tanstack-query
|
|
28
|
+
yarn add @tiesen/effect-tanstack-query @tanstack/react-query effect@beta
|
|
22
29
|
|
|
23
30
|
# Using bun
|
|
24
|
-
bun add @tiesen/effect-tanstack-query
|
|
31
|
+
bun add @tiesen/effect-tanstack-query @tanstack/react-query effect@beta
|
|
25
32
|
|
|
26
33
|
# Using pnpm
|
|
27
|
-
pnpm add @tiesen/effect-tanstack-query
|
|
34
|
+
pnpm add @tiesen/effect-tanstack-query @tanstack/react-query effect@beta
|
|
28
35
|
```
|
|
29
36
|
|
|
30
37
|
## Quick Start
|
|
@@ -33,9 +40,14 @@ pnpm add @tiesen/effect-tanstack-query
|
|
|
33
40
|
|
|
34
41
|
```ts
|
|
35
42
|
import { Schema } from 'effect'
|
|
36
|
-
import {
|
|
43
|
+
import {
|
|
44
|
+
HttpApi,
|
|
45
|
+
HttpApiEndpoint,
|
|
46
|
+
HttpApiGroup,
|
|
47
|
+
HttpApiSchema,
|
|
48
|
+
} from 'effect/unstable/httpapi'
|
|
37
49
|
|
|
38
|
-
class ApiGroup extends HttpApiGroup.make('
|
|
50
|
+
class ApiGroup extends HttpApiGroup.make('group')
|
|
39
51
|
.add(
|
|
40
52
|
HttpApiEndpoint.get('hello', '/hello/:name', {
|
|
41
53
|
success: Schema.String,
|
|
@@ -54,6 +66,13 @@ class ApiGroup extends HttpApiGroup.make('ApiGroup')
|
|
|
54
66
|
name: Schema.String,
|
|
55
67
|
}),
|
|
56
68
|
})
|
|
69
|
+
)
|
|
70
|
+
.add(
|
|
71
|
+
HttpApiEndpoint.get('stream', '/stream', {
|
|
72
|
+
success: HttpApiSchema.StreamSse({
|
|
73
|
+
data: Schema.String,
|
|
74
|
+
}),
|
|
75
|
+
})
|
|
57
76
|
) {}
|
|
58
77
|
|
|
59
78
|
export class Api extends HttpApi.make('Api').add(ApiGroup) {}
|
|
@@ -62,27 +81,18 @@ export class Api extends HttpApi.make('Api').add(ApiGroup) {}
|
|
|
62
81
|
### 2. Create an Effect HTTP API Client
|
|
63
82
|
|
|
64
83
|
```ts
|
|
65
|
-
import { Context,
|
|
66
|
-
import {
|
|
67
|
-
FetchHttpClient,
|
|
68
|
-
HttpClient,
|
|
69
|
-
HttpClientRequest,
|
|
70
|
-
} from 'effect/unstable/http'
|
|
84
|
+
import { Context, Layer } from 'effect'
|
|
85
|
+
import { FetchHttpClient } from 'effect/unstable/http'
|
|
71
86
|
import { HttpApiClient } from 'effect/unstable/httpapi'
|
|
72
87
|
|
|
73
88
|
class ApiClient extends Context.Service<
|
|
74
89
|
ApiClient,
|
|
75
90
|
HttpApiClient.ForApi<typeof Api>
|
|
76
91
|
>()('ApiClient') {
|
|
77
|
-
public static
|
|
92
|
+
public static layer = Layer.effect(
|
|
78
93
|
this,
|
|
79
94
|
HttpApiClient.make(Api, {
|
|
80
|
-
|
|
81
|
-
client.pipe(
|
|
82
|
-
HttpClient.mapRequest(
|
|
83
|
-
Function.flow(HttpClientRequest.prependUrl('http://localhost:3000'))
|
|
84
|
-
)
|
|
85
|
-
),
|
|
95
|
+
baseUrl: 'http://localhost:3000',
|
|
86
96
|
})
|
|
87
97
|
).pipe(Layer.provide(FetchHttpClient.layer))
|
|
88
98
|
}
|
|
@@ -94,7 +104,7 @@ class ApiClient extends Context.Service<
|
|
|
94
104
|
import { ManagedRuntime } from 'effect'
|
|
95
105
|
import { createTanstackQueryOptionsProxy } from '@tiesen/effect-tanstack-query'
|
|
96
106
|
|
|
97
|
-
const runtime = ManagedRuntime.make(ApiClient.
|
|
107
|
+
const runtime = ManagedRuntime.make(ApiClient.layer)
|
|
98
108
|
const api = createTanstackQueryOptionsProxy(ApiClient, runtime)
|
|
99
109
|
```
|
|
100
110
|
|
|
@@ -102,26 +112,42 @@ const api = createTanstackQueryOptionsProxy(ApiClient, runtime)
|
|
|
102
112
|
|
|
103
113
|
```ts
|
|
104
114
|
import { useMutation, useQueryClient, useQuery } from '@tanstack/react-query'
|
|
115
|
+
import { useSubscription } from '@tiesen/effect-tanstack-query/react'
|
|
105
116
|
|
|
106
117
|
// Query Example
|
|
107
118
|
const query = useQuery(
|
|
108
|
-
api.
|
|
119
|
+
api.group.hello.queryOptions({
|
|
109
120
|
params: { name: 'John' },
|
|
110
121
|
query: { greeting: 'Hi' },
|
|
111
122
|
})
|
|
112
123
|
)
|
|
113
124
|
|
|
114
125
|
// Mutation Example
|
|
115
|
-
const mutation = useMutation(api.
|
|
126
|
+
const mutation = useMutation(api.group.goodbye.mutationOptions())
|
|
116
127
|
mutation.mutate({ name: 'John' })
|
|
117
128
|
|
|
129
|
+
// Stream Example
|
|
130
|
+
useSubscription(
|
|
131
|
+
api.group.stream.subscriptionOptions(undefined, {
|
|
132
|
+
onData: (data) => console.log('Received data:', data),
|
|
133
|
+
})
|
|
134
|
+
)
|
|
135
|
+
|
|
118
136
|
// Invalidate Query Example
|
|
119
137
|
const queryClient = useQueryClient()
|
|
120
138
|
void queryClient.invalidateQueries({
|
|
121
|
-
queryKey: api.
|
|
139
|
+
queryKey: api.group.hello.getQueryKey(),
|
|
122
140
|
})
|
|
123
141
|
```
|
|
124
142
|
|
|
143
|
+
## Downloads
|
|
144
|
+
|
|
145
|
+
<picture>
|
|
146
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://npmx.dev/api/embed/downloads.svg?packages=%40tiesen%2Feffect-tanstack-query&metric=downloads&startDate=2025-08-01&endDate=2026-07-30&mode=dark&granularity=weekly&locale=en-US&accent=oklch%2867.3%25+0+0%29&yLabel=Weekly+Downloads">
|
|
147
|
+
<source media="(prefers-color-scheme: light)" srcset="https://npmx.dev/api/embed/downloads.svg?packages=%40tiesen%2Feffect-tanstack-query&metric=downloads&startDate=2025-08-01&endDate=2026-07-30&mode=light&granularity=weekly&locale=en-US&accent=oklch%2867.3%25+0+0%29&yLabel=Weekly+Downloads">
|
|
148
|
+
<img alt="npmx downloads" src="https://npmx.dev/api/embed/downloads.svg?packages=%40tiesen%2Feffect-tanstack-query&metric=downloads&startDate=2025-08-01&endDate=2026-07-30&mode=light&granularity=weekly&locale=en-US&accent=oklch%2867.3%25+0+0%29&yLabel=Weekly+Downloads">
|
|
149
|
+
</picture>
|
|
150
|
+
|
|
125
151
|
## License
|
|
126
152
|
|
|
127
153
|
This project is licensed under the MIT License. See the [LICENSE](./LICENSE) file for details.
|
package/dist/index.d.mts
CHANGED
|
@@ -1,38 +1,10 @@
|
|
|
1
|
+
import { r as TanstackQueryOptionsProxy } from "./types-BGHsAv5y.mjs";
|
|
1
2
|
import { Service } from "effect/Context";
|
|
2
3
|
import { ManagedRuntime } from "effect/ManagedRuntime";
|
|
3
|
-
import { DefinedInitialDataOptions, MutationOptions } from "@tanstack/react-query";
|
|
4
|
-
import { Schema } from "effect/Schema";
|
|
5
|
-
import { Client } from "effect/unstable/httpapi/HttpApiClient";
|
|
6
|
-
import { HttpApiEndpoint } from "effect/unstable/httpapi/HttpApiEndpoint";
|
|
7
|
-
//#region src/types.d.ts
|
|
8
|
-
type TanstackQueryOptionsProxy<T> = T extends Client.Method<HttpApiEndpoint<infer _Key, infer Method, infer _Path, infer Params, infer Query, infer Payload, infer Headers, infer Success, infer Error>, infer _Error, infer _Requires> ? {
|
|
9
|
-
queryOptions: Method extends 'GET' ? <TQuery = DefinedInitialDataOptions<UnwrapCodec<Success>, UnwrapCodec<Error>>>(input: MakeOptionalInput<([Params] extends [never] ? {} : {
|
|
10
|
-
params: UnwrapCodec<Params>;
|
|
11
|
-
}) & ([Query] extends [never] ? {} : {
|
|
12
|
-
query: UnwrapCodec<Query>;
|
|
13
|
-
}) & ([Headers] extends [never] ? {} : {
|
|
14
|
-
headers: UnwrapCodec<Headers>;
|
|
15
|
-
})>, options?: Omit<TQuery, 'queryKey' | 'queryFn'>) => TQuery : never;
|
|
16
|
-
mutationOptions: Method extends 'GET' ? never : <TMutation = MutationOptions<UnwrapCodec<Success>, UnwrapCodec<Error>, UnwrapCodec<Payload>>>(input: MakeOptionalInput<([Params] extends [never] ? {} : {
|
|
17
|
-
params: UnwrapCodec<Params>;
|
|
18
|
-
}) & ([Headers] extends [never] ? {} : {
|
|
19
|
-
headers: UnwrapCodec<Headers>;
|
|
20
|
-
})>, options?: Omit<TMutation, 'mutationKey' | 'mutationFn'>) => TMutation;
|
|
21
|
-
getQueryKey: Method extends 'GET' ? (input?: Partial<MakeOptionalInput<([Params] extends [never] ? {} : {
|
|
22
|
-
params: UnwrapCodec<Params>;
|
|
23
|
-
}) & ([Query] extends [never] ? {} : {
|
|
24
|
-
query: UnwrapCodec<Query>;
|
|
25
|
-
}) & ([Headers] extends [never] ? {} : {
|
|
26
|
-
headers: UnwrapCodec<Headers>;
|
|
27
|
-
})>>) => readonly unknown[] : never;
|
|
28
|
-
} : T extends object ? { readonly [K in keyof T]: TanstackQueryOptionsProxy<T[K]>; } : T;
|
|
29
|
-
type UnwrapCodec<T> = T extends Schema<unknown> ? Schema.Type<T> : T extends object ? { [K in keyof T]: UnwrapCodec<T[K]>; } : T;
|
|
30
|
-
type MakeOptionalInput<T> = keyof T extends never ? void | undefined : T;
|
|
31
|
-
//#endregion
|
|
32
4
|
//#region src/index.d.ts
|
|
33
5
|
/**
|
|
34
6
|
* Creates a type-safe proxy that bridges Effect `HttpApiClient` endpoints
|
|
35
|
-
* with TanStack Query options (`queryOptions`, `mutationOptions`, and `getQueryKey`).
|
|
7
|
+
* with TanStack Query options (`queryOptions`, `subscriptionOptions`, `mutationOptions`, and `getQueryKey`).
|
|
36
8
|
*
|
|
37
9
|
* @param tag - The Effect `Service` tag used to locate the client implementation within the Context.
|
|
38
10
|
* @param runtime - The Effect `ManagedRuntime` used to execute effects as promises.
|
|
@@ -42,13 +14,14 @@ type MakeOptionalInput<T> = keyof T extends never ? void | undefined : T;
|
|
|
42
14
|
* @example
|
|
43
15
|
* ```ts
|
|
44
16
|
* class ApiGroup extends HttpApiGroup.make('ApiGroup')
|
|
45
|
-
*
|
|
46
|
-
*
|
|
17
|
+
* .add(HttpApiEndpoint.get('hello', '/hello', { success: Schema.String, query: Schema.Struct({ name: Schema.String }) }))
|
|
18
|
+
* .add(HttpApiEndpoint.post('bye', '/bye', { success: Schema.String, payload: Schema.Struct({ name: Schema.String }) }))
|
|
19
|
+
* .add(HttpApiEndpoint.get('stream', '/stream', { success: HttpApiSchema.StreamSse({ data: Schema.String }) })) {}
|
|
47
20
|
*
|
|
48
21
|
* class Api extends HttpApi.make('Api').add(ApiGroup) {}
|
|
49
22
|
*
|
|
50
23
|
* class ApiClient extends Context.Service<ApiClient, HttpApiClient.ForApi<typeof Api>>()('ApiClient') {
|
|
51
|
-
*
|
|
24
|
+
* public static live = Layer.effect(this, HttpApiClient.make(Api)).pipe(Layer.provide(FetchHttpClient.layer))
|
|
52
25
|
* }
|
|
53
26
|
*
|
|
54
27
|
* const runtime = ManagedRuntime.make(ApiClient.live)
|
|
@@ -56,11 +29,16 @@ type MakeOptionalInput<T> = keyof T extends never ? void | undefined : T;
|
|
|
56
29
|
*
|
|
57
30
|
* // Example usage in a React component with TanStack Query
|
|
58
31
|
* const { data } = useQuery(api.hello.queryOptions({ query: { name: 'World' } }))
|
|
59
|
-
*
|
|
32
|
+
* ^? const data: string = "Hello, World!"
|
|
60
33
|
*
|
|
61
34
|
* const { mutate, data } = useMutation(api.bye.mutationOptions())
|
|
62
|
-
*
|
|
35
|
+
* ^? const data: string = "Goodbye, World!"
|
|
63
36
|
* mutate({ name: 'World' })
|
|
37
|
+
*
|
|
38
|
+
* useSubscription(api.stream.subscriptionOptions({
|
|
39
|
+
* onData: (data) => console.log(data),
|
|
40
|
+
* ^? const data: string = "data: keep-alive\n\n"
|
|
41
|
+
* }))
|
|
64
42
|
* ```
|
|
65
43
|
*/
|
|
66
44
|
declare function createTanstackQueryOptionsProxy<TServiceTag, TService>(tag: Service<TServiceTag, TService>, runtime: ManagedRuntime<TServiceTag, never>): TanstackQueryOptionsProxy<TService>;
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"effect/Effect";function
|
|
1
|
+
import*as e from"effect/Effect";import*as t from"effect/Stream";function n(n,r){let i=new Map,a=o=>{let s=o.join(`.`);if(i.has(s))return i.get(s);let c=new Proxy(()=>{},{get(e,t){if(typeof t!=`symbol`&&t!==`then`)return a([...o,String(t)])},apply(i,a,s){let c=o.at(-1),l=o.slice(0,-1),[u,d]=s,f=e.fn(function*(e){let t=yield*n;for(let e of l)t=t[e];return yield*t(e)}),p=(e,t)=>r.runPromise(f(e),{signal:t}),m=(e,t)=>[{type:e},...l,...t?[t]:[]];if(c===`queryOptions`)return{...d,queryKey:m(`query`,u),queryFn:({signal:e})=>p(u,e)};if(c===`getQueryKey`)return m(`query`,u);if(c===`subscriptionOptions`){let n=t.unwrap(f({...u,responseMode:`response-only`}).pipe(e.map(e=>e.stream.pipe(t.decodeText())))),i=d;return{...d,subcriptionKey:m(`subscription`,u),subscriptionFn:({signal:a}={})=>{let o=r.runFork(n.pipe(t.tap(t=>e.sync(()=>i.onData(t))),t.runDrain)),s=()=>o.interruptUnsafe(o.id);return a&&(a.aborted?s():a.addEventListener(`abort`,s,{once:!0})),o.addObserver(e=>{e._tag===`Failure`&&i.onError?.(e.cause)}),s}}}if(c===`mutationOptions`)return{...d,mutationKey:m(`mutation`,u),mutationFn:e=>p({payload:e})}}});return i.set(s,c),c};return a([])}export{n as createTanstackQueryOptionsProxy};
|
package/dist/react.d.mts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { n as SubscriptionReturns, t as SubscriptionOptions } from "./types-BGHsAv5y.mjs";
|
|
2
|
+
//#region src/react.d.ts
|
|
3
|
+
declare function useSubscription<TData, TError>({ enabled, ...subscriptionOptions }: SubscriptionOptions<TData, TError> & {
|
|
4
|
+
enabled?: boolean;
|
|
5
|
+
}): SubscriptionReturns;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { type SubscriptionOptions, type SubscriptionReturns, useSubscription };
|
package/dist/react.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import*as e from"react";function t({enabled:t=!0,...n}){let[r,i]=e.useState(`disconnected`),[a,o]=e.useState(0),s=e.useCallback(()=>{o(e=>e+1)},[]);return e.useEffect(()=>{if(!t){i(`disconnected`);return}i(`connecting`);let e=new AbortController,r=n.subscriptionFn({signal:e.signal});return i(`connected`),()=>{e.abort(),r(),i(`disconnected`)}},[t,n.subscriptionFn,a]),e.useMemo(()=>({status:r,reconnect:s}),[r,s])}export{t as useSubscription};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { DefinedInitialDataOptions, MutationOptions } from "@tanstack/react-query";
|
|
2
|
+
import { Schema } from "effect/Schema";
|
|
3
|
+
import { Client } from "effect/unstable/httpapi/HttpApiClient";
|
|
4
|
+
import { HttpApiEndpoint } from "effect/unstable/httpapi/HttpApiEndpoint";
|
|
5
|
+
import { SseEventFromData, StreamSse } from "effect/unstable/httpapi/HttpApiSchema";
|
|
6
|
+
//#region src/types.d.ts
|
|
7
|
+
type TanstackQueryOptionsProxy<T> = T extends Client.Method<HttpApiEndpoint<infer _Key, infer Method, infer _Path, infer Params, infer Query, infer Payload, infer Headers, infer Success, infer Error>, infer _Error, infer _Requires> ? {
|
|
8
|
+
queryOptions: Method extends 'GET' ? <TQuery = DefinedInitialDataOptions<UnwrapCodec<Success>, UnwrapCodec<Error>>>(input: MakeOptionalInput<([Params] extends [never] ? {} : {
|
|
9
|
+
params: UnwrapCodec<Params>;
|
|
10
|
+
}) & ([Query] extends [never] ? {} : {
|
|
11
|
+
query: UnwrapCodec<Query>;
|
|
12
|
+
}) & ([Headers] extends [never] ? {} : {
|
|
13
|
+
headers: UnwrapCodec<Headers>;
|
|
14
|
+
})>, options?: Omit<TQuery, 'queryKey' | 'queryFn'>) => TQuery : never;
|
|
15
|
+
subscriptionOptions: Success extends StreamSse<SseEventFromData<infer StreamSuccess>, infer StreamError, infer _StreamValue> ? (input: MakeOptionalInput<([Params] extends [never] ? {} : {
|
|
16
|
+
params: UnwrapCodec<Params>;
|
|
17
|
+
}) & ([Query] extends [never] ? {} : {
|
|
18
|
+
query: UnwrapCodec<Query>;
|
|
19
|
+
}) & ([Headers] extends [never] ? {} : {
|
|
20
|
+
headers: UnwrapCodec<Headers>;
|
|
21
|
+
})>, options?: {
|
|
22
|
+
onData: (data: StreamSuccess) => void;
|
|
23
|
+
onError?: (error: StreamError) => void;
|
|
24
|
+
}) => SubscriptionOptions<StreamSuccess, StreamError> : never;
|
|
25
|
+
mutationOptions: Method extends 'GET' ? never : <TMutation = MutationOptions<UnwrapCodec<Success>, UnwrapCodec<Error>, UnwrapCodec<Payload>>>(input: MakeOptionalInput<([Params] extends [never] ? {} : {
|
|
26
|
+
params: UnwrapCodec<Params>;
|
|
27
|
+
}) & ([Headers] extends [never] ? {} : {
|
|
28
|
+
headers: UnwrapCodec<Headers>;
|
|
29
|
+
})>, options?: Omit<TMutation, 'mutationKey' | 'mutationFn'>) => TMutation;
|
|
30
|
+
getQueryKey: Method extends 'GET' ? (input?: Partial<MakeOptionalInput<([Params] extends [never] ? {} : {
|
|
31
|
+
params: UnwrapCodec<Params>;
|
|
32
|
+
}) & ([Query] extends [never] ? {} : {
|
|
33
|
+
query: UnwrapCodec<Query>;
|
|
34
|
+
}) & ([Headers] extends [never] ? {} : {
|
|
35
|
+
headers: UnwrapCodec<Headers>;
|
|
36
|
+
})>>) => readonly unknown[] : never;
|
|
37
|
+
} : T extends object ? { readonly [K in keyof T]: TanstackQueryOptionsProxy<T[K]>; } : T;
|
|
38
|
+
type UnsubscribeFn = () => void;
|
|
39
|
+
interface SubscriptionOptions<TData, TError> {
|
|
40
|
+
subcriptionKey: readonly unknown[];
|
|
41
|
+
subscriptionFn: (options: {
|
|
42
|
+
signal?: AbortSignal;
|
|
43
|
+
}) => UnsubscribeFn;
|
|
44
|
+
onData: (data: TData) => void;
|
|
45
|
+
onError?: (error: TError) => void;
|
|
46
|
+
}
|
|
47
|
+
interface SubscriptionReturns {
|
|
48
|
+
status: 'connecting' | 'connected' | 'disconnected' | 'error';
|
|
49
|
+
reconnect: () => void;
|
|
50
|
+
}
|
|
51
|
+
type UnwrapCodec<T> = T extends Schema<unknown> ? Schema.Type<T> : T extends object ? { [K in keyof T]: UnwrapCodec<T[K]>; } : T;
|
|
52
|
+
type MakeOptionalInput<T> = keyof T extends never ? void | undefined : T;
|
|
53
|
+
//#endregion
|
|
54
|
+
export { SubscriptionReturns as n, TanstackQueryOptionsProxy as r, SubscriptionOptions as t };
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiesen/effect-tanstack-query",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
4
4
|
"private": false,
|
|
5
|
-
"description": "
|
|
5
|
+
"description": "Effortlessly bridge Effect HTTP API clients with TanStack Query. Enjoy end-to-end type safety, zero-boilerplate options, and built-in streaming support out of the box.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"effect",
|
|
8
8
|
"effect-ts",
|
|
@@ -34,8 +34,12 @@
|
|
|
34
34
|
"type": "module",
|
|
35
35
|
"exports": {
|
|
36
36
|
".": {
|
|
37
|
-
"
|
|
38
|
-
"
|
|
37
|
+
"types": "./dist/index.d.mts",
|
|
38
|
+
"default": "./dist/index.mjs"
|
|
39
|
+
},
|
|
40
|
+
"./react": {
|
|
41
|
+
"types": "./dist/react.d.mts",
|
|
42
|
+
"default": "./dist/react.mjs"
|
|
39
43
|
}
|
|
40
44
|
},
|
|
41
45
|
"publishConfig": {
|
|
@@ -51,6 +55,7 @@
|
|
|
51
55
|
"typecheck": "tsc --noEmit"
|
|
52
56
|
},
|
|
53
57
|
"devDependencies": {
|
|
58
|
+
"@types/react": "^19.2.18",
|
|
54
59
|
"oxfmt": "^0.61.0",
|
|
55
60
|
"oxlint": "^1.76.0",
|
|
56
61
|
"tegami": "^1.2.7",
|
|
@@ -59,7 +64,8 @@
|
|
|
59
64
|
},
|
|
60
65
|
"peerDependencies": {
|
|
61
66
|
"@tanstack/react-query": ">=5.100.0",
|
|
62
|
-
"effect": ">=4.0.0-beta.100 || >=4.0.0"
|
|
67
|
+
"effect": ">=4.0.0-beta.100 || >=4.0.0",
|
|
68
|
+
"react": ">=19.2.8"
|
|
63
69
|
},
|
|
64
70
|
"packageManager": "bun@1.3.0",
|
|
65
71
|
"patchedDependencies": {
|