@tiesen/effect-tanstack-query 0.0.20 → 0.0.21
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/dist/index.d.mts +3 -3
- package/dist/index.mjs +1 -1
- package/dist/react.d.mts +1 -1
- package/dist/react.mjs +1 -1
- package/dist/{types-CBIv8Q6_.d.mts → types-BarbB5aY.d.mts} +3 -1
- package/dist/vue.d.mts +1 -1
- package/package.json +12 -12
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as TanstackQueryOptionsProxy, t as SubscriptionOptions } from "./types-
|
|
1
|
+
import { n as TanstackQueryOptionsProxy, t as SubscriptionOptions } from "./types-BarbB5aY.mjs";
|
|
2
2
|
import { Service } from "effect/Context";
|
|
3
3
|
import { ManagedRuntime } from "effect/ManagedRuntime";
|
|
4
4
|
//#region src/create-proxy.d.ts
|
|
@@ -41,6 +41,6 @@ import { ManagedRuntime } from "effect/ManagedRuntime";
|
|
|
41
41
|
* }))
|
|
42
42
|
* ```
|
|
43
43
|
*/
|
|
44
|
-
declare function createTanstackQueryOptionsProxy<TServiceTag, TService>(tag: Service<TServiceTag, TService>, runtime: ManagedRuntime<TServiceTag, never>): TanstackQueryOptionsProxy<TService>;
|
|
44
|
+
export declare function createTanstackQueryOptionsProxy<TServiceTag, TService>(tag: Service<TServiceTag, TService>, runtime: ManagedRuntime<TServiceTag, never>): TanstackQueryOptionsProxy<TService>;
|
|
45
45
|
//#endregion
|
|
46
|
-
export {
|
|
46
|
+
export type { SubscriptionOptions, TanstackQueryOptionsProxy };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as e from"effect/Effect";import*as t from"effect/Fiber";import*as n from"effect/Schedule";import*as r from"effect/Stream";function i(i,a){let o
|
|
1
|
+
import*as e from"effect/Effect";import*as t from"effect/Fiber";import*as n from"effect/Schedule";import*as r from"effect/Stream";function i(i,a){let o=/* @__PURE__ */ new Map,s=c=>{let l=c.join(`.`);if(o.has(l))return o.get(l);let u=new Proxy(()=>{},{get(e,t){if(typeof t!=`symbol`&&t!==`then`)return s([...c,String(t)])},apply(o,s,l){let u=c.at(-1),d=c.slice(0,-1),[f,p]=l,m=e.fn(function*(e){let t=yield*i;for(let e of d)t=t[e];return yield*t(e)}),h=(e,t)=>a.runPromise(m(e),{signal:t}),g=(e,t)=>[{type:e},...d,...t?[t]:[]];if(u===`query`||u===`mutate`)return h(f);if((u===`queryEffect`||u===`mutateEffect`)&&a.cachedContext)return m(f).pipe(e.provide(a.cachedContext));if(u===`queryOptions`)return{...p,queryKey:g(`query`,f),queryFn:({signal:e})=>h(f,e)};if(u===`getQueryKey`)return g(`query`,f);if(u===`mutationOptions`)return{...p,mutationKey:g(`mutation`,f),mutationFn:e=>h({...f,payload:e})};if(u===`subscriptionOptions`)return{...p,enabled:p?.enabled??!0,subcriptionKey:g(`subscription`,f),subscriptionFn:({autoReconnect:i,keepAlive:o,...s})=>{let{onStarted:c,onData:l,onError:u,onConnectionChange:d}=s,p=n.max([n.exponential(i??0),n.spaced(`30 seconds`),n.recurs(3)]).pipe(n.jittered),h=e.gen(function*(){d?.({status:`connecting`}),c?.();let t=yield*m({...f,responseMode:`response-only`});d?.({status:`pending`});let n=yield*t.stream.pipe(r.decodeText,r.splitLines,r.filter(e=>e.length>0),r.share({capacity:`unbounded`})),a=n.pipe(r.filter(e=>e.startsWith(o?.message??`:keep-alive`)),r.timeout(o?.timeout??`10 seconds`)),s=yield*n.pipe(r.filter(e=>e.startsWith(`data:`)),r.map(e=>e.slice(5).trim()),r.filter(e=>e.length>0),r.mapEffect(t=>e.orElseSucceed(e.try(()=>JSON.parse(t)),()=>t)),r.tap(t=>e.sync(()=>l?.(t))),r.share({capacity:`unbounded`})),u=r.merge(a,s);yield*r.runDrain(u),i&&(yield*e.fail(`restart`))}).pipe(e.tapError(t=>t===`restart`||typeof t==`object`&&t._tag===`HttpClientError`&&t.reason?._tag===`DecodeError`?e.void:e.sync(()=>u?.(t)))),g=(i?h.pipe(e.retry(p)):h).pipe(e.ensuring(e.sync(()=>d?.({status:`idle`}))),e.scoped),_=a.runFork(g);return()=>a.runPromise(t.interrupt(_))}}}});return o.set(l,u),u};return s([])}export{i as createTanstackQueryOptionsProxy};
|
package/dist/react.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as UseSubscriptionReturns, t as SubscriptionOptions } from "./types-
|
|
1
|
+
import { r as UseSubscriptionReturns, t as SubscriptionOptions } from "./types-BarbB5aY.mjs";
|
|
2
2
|
//#region src/react.d.ts
|
|
3
3
|
declare function useSubscription<TData, TError>(opts: SubscriptionOptions<TData, TError>): UseSubscriptionReturns<TData, TError>;
|
|
4
4
|
//#endregion
|
package/dist/react.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{hashKey as e}from"@tanstack/query-core";import*as t from"react";function n(n){let i=t.useRef(n);i.current=n;let a=t.useRef(new Set),o=t.useCallback(e=>{a.current.add(e)},[]),s=t.useRef(()=>{}),c=t.useCallback(()=>{if(s.current(),p(l),!n.enabled)return;let e=n.subscriptionFn({autoReconnect:i.current.autoReconnect,keepAlive:i.current.keepAlive,onStarted:()=>{i.current.onStarted?.(),p(e=>({...e,status:`pending`,error:null}))},onData:e=>{i.current.onData?.(e),p(t=>({...t,status:`pending`,data:e,error:null}))},onError:e=>{i.current.onError?.(e),p(t=>({...t,status:`error`,error:e}))},onConnectionChange:e=>{i.current.onConnectionChange?.(e),p(t=>{switch(e.status){case`connecting`:return{...t,status:`connecting`,error:e.error??null};case`pending`:return t;case`idle`:return{...t,status:`idle`,data:null,error:null};default:return t}})}});s.current=()=>e()},[e(n.subcriptionKey),n.enabled]),l=t.useCallback(()=>n.enabled?{data:null,error:null,status:`connecting`,reset:c}:{data:null,error:null,status:`idle`,reset:c},[n.enabled,c]),u=t.useRef(l()),[d,f]=t.useState(r(u,o));d.reset=c;let p=t.useCallback(e=>{let t=u.current,n=u.current=e(t),i=!1;for(let e of a.current)if(t[e]!==n[e]){i=!0;break}i&&f(r(u,o))},[o]);return t.useEffect(()=>{if(n.enabled)return c(),()=>s.current()},[e(n.subcriptionKey),n.enabled]),d}function r(e,t){return new Proxy(e.current,{get(n,r){return t(r),e.current[r]}})}export{n as useSubscription};
|
|
1
|
+
import{hashKey as e}from"@tanstack/query-core";import*as t from"react";function n(n){let i=t.useRef(n);i.current=n;let a=t.useRef(/* @__PURE__ */ new Set),o=t.useCallback(e=>{a.current.add(e)},[]),s=t.useRef(()=>{}),c=t.useCallback(()=>{if(s.current(),p(l),!n.enabled)return;let e=n.subscriptionFn({autoReconnect:i.current.autoReconnect,keepAlive:i.current.keepAlive,onStarted:()=>{i.current.onStarted?.(),p(e=>({...e,status:`pending`,error:null}))},onData:e=>{i.current.onData?.(e),p(t=>({...t,status:`pending`,data:e,error:null}))},onError:e=>{i.current.onError?.(e),p(t=>({...t,status:`error`,error:e}))},onConnectionChange:e=>{i.current.onConnectionChange?.(e),p(t=>{switch(e.status){case`connecting`:return{...t,status:`connecting`,error:e.error??null};case`pending`:return t;case`idle`:return{...t,status:`idle`,data:null,error:null};default:return t}})}});s.current=()=>e()},[e(n.subcriptionKey),n.enabled]),l=t.useCallback(()=>n.enabled?{data:null,error:null,status:`connecting`,reset:c}:{data:null,error:null,status:`idle`,reset:c},[n.enabled,c]),u=t.useRef(l()),[d,f]=t.useState(r(u,o));d.reset=c;let p=t.useCallback(e=>{let t=u.current,n=u.current=e(t),i=!1;for(let e of a.current)if(t[e]!==n[e]){i=!0;break}i&&f(r(u,o))},[o]);return t.useEffect(()=>{if(n.enabled)return c(),()=>s.current()},[e(n.subcriptionKey),n.enabled]),d}function r(e,t){return new Proxy(e.current,{get(n,r){return t(r),e.current[r]}})}export{n as useSubscription};
|
|
@@ -6,7 +6,7 @@ import { Client } from "effect/unstable/httpapi/HttpApiClient";
|
|
|
6
6
|
import { HttpApiEndpoint } from "effect/unstable/httpapi/HttpApiEndpoint";
|
|
7
7
|
import { SseEventFromData, StreamSse } from "effect/unstable/httpapi/HttpApiSchema";
|
|
8
8
|
//#region src/types.d.ts
|
|
9
|
-
type
|
|
9
|
+
type TanstackQueryOptionsProxyInternal<T> = T extends Client.Method<HttpApiEndpoint<infer _Identifier, infer Method, infer _Path, infer Params, infer Query, infer Payload, infer Headers, infer Success, infer Error, infer _Middleware, infer _MiddlewareService>, infer _Error, infer _Requires> ? {
|
|
10
10
|
query: Method extends 'GET' ? (input: MakeInput<Headers, Params, Query, never>) => UnwrapCodec<Success> | Promise<UnwrapCodec<Success>> : never;
|
|
11
11
|
queryEffect: Method extends 'GET' ? (input: MakeInput<Headers, Params, Query, never>) => Effect<UnwrapCodec<Success>, UnwrapCodec<Error>> : never;
|
|
12
12
|
queryOptions: Method extends 'GET' ? <TQuery = QueryOptions<UnwrapCodec<Success>, UnwrapCodec<Error>>>(input: MakeInput<Headers, Params, Query, never>, options?: Omit<TQuery, 'queryKey' | 'queryFn'>) => TQuery : never;
|
|
@@ -16,6 +16,8 @@ type TanstackQueryOptionsProxy<T> = T extends Client.Method<HttpApiEndpoint<infe
|
|
|
16
16
|
mutationOptions: Method extends 'GET' ? never : <TMutation = MutationOptions<UnwrapCodec<Success>, UnwrapCodec<Error>, UnwrapCodec<Payload>>>(input: MakeInput<Headers, Params, never, never>, options?: Omit<TMutation, 'mutationKey' | 'mutationFn'>) => TMutation;
|
|
17
17
|
getQueryKey: Method extends 'GET' ? (input?: Partial<MakeInput<Headers, Params, Query, never>>) => QueryKey : never;
|
|
18
18
|
} : T extends object ? { readonly [K in keyof T as K extends symbol ? never : K]: TanstackQueryOptionsProxy<T[K]>; } : T;
|
|
19
|
+
type StripNever<T> = T extends ((...args: any[]) => any) ? T : T extends object ? { [K in keyof T as [T[K]] extends [never] ? never : K]: StripNever<T[K]>; } : T;
|
|
20
|
+
type TanstackQueryOptionsProxy<T> = StripNever<TanstackQueryOptionsProxyInternal<T>>;
|
|
19
21
|
interface SubscriptionOptions<TData, TError> {
|
|
20
22
|
/**
|
|
21
23
|
* Determines whether the subscription is active. If set to `false`, the subscription will not be initiated.
|
package/dist/vue.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { r as UseSubscriptionReturns, t as SubscriptionOptions } from "./types-
|
|
1
|
+
import { r as UseSubscriptionReturns, t as SubscriptionOptions } from "./types-BarbB5aY.mjs";
|
|
2
2
|
import { MaybeRefOrGetter } from "vue";
|
|
3
3
|
//#region src/vue.d.ts
|
|
4
4
|
declare function useSubscription<TData, TError>(optsInput: MaybeRefOrGetter<SubscriptionOptions<TData, TError>>): UseSubscriptionReturns<TData, TError>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiesen/effect-tanstack-query",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.21",
|
|
4
4
|
"private": false,
|
|
5
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": [
|
|
@@ -59,19 +59,19 @@
|
|
|
59
59
|
"typecheck": "tsc --noEmit"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@types/react": "^19.
|
|
62
|
+
"@types/react": "^19.3.0",
|
|
63
63
|
"@types/vue": "^2.0.0",
|
|
64
|
-
"oxfmt": "^0.
|
|
65
|
-
"oxlint": "^1.
|
|
66
|
-
"tegami": "^1.
|
|
67
|
-
"tsdown": "^0.
|
|
64
|
+
"oxfmt": "^0.68.0",
|
|
65
|
+
"oxlint": "^1.83.0",
|
|
66
|
+
"tegami": "^1.5.0",
|
|
67
|
+
"tsdown": "^0.23.0",
|
|
68
68
|
"typescript": "^7.0.2"
|
|
69
69
|
},
|
|
70
70
|
"peerDependencies": {
|
|
71
|
-
"@tanstack/query-core": ">=5.
|
|
72
|
-
"effect": ">=4.0.0-rc.
|
|
73
|
-
"react": ">=19.
|
|
74
|
-
"vue": ">=3.
|
|
71
|
+
"@tanstack/query-core": ">=5.103.0",
|
|
72
|
+
"effect": ">=4.0.0-rc.115",
|
|
73
|
+
"react": ">=19.0.0",
|
|
74
|
+
"vue": ">=3.0.0"
|
|
75
75
|
},
|
|
76
76
|
"peerDependenciesMeta": {
|
|
77
77
|
"react": {
|
|
@@ -81,8 +81,8 @@
|
|
|
81
81
|
"optional": true
|
|
82
82
|
}
|
|
83
83
|
},
|
|
84
|
-
"packageManager": "bun@1.
|
|
84
|
+
"packageManager": "bun@1.4.0",
|
|
85
85
|
"patchedDependencies": {
|
|
86
|
-
"tegami@1.
|
|
86
|
+
"tegami@1.5.0": "patches/tegami@1.5.0.patch"
|
|
87
87
|
}
|
|
88
88
|
}
|