@collective-intelligence/extensions-sdk-frontend-react 0.2.14 → 0.2.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/effect.js +1 -1
- package/package.json +5 -4
package/dist/effect.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as f from"effect/Schema";class S extends f.TaggedError()("StudioApiError",{body:f.Unknown,status:f.Int}){}class d extends f.TaggedError()("StudioApiTransportError",{cause:f.Defect()}){}import{fromPromise as
|
|
1
|
+
import*as f from"effect/Schema";class S extends f.TaggedError()("StudioApiError",{body:f.Unknown,status:f.Int}){}class d extends f.TaggedError()("StudioApiTransportError",{cause:f.Defect()}){}import{fromPromise as T}from"xstate";var w=()=>Promise.race([]),M=(t)=>T(async({input:s,signal:a})=>{try{let e=await s.runtime.runPromise(t(s),{signal:a});return a.aborted?w():e}catch(e){if(a.aborted)return w();throw e}});import{hashKey as K,isCancelledError as q,QueryObserver as P}from"@tanstack/react-query";import*as x from"effect/Brand";import*as g from"effect/Context";import*as i from"effect/Effect";import*as c from"effect/Exit";import{constVoid as F}from"effect/Function";import*as C from"effect/Layer";import*as D from"effect/Schema";import*as k from"effect/Semaphore";class p extends g.Service()("@collective-intelligence/extensions-sdk-frontend-react/QueryCache"){}var Q=new WeakMap,H=(t,s)=>(a)=>{let e=K(s),r=Q.get(t)??new Map;return Q.set(t,r),i.acquireUseRelease(i.sync(()=>{let n=r.get(e)??{semaphore:k.makeUnsafe(1),users:0};return n.users+=1,r.set(e,n),n}),(n)=>n.semaphore.withPermits(1)(a),(n)=>i.sync(()=>{if(n.users-=1,n.users===0)r.delete(e)}))},B=x.nominal(),j=(t,s,a)=>{let e=t.getQueryData(s);if(e===void 0)return;t.setQueryData(s,a(e));let r=t.getQueryCache().find({exact:!0,queryKey:s});return r===void 0?void 0:B({dataUpdateCount:r.state.dataUpdateCount,query:r,snapshot:e})},z=(t,s)=>{let{query:a}=s;if(t.getQueryCache().get(a.queryHash)===a&&a.state.dataUpdateCount===s.dataUpdateCount)t.setQueryData(a.queryKey,s.snapshot)},A=(t)=>{let s=async({query:e,...r},n)=>{try{return c.succeed(await t.fetchQuery({...r,queryFn:({signal:o})=>i.runPromiseWith(n)(e,{signal:o}),retry:!1}))}catch(o){if(q(o))return c.interrupt();return D.is(S)(o)||D.is(d)(o)?c.fail(o):c.die(o)}},a=(e)=>i.sync(()=>new P(t,{enabled:!1,queryKey:e}).subscribe(F));return p.of({cancel:(e)=>i.promise(()=>t.cancelQueries({queryKey:e})),fetch:(e)=>i.flatMap(i.context(),(r)=>i.acquireUseRelease(a(e.queryKey),()=>i.flatten(i.promise(()=>s(e,r))),(n)=>i.sync(n))),invalidate:(e)=>i.promise(()=>t.invalidateQueries({queryKey:e})),optimisticUpdate:(e,r,n)=>H(t,e)(i.acquireUseRelease(i.promise(()=>t.cancelQueries({exact:!0,queryKey:e})).pipe(i.andThen(i.sync(()=>j(t,e,r)))),()=>n,(o,u)=>i.sync(()=>{if(o!==void 0&&c.isFailure(u))z(t,o);t.invalidateQueries({exact:!0,queryKey:e})}))),remove:(e)=>i.sync(()=>{t.removeQueries({queryKey:e})}),setData:(e,r)=>i.sync(()=>{t.setQueryData(e,r)}),update:(e,r)=>i.sync(()=>{t.setQueriesData({queryKey:e},r)})})},V=(t)=>C.succeed(p,A(t));import{QueryClient as J}from"@tanstack/react-query";import*as v from"effect/Effect";import*as L from"effect/Layer";var X=(t={})=>{let s=t.queryClient??new J({defaultOptions:{queries:{gcTime:1/0}}});for(let[o,u]of t.seed??[])s.setQueryData(o,u);let a=A(s),e=t.overrides??{},r=[],n=(o,u,m)=>v.suspend(()=>(r.push({member:o,queryKey:u}),m()));return{calls:r,layer:L.succeed(p,p.of({cancel:(o)=>n("cancel",o,()=>(e.cancel??a.cancel)(o)),fetch:(o)=>n("fetch",o.queryKey,()=>(e.fetch??a.fetch)(o)),invalidate:(o)=>n("invalidate",o,()=>(e.invalidate??a.invalidate)(o)),optimisticUpdate:(o,u,m)=>n("optimisticUpdate",o,()=>(e.optimisticUpdate??a.optimisticUpdate)(o,u,m)),remove:(o)=>n("remove",o,()=>(e.remove??a.remove)(o)),setData:(o,u)=>n("setData",o,()=>(e.setData??a.setData)(o,u)),update:(o,u)=>n("update",o,()=>(e.update??a.update)(o,u))})),queryClient:s}};import{useQueryClient as Y}from"@tanstack/react-query";import*as G from"effect/ManagedRuntime";import{createContext as Z,useContext as _,useMemo as ee}from"react";import{jsx as oe}from"react/jsx-runtime";var O=Z(null),te=({children:t})=>{let s=Y(),a=ee(()=>G.make(V(s)),[s]);return oe(O.Provider,{value:a,children:t})},re=()=>{let t=_(O);if(t===null)throw Error("useEffectRuntime requires an EffectRuntimeProvider");return t};import{client as ae,studioAgentRunsGet as ie,studioAgentRunsList as se,studioViewDataGetItem as ne,studioViewDataSearch as ue,studioViewDataSearchMembers as ce,studioViewDataUpdateItem as fe,studioWorkflowRunsGet as de,studioWorkflowRunsList as pe}from"@collective-intelligence/extensions-sdk-frontend-react/studio-api";import*as b from"effect/Config";import*as U from"effect/Context";import*as E from"effect/Effect";import*as R from"effect/Layer";class h extends U.Service()("@collective-intelligence/extensions-sdk-frontend-react/StudioApi"){}var me=(t={})=>{let s=t.baseUrl===void 0?{}:{baseUrl:t.baseUrl},a=(e,r)=>E.fn(`StudioApi.${e}`)(function*(o){let u=!1,m=ae.getConfig().fetch??globalThis.fetch,I=Object.assign(async(l,N)=>(u=!0,await m(l,N)),m),y=yield*E.tryPromise({catch:(l)=>{if(u)return new d({cause:l});throw l},try:(l)=>r(o,{...s,fetch:I,responseStyle:"fields",signal:l,throwOnError:!1})});if(y.response===void 0)return yield*new d({cause:y.error});if(!y.response.ok)return yield*new S({body:y.error,status:y.response.status});return y.data});return h.of({studioAgentRunsGet:a("studioAgentRunsGet",(e,r)=>ie({...e,...r})),studioAgentRunsList:a("studioAgentRunsList",(e,r)=>se({...e,...r})),studioViewDataGetItem:a("studioViewDataGetItem",(e,r)=>ne({...e,...r})),studioViewDataSearch:a("studioViewDataSearch",(e,r)=>ue({...e,...r})),studioViewDataSearchMembers:a("studioViewDataSearchMembers",(e,r)=>ce({...e,...r})),studioViewDataUpdateItem:a("studioViewDataUpdateItem",(e,r)=>fe({...e,...r})),studioWorkflowRunsGet:a("studioWorkflowRunsGet",(e,r)=>de({...e,...r})),studioWorkflowRunsList:a("studioWorkflowRunsList",(e,r)=>pe({...e,...r}))})},W=(t={})=>R.sync(h,()=>me(t)),ye=(t)=>R.unwrap(E.map(b.unwrap(t),W));export{te as EffectRuntimeProvider,p as QueryCache,h as StudioApi,S as StudioApiError,d as StudioApiTransportError,M as fromEffect,W as layerStudioApi,ye as layerStudioApiConfig,X as makeTestQueryCache,re as useEffectRuntime};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@collective-intelligence/extensions-sdk-frontend-react",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.16",
|
|
4
4
|
"description": "Public hosted React contribution contracts for Collective Intelligence extensions.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -80,8 +80,8 @@
|
|
|
80
80
|
"type-check": "bun check && bun check -p tsconfig.type-tests.json"
|
|
81
81
|
},
|
|
82
82
|
"dependencies": {
|
|
83
|
-
"@collective-intelligence/extensions-sdk": "0.2.
|
|
84
|
-
"@collective-intelligence/extensions-sdk-frontend": "0.2.
|
|
83
|
+
"@collective-intelligence/extensions-sdk": "0.2.10",
|
|
84
|
+
"@collective-intelligence/extensions-sdk-frontend": "0.2.10"
|
|
85
85
|
},
|
|
86
86
|
"peerDependencies": {
|
|
87
87
|
"@collective-intelligence/ui-react": "0.2.5",
|
|
@@ -106,6 +106,7 @@
|
|
|
106
106
|
"@effect/vitest": "4.1.2",
|
|
107
107
|
"@hey-api/openapi-ts": "^0.96.0",
|
|
108
108
|
"@oxlint/plugins": "1.90.0",
|
|
109
|
+
"@punks/lints": "0.2.0",
|
|
109
110
|
"@tanstack/react-query": "5.101.4",
|
|
110
111
|
"@testing-library/react": "^16.3.2",
|
|
111
112
|
"@types/bun": "1.4.2",
|
|
@@ -128,5 +129,5 @@
|
|
|
128
129
|
"vitest": "5.0.2",
|
|
129
130
|
"xstate": "5.33.3"
|
|
130
131
|
},
|
|
131
|
-
"gitHead": "
|
|
132
|
+
"gitHead": "4cefe91552731170db20795b65c41115fd65c62b"
|
|
132
133
|
}
|