@tiesen/effect-tanstack-query 0.0.14 → 0.0.16
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.mjs +1 -1
- package/dist/vue.d.mts +6 -0
- package/dist/vue.mjs +1 -0
- package/package.json +19 -5
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({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.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/vue.d.mts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { n as SubscriptionReturns, t as SubscriptionOptions } from "./types-A-WfeH_j.mjs";
|
|
2
|
+
import { MaybeRefOrGetter } from "vue";
|
|
3
|
+
//#region src/vue.d.ts
|
|
4
|
+
declare function useSubscription<TData, TError>(optsInput: MaybeRefOrGetter<SubscriptionOptions<TData, TError>>): SubscriptionReturns<TData, TError>;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { type SubscriptionOptions, type SubscriptionReturns, useSubscription };
|
package/dist/vue.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{hashKey as e}from"@tanstack/query-core";import{onUnmounted as t,reactive as n,toValue as r,watch as i}from"vue";function a(a){let o=n({data:null,error:null,status:`idle`,reset:()=>{}}),s=null,c=()=>{s&&=(s(),null)},l=()=>{c();let e=r(a);if(!e.enabled){o.status=`idle`,o.data=null,o.error=null;return}o.status=`connecting`,o.data=null,o.error=null;let t=e.subscriptionFn({autoReconnect:e.autoReconnect,keepAlive:e.keepAlive,onStarted:()=>{r(a).onStarted?.(),o.status=`pending`,o.error=null},onData:e=>{r(a).onData?.(e),o.status=`pending`,o.data=e,o.error=null},onError:e=>{r(a).onError?.(e),o.status=`error`,o.error=e},onConnectionChange:e=>{switch(r(a).onConnectionChange?.(e),e.status){case`connecting`:o.status=`connecting`,o.error=e.error??null;break;case`pending`:break;case`idle`:o.status=`idle`,o.data=null,o.error=null}}});s=()=>t()};return o.reset=l,i(()=>{let t=r(a);return{enabled:t.enabled,key:t.subcriptionKey?e(t.subcriptionKey):void 0}},({enabled:e})=>{e?l():(c(),o.status=`idle`,o.data=null,o.error=null)},{immediate:!0}),t(()=>c()),o}export{a as useSubscription};
|
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.16",
|
|
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": [
|
|
@@ -40,6 +40,10 @@
|
|
|
40
40
|
"./react": {
|
|
41
41
|
"types": "./dist/react.d.mts",
|
|
42
42
|
"default": "./dist/react.mjs"
|
|
43
|
+
},
|
|
44
|
+
"./vue": {
|
|
45
|
+
"types": "./dist/vue.d.mts",
|
|
46
|
+
"default": "./dist/vue.mjs"
|
|
43
47
|
}
|
|
44
48
|
},
|
|
45
49
|
"publishConfig": {
|
|
@@ -56,19 +60,29 @@
|
|
|
56
60
|
},
|
|
57
61
|
"devDependencies": {
|
|
58
62
|
"@types/react": "^19.2.18",
|
|
63
|
+
"@types/vue": "^2.0.0",
|
|
59
64
|
"oxfmt": "^0.62.0",
|
|
60
65
|
"oxlint": "^1.77.0",
|
|
61
|
-
"tegami": "^1.3.
|
|
66
|
+
"tegami": "^1.3.4",
|
|
62
67
|
"tsdown": "^0.22.14",
|
|
63
68
|
"typescript": "^7.0.2"
|
|
64
69
|
},
|
|
65
70
|
"peerDependencies": {
|
|
66
71
|
"@tanstack/query-core": ">=5.100.0",
|
|
67
|
-
"effect": ">=4.0.0-beta.
|
|
68
|
-
"react": ">=19.2.8"
|
|
72
|
+
"effect": ">=4.0.0-beta.106",
|
|
73
|
+
"react": ">=19.2.8",
|
|
74
|
+
"vue": ">=3.5.40"
|
|
75
|
+
},
|
|
76
|
+
"peerDependenciesMeta": {
|
|
77
|
+
"react": {
|
|
78
|
+
"optional": true
|
|
79
|
+
},
|
|
80
|
+
"vue": {
|
|
81
|
+
"optional": true
|
|
82
|
+
}
|
|
69
83
|
},
|
|
70
84
|
"packageManager": "bun@1.3.0",
|
|
71
85
|
"patchedDependencies": {
|
|
72
|
-
"tegami@1.3.
|
|
86
|
+
"tegami@1.3.4": "patches/tegami@1.3.4.patch"
|
|
73
87
|
}
|
|
74
88
|
}
|