@tiesen/effect-tanstack-query 0.0.16 → 0.0.18

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 CHANGED
@@ -1,4 +1,4 @@
1
- import { r as TanstackQueryOptionsProxy } from "./types-A-WfeH_j.mjs";
1
+ import { n as TanstackQueryOptionsProxy, t as SubscriptionOptions } from "./types-Day-Eet1.mjs";
2
2
  import { Service } from "effect/Context";
3
3
  import { ManagedRuntime } from "effect/ManagedRuntime";
4
4
  //#region src/create-proxy.d.ts
@@ -43,4 +43,4 @@ import { ManagedRuntime } from "effect/ManagedRuntime";
43
43
  */
44
44
  declare function createTanstackQueryOptionsProxy<TServiceTag, TService>(tag: Service<TServiceTag, TService>, runtime: ManagedRuntime<TServiceTag, never>): TanstackQueryOptionsProxy<TService>;
45
45
  //#endregion
46
- export { type TanstackQueryOptionsProxy, createTanstackQueryOptionsProxy };
46
+ export { type SubscriptionOptions, type TanstackQueryOptionsProxy, createTanstackQueryOptionsProxy };
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=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===`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.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};
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=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===`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,5 +1,5 @@
1
- import { n as SubscriptionReturns, t as SubscriptionOptions } from "./types-A-WfeH_j.mjs";
1
+ import { r as UseSubscriptionReturns, t as SubscriptionOptions } from "./types-Day-Eet1.mjs";
2
2
  //#region src/react.d.ts
3
- declare function useSubscription<TData, TError>(opts: SubscriptionOptions<TData, TError>): SubscriptionReturns<TData, TError>;
3
+ declare function useSubscription<TData, TError>(opts: SubscriptionOptions<TData, TError>): UseSubscriptionReturns<TData, TError>;
4
4
  //#endregion
5
- export { type SubscriptionOptions, type SubscriptionReturns, useSubscription };
5
+ export { type SubscriptionOptions, type UseSubscriptionReturns as SubscriptionReturns, useSubscription };
@@ -80,12 +80,12 @@ interface SubscriptionOptions<TData, TError> {
80
80
  /**
81
81
  * Callback invoked when the connection's status changes
82
82
  */
83
- onConnectionChange?: (result: Partial<SubscriptionReturns<TData, TError>>) => void;
83
+ onConnectionChange?: (result: Partial<UseSubscriptionReturns<TData, TError>>) => void;
84
84
  }
85
85
  type QueryOptions<TQueryFnData = unknown, TError = DefaultError, TData = TQueryFnData, TQueryKey extends QueryKey = QueryKey> = QueryObserverOptions<TQueryFnData, TError, TData, TQueryFnData, TQueryKey> & {
86
86
  subscribed?: boolean;
87
87
  };
88
- type SubscriptionReturns<TData, TError> = {
88
+ type UseSubscriptionReturns<TData, TError> = {
89
89
  reset: () => void;
90
90
  } & ({
91
91
  status: 'idle';
@@ -107,4 +107,4 @@ type SubscriptionReturns<TData, TError> = {
107
107
  type UnwrapCodec<T> = T extends Schema<unknown> ? Schema.Type<T> : T extends object ? { [K in keyof T]: UnwrapCodec<T[K]>; } : T;
108
108
  type MakeOptionalInput<T> = keyof T extends never ? void | undefined : T;
109
109
  //#endregion
110
- export { SubscriptionReturns as n, TanstackQueryOptionsProxy as r, SubscriptionOptions as t };
110
+ export { TanstackQueryOptionsProxy as n, UseSubscriptionReturns as r, SubscriptionOptions as t };
package/dist/vue.d.mts CHANGED
@@ -1,6 +1,6 @@
1
- import { n as SubscriptionReturns, t as SubscriptionOptions } from "./types-A-WfeH_j.mjs";
1
+ import { r as UseSubscriptionReturns, t as SubscriptionOptions } from "./types-Day-Eet1.mjs";
2
2
  import { MaybeRefOrGetter } from "vue";
3
3
  //#region src/vue.d.ts
4
- declare function useSubscription<TData, TError>(optsInput: MaybeRefOrGetter<SubscriptionOptions<TData, TError>>): SubscriptionReturns<TData, TError>;
4
+ declare function useSubscription<TData, TError>(optsInput: MaybeRefOrGetter<SubscriptionOptions<TData, TError>>): UseSubscriptionReturns<TData, TError>;
5
5
  //#endregion
6
- export { type SubscriptionOptions, type SubscriptionReturns, useSubscription };
6
+ export { type SubscriptionOptions, type UseSubscriptionReturns as SubscriptionReturns, useSubscription };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tiesen/effect-tanstack-query",
3
- "version": "0.0.16",
3
+ "version": "0.0.18",
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": [
@@ -61,15 +61,15 @@
61
61
  "devDependencies": {
62
62
  "@types/react": "^19.2.18",
63
63
  "@types/vue": "^2.0.0",
64
- "oxfmt": "^0.62.0",
65
- "oxlint": "^1.77.0",
66
- "tegami": "^1.3.4",
64
+ "oxfmt": "^0.63.0",
65
+ "oxlint": "^1.78.0",
66
+ "tegami": "^1.3.5",
67
67
  "tsdown": "^0.22.14",
68
68
  "typescript": "^7.0.2"
69
69
  },
70
70
  "peerDependencies": {
71
71
  "@tanstack/query-core": ">=5.100.0",
72
- "effect": ">=4.0.0-beta.106",
72
+ "effect": ">=4.0.0-rc.108 || >=4.0.0",
73
73
  "react": ">=19.2.8",
74
74
  "vue": ">=3.5.40"
75
75
  },
@@ -83,6 +83,6 @@
83
83
  },
84
84
  "packageManager": "bun@1.3.0",
85
85
  "patchedDependencies": {
86
- "tegami@1.3.4": "patches/tegami@1.3.4.patch"
86
+ "tegami@1.3.5": "patches/tegami@1.3.5.patch"
87
87
  }
88
88
  }