fetchium 0.2.1 → 0.2.3
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/CHANGELOG.md +14 -0
- package/dist/cjs/development/QueryAdapter-DUo338ga.js.map +1 -1
- package/dist/cjs/development/{QueryClient-vYETX2J2.js → QueryClient-Ce5Mnumb.js} +2 -2
- package/dist/cjs/development/QueryClient-Ce5Mnumb.js.map +1 -0
- package/dist/cjs/development/index.js +1 -1
- package/dist/cjs/{production/mutation-BnIsaYdm.js → development/mutation-GI_gTQEB.js} +2 -2
- package/dist/cjs/development/mutation-GI_gTQEB.js.map +1 -0
- package/dist/cjs/development/react/index.js +1 -1
- package/dist/cjs/development/rest/index.js +1 -1
- package/dist/cjs/development/topic/index.js +1 -1
- package/dist/cjs/development/topic/index.js.map +1 -1
- package/dist/cjs/production/QueryAdapter-DUo338ga.js.map +1 -1
- package/dist/cjs/production/{QueryClient-DJoA1ac6.js → QueryClient-BXGk-5PR.js} +2 -2
- package/dist/cjs/production/QueryClient-BXGk-5PR.js.map +1 -0
- package/dist/cjs/production/index.js +1 -1
- package/dist/cjs/{development/mutation-Beh3eks8.js → production/mutation-Bleah98u.js} +2 -2
- package/dist/cjs/production/mutation-Bleah98u.js.map +1 -0
- package/dist/cjs/production/react/index.js +1 -1
- package/dist/cjs/production/rest/index.js +1 -1
- package/dist/cjs/production/topic/index.js +1 -1
- package/dist/cjs/production/topic/index.js.map +1 -1
- package/dist/esm/QueryAdapter.d.ts +11 -0
- package/dist/esm/QueryAdapter.d.ts.map +1 -1
- package/dist/esm/QueryClient.d.ts +20 -6
- package/dist/esm/QueryClient.d.ts.map +1 -1
- package/dist/esm/QueryResult.d.ts.map +1 -1
- package/dist/esm/development/QueryAdapter-Bu5UJjE4.js.map +1 -1
- package/dist/esm/development/{QueryClient-zAD_O9xj.js → QueryClient-CmMSNSpt.js} +72 -48
- package/dist/esm/development/QueryClient-CmMSNSpt.js.map +1 -0
- package/dist/esm/development/index.js +2 -2
- package/dist/esm/development/{mutation-lw06SxbJ.js → mutation-BAM3eYqd.js} +2 -2
- package/dist/esm/development/mutation-BAM3eYqd.js.map +1 -0
- package/dist/esm/development/react/index.js +1 -1
- package/dist/esm/development/rest/index.js +2 -2
- package/dist/esm/development/topic/index.js +19 -18
- package/dist/esm/development/topic/index.js.map +1 -1
- package/dist/esm/mutation.d.ts +3 -3
- package/dist/esm/mutation.d.ts.map +1 -1
- package/dist/esm/production/QueryAdapter-Bu5UJjE4.js.map +1 -1
- package/dist/esm/production/{QueryClient-DSAzqTG6.js → QueryClient-3aWu_mJE.js} +62 -44
- package/dist/esm/production/QueryClient-3aWu_mJE.js.map +1 -0
- package/dist/esm/production/index.js +2 -2
- package/dist/esm/production/{mutation-Dmb9k9FG.js → mutation-YpiJLNWU.js} +2 -2
- package/dist/esm/production/mutation-YpiJLNWU.js.map +1 -0
- package/dist/esm/production/react/index.js +1 -1
- package/dist/esm/production/rest/index.js +2 -2
- package/dist/esm/production/topic/index.js +19 -18
- package/dist/esm/production/topic/index.js.map +1 -1
- package/dist/esm/query.d.ts +3 -3
- package/dist/esm/query.d.ts.map +1 -1
- package/dist/esm/topic/TopicQuery.d.ts +3 -2
- package/dist/esm/topic/TopicQuery.d.ts.map +1 -1
- package/package.json +1 -1
- package/plugin/docs/api/fetchium.md +2 -2
- package/plugin/docs/api/stores-async.md +9 -3
- package/plugin/docs/api/stores-sync.md +9 -3
- package/plugin/docs/core/entities.md +2 -2
- package/plugin/docs/core/queries.md +12 -19
- package/plugin/docs/core/streaming.md +7 -9
- package/plugin/docs/data/mutations.md +1 -1
- package/plugin/docs/guides/auth.md +65 -42
- package/plugin/docs/guides/error-handling.md +9 -5
- package/plugin/docs/guides/offline.md +11 -8
- package/plugin/docs/guides/testing.md +1 -1
- package/plugin/docs/quickstart.md +1 -1
- package/plugin/docs/reference/rest-queries.md +9 -9
- package/plugin/docs/setup/project-setup.md +5 -5
- package/dist/cjs/development/QueryClient-vYETX2J2.js.map +0 -1
- package/dist/cjs/development/mutation-Beh3eks8.js.map +0 -1
- package/dist/cjs/production/QueryClient-DJoA1ac6.js.map +0 -1
- package/dist/cjs/production/mutation-BnIsaYdm.js.map +0 -1
- package/dist/esm/development/QueryClient-zAD_O9xj.js.map +0 -1
- package/dist/esm/development/mutation-lw06SxbJ.js.map +0 -1
- package/dist/esm/production/QueryClient-DSAzqTG6.js.map +0 -1
- package/dist/esm/production/mutation-Dmb9k9FG.js.map +0 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./QueryClient-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./QueryClient-BXGk-5PR.js"),r=require("./QueryAdapter-DUo338ga.js"),t=require("./mutation-Bleah98u.js");exports.ARRAY_KEY=e.ARRAY_KEY;exports.Entity=e.Entity;exports.GcManager=e.GcManager;exports.LiveFieldConfig=e.LiveFieldConfig;exports.LiveFieldType=e.LiveFieldType;exports.Mask=e.Mask;exports.NetworkManager=e.NetworkManager;exports.NetworkManagerContext=e.NetworkManagerContext;exports.NetworkMode=e.NetworkMode;exports.NoOpGcManager=e.NoOpGcManager;exports.NoOpNetworkManager=e.NoOpNetworkManager;exports.QUERY_ID=e.QUERY_ID;exports.Query=e.Query;exports.QueryClient=e.QueryClient;exports.QueryClientContext=e.QueryClientContext;exports.RECORD_KEY=e.RECORD_KEY;exports.defaultNetworkManager=e.defaultNetworkManager;exports.draft=e.draft;exports.fetchQuery=e.fetchQuery;exports.queryKeyForClass=e.queryKeyForClass;exports.registerFormat=e.registerFormat;exports.t=e.t;exports.QueryAdapter=r.QueryAdapter;exports.Mutation=t.Mutation;exports.getMutation=t.getMutation;exports.mutationKeyForClass=t.mutationKeyForClass;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";const g=require("signalium"),o=require("./QueryClient-
|
|
2
|
-
//# sourceMappingURL=mutation-
|
|
1
|
+
"use strict";const g=require("signalium"),o=require("./QueryClient-BXGk-5PR.js");class y{static adapter;params;result;optimisticUpdates;config;effects;constructor(){return o.createDefinitionProxy(this)}}const c=new WeakMap,h=t=>{const e=c.get(t);if(e===void 0)throw new Error("Mutation definition not found");return e().id};function D(t){let e=c.get(t);if(e!==void 0)return e;let n;const f=()=>{if(n!==void 0)return n;const d=new t,r=o.extractDefinition(d),{fields:i}=r,p=`mutation:${String(r.methods.getIdentityKey.call(i))}`,a=i.params??{},l=a instanceof o.ValidatorDef?a:o.t.object(a),s=i.result,m=s!==void 0?s instanceof o.ValidatorDef?s:o.t.object(s):void 0,u=t.adapter;if(!u)throw new Error(`Mutation class "${t.name}" must define a static \`adapter\` property. Extend RESTMutation (from fetchium/rest) or set \`static adapter = MyAdapter\` on your mutation class.`);return n={id:p,requestShape:l,responseShape:m,captured:r,optimisticUpdates:i.optimisticUpdates??!1,config:i.config,effects:i.effects,hasGetEffects:typeof r.methods.getEffects=="function",adapterClass:u},n};return c.set(t,f),f}function M(t){const e=D(t),n=g.getContext(o.QueryClientContext);if(n===void 0)throw new Error("QueryClient not found");return n.getMutation(e())}exports.Mutation=y;exports.getMutation=M;exports.mutationKeyForClass=h;
|
|
2
|
+
//# sourceMappingURL=mutation-Bleah98u.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutation-Bleah98u.js","sources":["../../../src/mutation.ts"],"sourcesContent":["import { getContext, ReactiveTask } from 'signalium';\nimport { ExtractType, InternalTypeDef, MutationEffects, TypeDef, RetryConfig, TypeDefShape } from './types.js';\nimport { QueryClientContext, type QueryContext } from './QueryClient.js';\nimport { ValidatorDef, t } from './typeDefs.js';\nimport { createDefinitionProxy, extractDefinition, type CapturedDefinition } from './fieldRef.js';\nimport type { QueryAdapter, QueryAdapterClass } from './QueryAdapter.js';\n\n// ================================\n// Mutation Definition Types\n// ================================\n\nexport interface MutationConfigOptions {\n retry?: RetryConfig | number | false;\n}\n\nexport interface MutationDefinition<Request, Response> {\n id: string;\n requestShape: InternalTypeDef;\n responseShape: InternalTypeDef | undefined;\n captured: CapturedDefinition<Mutation>;\n optimisticUpdates: boolean;\n config?: MutationConfigOptions;\n effects?: MutationEffects;\n hasGetEffects: boolean;\n adapterClass: QueryAdapterClass;\n}\n\n// ================================\n// Mutation base class\n// ================================\n\nexport abstract class Mutation {\n static adapter?: QueryAdapterClass;\n\n readonly params?: TypeDefShape;\n readonly result?: TypeDefShape;\n readonly optimisticUpdates?: boolean;\n readonly config?: MutationConfigOptions;\n readonly effects?: Readonly<MutationEffects>;\n\n declare context: QueryContext;\n\n abstract getIdentityKey(): unknown;\n\n getEffects?(): MutationEffects;\n\n constructor() {\n return createDefinitionProxy(this);\n }\n}\n\n// ================================\n// Mutation definition cache and lookup\n// ================================\n\nconst mutationDefCache = new WeakMap<new () => Mutation, () => MutationDefinition<any, any>>();\n\nexport const mutationKeyForClass = (cls: new () => Mutation): string => {\n const getMutationDef = mutationDefCache.get(cls);\n\n if (getMutationDef === undefined) {\n throw new Error('Mutation definition not found');\n }\n\n return getMutationDef().id;\n};\n\n// ================================\n// Internal: build mutation definition from class\n// ================================\n\nfunction buildMutationDefinition(MutationClass: new () => Mutation): () => MutationDefinition<any, any> {\n let cached = mutationDefCache.get(MutationClass);\n\n if (cached !== undefined) {\n return cached;\n }\n\n let mutationDefinition: MutationDefinition<any, any> | undefined;\n\n const getter = (): MutationDefinition<any, any> => {\n if (mutationDefinition !== undefined) {\n return mutationDefinition;\n }\n\n const instance = new MutationClass();\n const captured = extractDefinition(instance);\n const { fields } = captured;\n\n const id = `mutation:${String(captured.methods.getIdentityKey.call(fields))}`;\n\n const requestDef = fields.params ?? {};\n const requestShape = (requestDef instanceof ValidatorDef\n ? requestDef\n : t.object(requestDef)) as unknown as InternalTypeDef;\n const responseDef = fields.result;\n const responseShape =\n responseDef !== undefined\n ? ((responseDef instanceof ValidatorDef ? responseDef : t.object(responseDef)) as unknown as InternalTypeDef)\n : undefined;\n\n const adapterClass = (MutationClass as typeof Mutation).adapter;\n if (!adapterClass) {\n throw new Error(\n `Mutation class \"${MutationClass.name}\" must define a static \\`adapter\\` property. ` +\n `Extend RESTMutation (from fetchium/rest) or set \\`static adapter = MyAdapter\\` on your mutation class.`,\n );\n }\n\n mutationDefinition = {\n id,\n requestShape,\n responseShape,\n captured,\n optimisticUpdates: fields.optimisticUpdates ?? false,\n config: fields.config,\n effects: fields.effects,\n hasGetEffects: typeof captured.methods.getEffects === 'function',\n adapterClass,\n };\n\n return mutationDefinition;\n };\n\n mutationDefCache.set(MutationClass, getter);\n return getter;\n}\n\n// ================================\n// Public API\n// ================================\n\nexport function getMutation<T extends Mutation>(\n MutationClass: new () => T,\n): ReactiveTask<Readonly<ExtractType<T['result']>>, [ExtractType<T['params']>]> {\n const getMutationDef = buildMutationDefinition(MutationClass);\n\n const queryClient = getContext(QueryClientContext);\n\n if (queryClient === undefined) {\n throw new Error('QueryClient not found');\n }\n\n return queryClient.getMutation<any, any>(getMutationDef());\n}\n"],"names":["Mutation","createDefinitionProxy","mutationDefCache","mutationKeyForClass","cls","getMutationDef","buildMutationDefinition","MutationClass","cached","mutationDefinition","getter","instance","captured","extractDefinition","fields","id","requestDef","requestShape","ValidatorDef","t","responseDef","responseShape","adapterClass","getMutation","queryClient","getContext","QueryClientContext"],"mappings":"iFA+BO,MAAeA,CAAS,CAC7B,OAAO,QAEE,OACA,OACA,kBACA,OACA,QAQT,aAAc,CACZ,OAAOC,EAAAA,sBAAsB,IAAI,CACnC,CACF,CAMA,MAAMC,MAAuB,QAEhBC,EAAuBC,GAAoC,CACtE,MAAMC,EAAiBH,EAAiB,IAAIE,CAAG,EAE/C,GAAIC,IAAmB,OACrB,MAAM,IAAI,MAAM,+BAA+B,EAGjD,OAAOA,IAAiB,EAC1B,EAMA,SAASC,EAAwBC,EAAuE,CACtG,IAAIC,EAASN,EAAiB,IAAIK,CAAa,EAE/C,GAAIC,IAAW,OACb,OAAOA,EAGT,IAAIC,EAEJ,MAAMC,EAAS,IAAoC,CACjD,GAAID,IAAuB,OACzB,OAAOA,EAGT,MAAME,EAAW,IAAIJ,EACfK,EAAWC,EAAAA,kBAAkBF,CAAQ,EACrC,CAAE,OAAAG,GAAWF,EAEbG,EAAK,YAAY,OAAOH,EAAS,QAAQ,eAAe,KAAKE,CAAM,CAAC,CAAC,GAErEE,EAAaF,EAAO,QAAU,CAAA,EAC9BG,EAAgBD,aAAsBE,EAAAA,aACxCF,EACAG,EAAAA,EAAE,OAAOH,CAAU,EACjBI,EAAcN,EAAO,OACrBO,EACJD,IAAgB,OACVA,aAAuBF,EAAAA,aAAeE,EAAcD,IAAE,OAAOC,CAAW,EAC1E,OAEAE,EAAgBf,EAAkC,QACxD,GAAI,CAACe,EACH,MAAM,IAAI,MACR,mBAAmBf,EAAc,IAAI,qJAAA,EAKzC,OAAAE,EAAqB,CACnB,GAAAM,EACA,aAAAE,EACA,cAAAI,EACA,SAAAT,EACA,kBAAmBE,EAAO,mBAAqB,GAC/C,OAAQA,EAAO,OACf,QAASA,EAAO,QAChB,cAAe,OAAOF,EAAS,QAAQ,YAAe,WACtD,aAAAU,CAAA,EAGKb,CACT,EAEA,OAAAP,EAAiB,IAAIK,EAAeG,CAAM,EACnCA,CACT,CAMO,SAASa,EACdhB,EAC8E,CAC9E,MAAMF,EAAiBC,EAAwBC,CAAa,EAEtDiB,EAAcC,EAAAA,WAAWC,oBAAkB,EAEjD,GAAIF,IAAgB,OAClB,MAAM,IAAI,MAAM,uBAAuB,EAGzC,OAAOA,EAAY,YAAsBnB,GAAgB,CAC3D"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("signalium/react"),i=require("signalium"),f=require("../QueryClient-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("signalium/react"),i=require("signalium"),f=require("../QueryClient-BXGk-5PR.js");function n(e){if(Array.isArray(e))return e.map(n);if(e&&typeof e=="object"){if(e instanceof Date)return new Date(e);if(e instanceof RegExp)return new RegExp(e);if(e instanceof Map)return new Map(Array.from(e.entries()).map(([t,c])=>[n(t),n(c)]));if(e instanceof Set)return new Set(Array.from(e).map(n));const r=Object.create(Object.getPrototypeOf(e));for(const t of Object.keys(e))r[t]=n(e[t]);return r}return e}const y=i.reactive(e=>n(e.value)),a=i.reactive((e,...r)=>{const t=f.fetchQuery(e,...r);return new Proxy(t,{get(c,o,u){return o==="value"?y(c):Reflect.get(c,o,u)}})}),p=i.reactive(e=>e.value);function g(e,...r){const t=s.useReactive(a,e,...r);return s.useReactive(p,t),t}exports.useQuery=g;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../QueryClient-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../QueryClient-BXGk-5PR.js"),q=require("../QueryAdapter-DUo338ga.js"),T=require("../mutation-Bleah98u.js");class f extends q.QueryAdapter{_fetch;_baseUrl;constructor(e){super(),this._fetch=e?.fetch??globalThis.fetch,this._baseUrl=e?.baseUrl}async send(e,s){return this.executeRequest(e,s)}async sendNext(e,s){const t=this.resolveFetchNext(e);if(t===void 0)throw new Error("fetchNext is not configured for this query");return this.executeRequest(e,s,t)}hasNext(e){const s=this.resolveFetchNext(e);if(s===void 0)return!1;if(s.url!==void 0&&s.url!==null)return!0;if(s.searchParams!==void 0){const t=Object.keys(s.searchParams);if(t.length===0)return!1;for(const r of t)if(s.searchParams[r]===void 0||s.searchParams[r]===null)return!1;return!0}return!1}resolveFetchNext(e){const t=(e.getFetchNext?e.getFetchNext():void 0)??e.rawFetchNext;if(t===void 0)return;const r={params:e.params??{},result:e.resultData};return{url:t.url!==void 0?i.reifyValue(t.url,r):void 0,searchParams:t.searchParams!==void 0?i.reifyValue(t.searchParams,r):void 0}}buildUrl(e,s){if(e.startsWith("http://")||e.startsWith("https://")||e.startsWith("//"))return e;if(e.startsWith("/")){const t=i.resolveBaseUrl(s)??i.resolveBaseUrl(this._baseUrl)??globalThis.location?.origin;if(!t)throw new Error(`RESTQueryAdapter: cannot resolve URL for path "${e}". Set \`baseUrl\` on the query/mutation, pass it to \`new RESTQueryAdapter({ baseUrl })\`, or use an absolute URL.`);return`${t}${e}`}return e}async executeRequest(e,s,t){const r=t?.url??(e.getPath?e.getPath():e.path),u=e.getMethod?e.getMethod():e.method,a=e.getSearchParams?e.getSearchParams():e.searchParams,o=t?.searchParams?{...a,...t.searchParams}:a,n=e.getBody?e.getBody():e.body,h=e.getRequestOptions?e.getRequestOptions():e.requestOptions;if(!r)throw new Error("RESTQuery requires a path. Define `path` as a field or override `getPath()`.");let l=r;if(o){const m=new URLSearchParams;for(const U in o){const c=o[U];c!=null&&m.append(U,String(c))}const v=m.toString();v&&(l+="?"+v)}const p=h?.baseUrl??e.baseUrl,d=this.buildUrl(l,p),{baseUrl:g,signal:P,...R}=h??{},S=n||e.headers?{...n?{"Content-Type":"application/json"}:void 0,...e.headers}:void 0,b=await this._fetch(d,{method:u,headers:S,body:n?JSON.stringify(n):void 0,signal:s,...R});return e.response=b,b.json()}async sendMutation(e,s){const t=e,r=t.getPath?t.getPath():t.path,u=t.getMethod?t.getMethod():t.method,a=t.getBody?t.getBody():t.body,o=t.getRequestOptions?t.getRequestOptions():t.requestOptions;if(!r)throw new Error("RESTMutation requires a path. Define `path` as a field or override `getPath()`.");const n=o?.baseUrl??t.baseUrl,h=this.buildUrl(r,n),{baseUrl:l,signal:p,...d}=o??{},g={...a!==void 0?{"Content-Type":"application/json"}:{},...t.headers};return(await this._fetch(h,{method:u,headers:g,...a!==void 0?{body:JSON.stringify(a)}:{},signal:s,...d})).json()}}class O extends i.Query{static adapter=f;method="GET";path;baseUrl;searchParams;body;headers;requestOptions;fetchNext;getIdentityKey(){return`${this.method??"GET"}:${this.path??""}`}}class E extends T.Mutation{static adapter=f;path;baseUrl;method="POST";body;headers;requestOptions;getIdentityKey(){return`${this.method??"POST"}:${this.path??""}`}}exports.RESTMutation=E;exports.RESTQuery=O;exports.RESTQueryAdapter=f;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("../QueryClient-BXGk-5PR.js"),h=require("../QueryAdapter-DUo338ga.js");class p extends h.QueryAdapter{_topics=new Map;fulfillTopic(e,s){const t=this._topics.get(e);if(t===void 0){this._topics.set(e,{status:"fulfilled",data:s});return}t.status==="pending"&&(t.status="fulfilled",t.data=s,t.resolve(s))}rejectTopic(e,s){const t=this._topics.get(e);if(t===void 0){this._topics.set(e,{status:"rejected",error:s});return}t.status==="pending"&&(t.status="rejected",t.error=s,t.reject(s))}clearTopic(e){this._topics.delete(e)}clearAll(){this._topics.clear()}async send(e,s){const t=e;t._topicAdapter=this;const r=t.topic,i=this._topics.get(r);if(i)switch(i.status){case"fulfilled":return i.data;case"rejected":throw i.error;case"pending":return i.promise}let c,o;const n=new Promise((u,l)=>{c=u,o=l});return this._topics.set(r,{status:"pending",promise:n,resolve:c,reject:o}),this.subscribe(r),n}sendMutationEvent(e){this.queryClient.applyMutationEvent(e)}}class f extends d.Query{static adapter=p;getIdentityKey(){return`topic:${this.topic}`}getConfig(){return{staleTime:0,subscribe:()=>()=>{this._topicAdapter?.unsubscribe(this.topic)}}}}exports.TopicQuery=f;exports.TopicQueryAdapter=p;
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../../src/topic/
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../../src/topic/TopicQueryAdapter.ts","../../../../src/topic/TopicQuery.ts"],"sourcesContent":["import { QueryAdapter } from '../QueryAdapter.js';\nimport type { Query } from '../query.js';\nimport type { MutationEvent } from '../types.js';\n\n// ================================\n// TopicQueryAdapter — abstract adapter for topic-based subscriptions\n// ================================\n\ninterface TopicCtx extends Query {\n topic: string;\n _topicAdapter?: TopicQueryAdapter;\n}\n\ninterface TopicState {\n status: 'pending' | 'fulfilled' | 'rejected';\n promise?: Promise<unknown>;\n resolve?: (data: unknown) => void;\n reject?: (error: unknown) => void;\n data?: unknown;\n error?: unknown;\n}\n\nexport abstract class TopicQueryAdapter extends QueryAdapter {\n private _topics = new Map<string, TopicState>();\n\n /**\n * Called when a query activates for a given topic.\n * Implementations should start delivering data for this topic,\n * calling `fulfillTopic()` when initial data is available and\n * `sendMutationEvent()` for ongoing updates.\n */\n abstract subscribe(topic: string): void;\n\n /**\n * Called when the query deactivates. Implementations should\n * tear down any resources for this topic.\n */\n abstract unsubscribe(topic: string): void;\n\n /**\n * Resolve the pending promise for a topic with initial data.\n * Can be called before `send()` — the data will be picked up\n * when the query activates.\n */\n protected fulfillTopic(topic: string, data: unknown): void {\n const state = this._topics.get(topic);\n\n if (state === undefined) {\n this._topics.set(topic, { status: 'fulfilled', data });\n return;\n }\n\n if (state.status === 'pending') {\n state.status = 'fulfilled';\n state.data = data;\n state.resolve!(data);\n }\n }\n\n /**\n * Reject the pending promise for a topic.\n * Can be called before `send()` — the error will be propagated\n * when the query activates.\n */\n protected rejectTopic(topic: string, error: unknown): void {\n const state = this._topics.get(topic);\n\n if (state === undefined) {\n this._topics.set(topic, { status: 'rejected', error });\n return;\n }\n\n if (state.status === 'pending') {\n state.status = 'rejected';\n state.error = error;\n state.reject!(error);\n }\n }\n\n /**\n * Clears internal state for a topic. Called automatically by\n * `unsubscribe` — subclasses generally don't need to call this.\n */\n protected clearTopic(topic: string): void {\n this._topics.delete(topic);\n }\n\n protected clearAll(): void {\n this._topics.clear();\n }\n\n override async send(ctx: Query, _signal: AbortSignal): Promise<unknown> {\n const topicCtx = ctx as TopicCtx;\n topicCtx._topicAdapter = this;\n const topic = topicCtx.topic;\n\n const existing = this._topics.get(topic);\n\n if (existing) {\n switch (existing.status) {\n case 'fulfilled':\n return existing.data;\n case 'rejected':\n throw existing.error;\n case 'pending':\n return existing.promise;\n }\n }\n\n // No state yet — create a deferred and subscribe\n let resolve!: (data: unknown) => void;\n let reject!: (error: unknown) => void;\n const promise = new Promise<unknown>((res, rej) => {\n resolve = res;\n reject = rej;\n });\n\n this._topics.set(topic, { status: 'pending', promise, resolve, reject });\n this.subscribe(topic);\n\n return promise;\n }\n\n /**\n * Convenience wrapper — pushes a mutation event through the QueryClient\n * so that entities and live collections are updated reactively.\n */\n protected sendMutationEvent(event: MutationEvent): void {\n this.queryClient!.applyMutationEvent(event);\n }\n}\n","import { Query } from '../query.js';\nimport { TopicQueryAdapter } from './TopicQueryAdapter.js';\nimport type { QueryAdapterClass } from '../QueryAdapter.js';\nimport type { QueryConfigOptions } from '../query-types.js';\n\n// ================================\n// TopicQuery — declarative topic-based query definition\n// ================================\n\nexport abstract class TopicQuery extends Query {\n // Explicit type lets subclasses override with adapters that take constructor args.\n static override adapter: QueryAdapterClass<TopicQueryAdapter> = TopicQueryAdapter;\n\n abstract topic: string;\n\n getIdentityKey(): string {\n return `topic:${this.topic}`;\n }\n\n getConfig(): QueryConfigOptions {\n return {\n staleTime: 0,\n subscribe: () => {\n return () => {\n const adapter = (this as Record<string, any>)._topicAdapter as TopicQueryAdapter | undefined;\n adapter?.unsubscribe(this.topic);\n };\n },\n };\n }\n}\n"],"names":["TopicQueryAdapter","QueryAdapter","topic","data","state","error","ctx","_signal","topicCtx","existing","resolve","reject","promise","res","rej","event","TopicQuery","Query"],"mappings":"uKAsBO,MAAeA,UAA0BC,EAAAA,YAAa,CACnD,YAAc,IAqBZ,aAAaC,EAAeC,EAAqB,CACzD,MAAMC,EAAQ,KAAK,QAAQ,IAAIF,CAAK,EAEpC,GAAIE,IAAU,OAAW,CACvB,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,WAAgC,CAC9B,MAAO,CACL,UAAW,EACX,UAAW,IACF,IAAM,CACM,KAA6B,eACrC,YAAY,KAAK,KAAK,CACjC,CACF,CAEJ,CACF"}
|
|
@@ -5,6 +5,17 @@ export interface IQueryClientForAdapter {
|
|
|
5
5
|
getContext(): QueryContext;
|
|
6
6
|
applyMutationEvent(event: import('./types.js').MutationEvent): void;
|
|
7
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* A reference to an adapter class (abstract or concrete) with any constructor
|
|
10
|
+
* signature. Used as the type of `static adapter` properties on Query/Mutation
|
|
11
|
+
* classes, so that subclasses with required constructor arguments can be
|
|
12
|
+
* assigned directly without casts.
|
|
13
|
+
*
|
|
14
|
+
* The framework never instantiates these classes via this type (adapters are
|
|
15
|
+
* registered as pre-built instances on the QueryClient); it only uses the
|
|
16
|
+
* reference as a map key and for prototype/name introspection.
|
|
17
|
+
*/
|
|
18
|
+
export type QueryAdapterClass<T extends QueryAdapter = QueryAdapter> = abstract new (...args: any[]) => T;
|
|
8
19
|
export declare abstract class QueryAdapter {
|
|
9
20
|
protected queryClient: IQueryClientForAdapter | undefined;
|
|
10
21
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryAdapter.d.ts","sourceRoot":"","sources":["../../src/QueryAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAO9C,MAAM,WAAW,sBAAsB;IACrC,UAAU,IAAI,YAAY,CAAC;IAC3B,kBAAkB,CAAC,KAAK,EAAE,OAAO,YAAY,EAAE,aAAa,GAAG,IAAI,CAAC;CACrE;AAMD,8BAAsB,YAAY;IAChC,SAAS,CAAC,WAAW,EAAE,sBAAsB,GAAG,SAAS,CAAC;IAE1D;;;OAGG;IACH,QAAQ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WAAW,EAAE,sBAAsB,GAAG,IAAI;IAInD;;;OAGG;IACH,qBAAqB,CAAC,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI;IAE/C;;;OAGG;IACH,OAAO,CAAC,IAAI,IAAI;IAEhB;;;;OAIG;IACH,QAAQ,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;IAEhE;;;;OAIG;IACH,QAAQ,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;IAE5D;;;OAGG;IACH,OAAO,CAAC,CAAC,GAAG,EAAE,KAAK,GAAG,OAAO;IAE7B;;;;OAIG;IACH,YAAY,CAAC,CAAC,GAAG,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC;CACpE"}
|
|
@@ -2,7 +2,7 @@ import { ReactiveTask, type Context } from 'signalium';
|
|
|
2
2
|
import { EntityDef, MutationEvent, QueryPromise, InternalTypeDef, InvalidateTarget } from './types.js';
|
|
3
3
|
import { EntityStore } from './EntityStore.js';
|
|
4
4
|
import { EntityInstance } from './EntityInstance.js';
|
|
5
|
-
import { NetworkManager } from './NetworkManager.js';
|
|
5
|
+
import { NetworkManager, NoOpNetworkManager } from './NetworkManager.js';
|
|
6
6
|
import { QueryInstance } from './QueryResult.js';
|
|
7
7
|
import { MutationResultImpl } from './MutationResult.js';
|
|
8
8
|
import { MutationDefinition } from './mutation.js';
|
|
@@ -13,12 +13,12 @@ import { type ApplyResult } from './applyEntities.js';
|
|
|
13
13
|
import { ValidatorDef } from './typeDefs.js';
|
|
14
14
|
import { ConstraintMatcher } from './ConstraintMatcher.js';
|
|
15
15
|
import { LiveCollectionBinding } from './LiveCollection.js';
|
|
16
|
-
import { QueryAdapter } from './QueryAdapter.js';
|
|
16
|
+
import { QueryAdapter, type QueryAdapterClass } from './QueryAdapter.js';
|
|
17
17
|
import { type QueryContext, type QueryStore, type QueryParams, type PreloadedEntityMap } from './query-types.js';
|
|
18
18
|
export interface QueryClientConfig {
|
|
19
19
|
store?: QueryStore;
|
|
20
20
|
adapters?: QueryAdapter[];
|
|
21
|
-
networkManager?: NetworkManager;
|
|
21
|
+
networkManager?: NetworkManager | NoOpNetworkManager;
|
|
22
22
|
gcManager?: GcManager | NoOpGcManager;
|
|
23
23
|
log?: {
|
|
24
24
|
error?: (message: string, error?: unknown) => void;
|
|
@@ -34,7 +34,7 @@ export declare class QueryClient {
|
|
|
34
34
|
queryInstances: Map<number, QueryInstance<any>>;
|
|
35
35
|
mutationInstances: Map<string, MutationResultImpl<unknown, unknown>>;
|
|
36
36
|
gcManager: GcManager | NoOpGcManager;
|
|
37
|
-
networkManager: NetworkManager;
|
|
37
|
+
networkManager: NetworkManager | NoOpNetworkManager;
|
|
38
38
|
isServer: boolean;
|
|
39
39
|
store: QueryStore;
|
|
40
40
|
currentParseId: number;
|
|
@@ -47,9 +47,23 @@ export declare class QueryClient {
|
|
|
47
47
|
constructor(config?: QueryClientConfig);
|
|
48
48
|
/**
|
|
49
49
|
* Returns the registered adapter instance for the given adapter class.
|
|
50
|
-
*
|
|
50
|
+
*
|
|
51
|
+
* Resolution order:
|
|
52
|
+
* 1. Exact class match in the registered adapters.
|
|
53
|
+
* 2. Subclass match — if any registered adapter is an `instanceof adapterClass`,
|
|
54
|
+
* return it. This lets queries declare an abstract base adapter (e.g.
|
|
55
|
+
* `TopicQueryAdapter`) and have the consumer-supplied concrete subclass
|
|
56
|
+
* (e.g. a `WebSocket`-backed adapter) resolve to it.
|
|
57
|
+
* 3. Auto-instantiate via the no-arg constructor (for adapters like
|
|
58
|
+
* `RESTQueryAdapter` that default to `globalThis.fetch`).
|
|
59
|
+
*
|
|
60
|
+
* In dev builds, step 2 verifies that at most one registered adapter
|
|
61
|
+
* matches the lookup and throws otherwise. The dev-only check is stripped
|
|
62
|
+
* from production builds.
|
|
63
|
+
*
|
|
64
|
+
* Throws if none of those succeed.
|
|
51
65
|
*/
|
|
52
|
-
getAdapter(adapterClass:
|
|
66
|
+
getAdapter(adapterClass: QueryAdapterClass): QueryAdapter;
|
|
53
67
|
getContext(): QueryContext;
|
|
54
68
|
private registerEntityDef;
|
|
55
69
|
getEntityDefsForTypename(typename: string): ValidatorDef<any>[] | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryClient.d.ts","sourceRoot":"","sources":["../../src/QueryClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,YAAY,EAAE,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzE,OAAO,EACL,SAAS,EACT,aAAa,EACb,YAAY,EAEZ,eAAe,EAEf,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"QueryClient.d.ts","sourceRoot":"","sources":["../../src/QueryClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,YAAY,EAAE,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzE,OAAO,EACL,SAAS,EACT,aAAa,EACb,YAAY,EAEZ,eAAe,EAEf,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AACnD,OAAO,E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C,2BAA2B;IAgBnC,OAAO,CAAC,sBAAsB;YAMhB,QAAQ;IA8BtB,OAAO,CAAC,mBAAmB;IAS3B,OAAO,CAAC,YAAY;IAiBpB,OAAO,QAAO,4BAA4B,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAIxD;IAEF,SAAS,IAAI,IAAI;IAIjB,IAAI,cAAc,IAAI,WAAW,GAAG,SAAS,CAE5C;IAED,qDAAqD;IACrD,OAAO,CAAC,iBAAiB,CAAkD;IAE3E,4CAA4C;IAC5C,OAAO,CAAC,eAAe,CAA0C;IAEjE,SAAS,QAAO,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CA4BrC;IAEF,OAAO,KAAK,OAAO,GAMlB;YAEa,YAAY;IA2B1B,OAAO,KAAK,OAAO,GAOlB;IAED,OAAO,KAAK,QAAQ,GAiBnB;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryAdapter-Bu5UJjE4.js","sources":["../../../src/QueryAdapter.ts"],"sourcesContent":["import { type QueryContext } from './query-types.js';\nimport type { Query } from './query.js';\nimport type { Mutation } from './mutation.js';\n\n// ================================\n// IQueryClient — minimal interface QueryAdapter needs from the client\n// (avoids circular import: QueryClient → QueryAdapter → QueryClient)\n// ================================\n\nexport interface IQueryClientForAdapter {\n getContext(): QueryContext;\n applyMutationEvent(event: import('./types.js').MutationEvent): void;\n}\n\n// ================================\n// QueryAdapter base class\n// ================================\n\nexport abstract class QueryAdapter {\n protected queryClient: IQueryClientForAdapter | undefined;\n\n /**\n * Called once by QueryClient when this adapter is registered.\n * Subclasses can override to do setup (e.g. open a WebSocket connection).\n */\n register(queryClient: IQueryClientForAdapter): void {\n this.queryClient = queryClient;\n }\n\n /**\n * Called when the network comes online or goes offline.\n * Subclasses can override to reconnect persistent connections (e.g. WebSocket).\n */\n onNetworkStatusChange?(isOnline: boolean): void;\n\n /**\n * Called when the QueryClient is destroyed.\n * Subclasses can override to clean up connections or timers.\n */\n destroy?(): void;\n\n /**\n * Send the query and return the raw response data.\n * @param ctx The query execution context (a reified Query instance with params applied).\n * @param signal AbortSignal to cancel the in-flight request.\n */\n abstract send(ctx: Query, signal: AbortSignal): Promise<unknown>;\n\n /**\n * Fetch the next page of results. Only implement if the adapter supports pagination.\n * @param ctx The query execution context. `ctx.resultData` contains the current page's data.\n * @param signal AbortSignal to cancel the in-flight request.\n */\n sendNext?(ctx: Query, signal: AbortSignal): Promise<unknown>;\n\n /**\n * Return true if more pages are available for the current result.\n * Called reactively — do not perform async work here.\n */\n hasNext?(ctx: Query): boolean;\n\n /**\n * Send a mutation and return the raw response data.\n * @param ctx The mutation execution context (a reified Mutation instance with params applied).\n * @param signal AbortSignal to cancel the in-flight request.\n */\n sendMutation?(ctx: Mutation, signal: AbortSignal): Promise<unknown>;\n}\n"],"names":["QueryAdapter","queryClient"],"mappings":"
|
|
1
|
+
{"version":3,"file":"QueryAdapter-Bu5UJjE4.js","sources":["../../../src/QueryAdapter.ts"],"sourcesContent":["import { type QueryContext } from './query-types.js';\nimport type { Query } from './query.js';\nimport type { Mutation } from './mutation.js';\n\n// ================================\n// IQueryClient — minimal interface QueryAdapter needs from the client\n// (avoids circular import: QueryClient → QueryAdapter → QueryClient)\n// ================================\n\nexport interface IQueryClientForAdapter {\n getContext(): QueryContext;\n applyMutationEvent(event: import('./types.js').MutationEvent): void;\n}\n\n// ================================\n// QueryAdapterClass — constructor reference for an adapter class\n// ================================\n\n/**\n * A reference to an adapter class (abstract or concrete) with any constructor\n * signature. Used as the type of `static adapter` properties on Query/Mutation\n * classes, so that subclasses with required constructor arguments can be\n * assigned directly without casts.\n *\n * The framework never instantiates these classes via this type (adapters are\n * registered as pre-built instances on the QueryClient); it only uses the\n * reference as a map key and for prototype/name introspection.\n */\nexport type QueryAdapterClass<T extends QueryAdapter = QueryAdapter> = abstract new (...args: any[]) => T;\n\n// ================================\n// QueryAdapter base class\n// ================================\n\nexport abstract class QueryAdapter {\n protected queryClient: IQueryClientForAdapter | undefined;\n\n /**\n * Called once by QueryClient when this adapter is registered.\n * Subclasses can override to do setup (e.g. open a WebSocket connection).\n */\n register(queryClient: IQueryClientForAdapter): void {\n this.queryClient = queryClient;\n }\n\n /**\n * Called when the network comes online or goes offline.\n * Subclasses can override to reconnect persistent connections (e.g. WebSocket).\n */\n onNetworkStatusChange?(isOnline: boolean): void;\n\n /**\n * Called when the QueryClient is destroyed.\n * Subclasses can override to clean up connections or timers.\n */\n destroy?(): void;\n\n /**\n * Send the query and return the raw response data.\n * @param ctx The query execution context (a reified Query instance with params applied).\n * @param signal AbortSignal to cancel the in-flight request.\n */\n abstract send(ctx: Query, signal: AbortSignal): Promise<unknown>;\n\n /**\n * Fetch the next page of results. Only implement if the adapter supports pagination.\n * @param ctx The query execution context. `ctx.resultData` contains the current page's data.\n * @param signal AbortSignal to cancel the in-flight request.\n */\n sendNext?(ctx: Query, signal: AbortSignal): Promise<unknown>;\n\n /**\n * Return true if more pages are available for the current result.\n * Called reactively — do not perform async work here.\n */\n hasNext?(ctx: Query): boolean;\n\n /**\n * Send a mutation and return the raw response data.\n * @param ctx The mutation execution context (a reified Mutation instance with params applied).\n * @param signal AbortSignal to cancel the in-flight request.\n */\n sendMutation?(ctx: Mutation, signal: AbortSignal): Promise<unknown>;\n}\n"],"names":["QueryAdapter","queryClient"],"mappings":"AAkCO,MAAeA,EAAa;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMV,SAASC,GAA2C;AAClD,SAAK,cAAcA;AAAA,EACrB;AAwCF;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { notifier as ut, relay as Pt, setScopeOwner as Ee, reactiveMethod as be, signal as jt, context as $t, getContext as Ce, task as
|
|
1
|
+
import { notifier as ut, relay as Pt, setScopeOwner as Ee, reactiveMethod as be, signal as jt, context as $t, getContext as Ce, task as Se, reactiveSignal as Oe, isSignal as Re, watcher as xe } from "signalium";
|
|
2
2
|
import { registerCustomHash as Ae, hashValue as N } from "signalium/utils";
|
|
3
3
|
import { d as Lt } from "./shared-DcuVH8Pf.js";
|
|
4
4
|
import { SyncQueryStore as Ne, MemoryPersistentStore as De } from "./stores/sync.js";
|
|
@@ -42,9 +42,9 @@ class B {
|
|
|
42
42
|
);
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
|
-
const
|
|
45
|
+
const S = /* @__PURE__ */ new WeakMap();
|
|
46
46
|
function T(e) {
|
|
47
|
-
return
|
|
47
|
+
return S.get(e);
|
|
48
48
|
}
|
|
49
49
|
var X = /* @__PURE__ */ ((e) => (e[e.Query = 0] = "Query", e[e.Entity = 1] = "Entity", e))(X || {});
|
|
50
50
|
class Ie {
|
|
@@ -273,10 +273,10 @@ let Gt = () => {
|
|
|
273
273
|
);
|
|
274
274
|
};
|
|
275
275
|
}
|
|
276
|
-
function
|
|
276
|
+
function St(e) {
|
|
277
277
|
return typeof e == "number" ? e | d.UNDEFINED : e instanceof m ? (e.mask & d.UNDEFINED) !== 0 ? e : m.cloneWith(e, d.UNDEFINED) : e;
|
|
278
278
|
}
|
|
279
|
-
function
|
|
279
|
+
function Ot(e) {
|
|
280
280
|
return e instanceof m && (e.mask & d.OBJECT) !== 0 && (e.mask & (d.ENTITY | d.ARRAY | d.UNION | d.RECORD | d.LIVE)) === 0;
|
|
281
281
|
}
|
|
282
282
|
function Ht(e, t, n) {
|
|
@@ -292,13 +292,13 @@ function Ht(e, t, n) {
|
|
|
292
292
|
let f = !0;
|
|
293
293
|
for (const h of e) {
|
|
294
294
|
const u = h?.[s];
|
|
295
|
-
u !== void 0 ? (o++, a === void 0 && (a = u), a !== void 0 && u !== a && !
|
|
295
|
+
u !== void 0 ? (o++, a === void 0 && (a = u), a !== void 0 && u !== a && !Ot(u) && Gt(n, s, a, u), Ot(u) ? c.push(u.shape) : (f = !1, c.push(void 0))) : (f = !1, c.push(void 0));
|
|
296
296
|
}
|
|
297
297
|
if (f && o > 0) {
|
|
298
298
|
const h = Ht(c, t, n), u = new m(d.OBJECT, h);
|
|
299
|
-
r[s] = o < t ?
|
|
299
|
+
r[s] = o < t ? St(u) : u;
|
|
300
300
|
} else
|
|
301
|
-
r[s] = o < t ?
|
|
301
|
+
r[s] = o < t ? St(a) : a;
|
|
302
302
|
}
|
|
303
303
|
return r;
|
|
304
304
|
}
|
|
@@ -940,7 +940,7 @@ function oe(e, t, n, i) {
|
|
|
940
940
|
return e;
|
|
941
941
|
}
|
|
942
942
|
function ae(e, t, n, i) {
|
|
943
|
-
if (
|
|
943
|
+
if (S.has(e))
|
|
944
944
|
return e;
|
|
945
945
|
const r = t.shape;
|
|
946
946
|
for (const [s, o] of vt(r))
|
|
@@ -1003,7 +1003,7 @@ const fn = Object.prototype, H = /* @__PURE__ */ new WeakMap();
|
|
|
1003
1003
|
function A(e) {
|
|
1004
1004
|
if (typeof e != "object" || e === null) return e;
|
|
1005
1005
|
if (Z.has(e)) return A(e.getValue());
|
|
1006
|
-
if (
|
|
1006
|
+
if (S.has(e)) return e;
|
|
1007
1007
|
if (Array.isArray(e)) {
|
|
1008
1008
|
let t = H.get(e);
|
|
1009
1009
|
return t === void 0 && (t = new Proxy(e, un), H.set(e, t)), t;
|
|
@@ -1135,7 +1135,7 @@ function ln(e, t, n) {
|
|
|
1135
1135
|
const i = [];
|
|
1136
1136
|
for (const r of e) {
|
|
1137
1137
|
if (typeof r != "object" || r === null) continue;
|
|
1138
|
-
const s =
|
|
1138
|
+
const s = S.get(r);
|
|
1139
1139
|
if (s === void 0) continue;
|
|
1140
1140
|
const o = n.entityMap.getEntity(s);
|
|
1141
1141
|
o !== void 0 && o.satisfiesDef(t) && i.push(r);
|
|
@@ -1154,15 +1154,15 @@ function yn(e, t, n, i, r) {
|
|
|
1154
1154
|
let v;
|
|
1155
1155
|
if (u && !(u in s))
|
|
1156
1156
|
throw new Error(`typenameField "${u}" must be declared in the entity shape`);
|
|
1157
|
-
const
|
|
1158
|
-
if (
|
|
1157
|
+
const O = Object.keys(s);
|
|
1158
|
+
if (O.includes("__typename") || O.push("__typename"), a)
|
|
1159
1159
|
for (const E of Object.keys(a))
|
|
1160
|
-
|
|
1161
|
-
let k, R =
|
|
1160
|
+
O.includes(E) || O.push(E);
|
|
1161
|
+
let k, R = O;
|
|
1162
1162
|
function L() {
|
|
1163
1163
|
const E = e._extraMethods;
|
|
1164
1164
|
if (E !== k) {
|
|
1165
|
-
if (k = E, R =
|
|
1165
|
+
if (k = E, R = O.slice(), E !== void 0)
|
|
1166
1166
|
for (const _ of Object.keys(E))
|
|
1167
1167
|
R.includes(_) || R.push(_);
|
|
1168
1168
|
const y = e._extraGetters;
|
|
@@ -1253,7 +1253,7 @@ function yn(e, t, n, i, r) {
|
|
|
1253
1253
|
}
|
|
1254
1254
|
}
|
|
1255
1255
|
};
|
|
1256
|
-
return v = new Proxy({}, U),
|
|
1256
|
+
return v = new Proxy({}, U), S.set(v, t), Ee(v, r), v;
|
|
1257
1257
|
}
|
|
1258
1258
|
class pn {
|
|
1259
1259
|
instances = /* @__PURE__ */ new Map();
|
|
@@ -1536,7 +1536,7 @@ class mn {
|
|
|
1536
1536
|
return;
|
|
1537
1537
|
}
|
|
1538
1538
|
const g = Tt(this.params), p = Et(this.def, g), w = p !== this.storageKey;
|
|
1539
|
-
w && (this.currentParams = g, this.storageKey = p), this.getOrCreateExecutionContext(), this.initialized ? h || f ? (this.queryClient.activateQuery(this), f && this.updatedAt !== void 0 && this.setupSubscription(), (this.config?.refreshStaleOnReconnect ?? !0) && this.isStale && this.runDebounced()) : w && (this.setupSubscription(), this.runDebounced()) : (this.queryClient.activateQuery(this), this.initialize());
|
|
1539
|
+
w && (this.currentParams = g, this.storageKey = p), this.getOrCreateExecutionContext(), this.initialized ? h || f ? (this.queryClient.activateQuery(this), f && this.updatedAt !== void 0 && this.setupSubscription(), this.relayState.isPending && this._abortController === void 0 ? this.runQueryImmediately() : (this.config?.refreshStaleOnReconnect ?? !0) && this.isStale && this.runDebounced()) : w && (this.setupSubscription(), this.runDebounced()) : (this.queryClient.activateQuery(this), this.initialize());
|
|
1540
1540
|
};
|
|
1541
1541
|
return c(!0), {
|
|
1542
1542
|
update: c,
|
|
@@ -1716,7 +1716,7 @@ class vn {
|
|
|
1716
1716
|
this.def = t, this.queryClient = n, this.task = this.createTask();
|
|
1717
1717
|
}
|
|
1718
1718
|
createTask() {
|
|
1719
|
-
return
|
|
1719
|
+
return Se(
|
|
1720
1720
|
async (t) => {
|
|
1721
1721
|
if (this._inFlight)
|
|
1722
1722
|
throw new Error("A mutation is already in progress. Await the previous call before starting a new one.");
|
|
@@ -1866,7 +1866,7 @@ class Cn {
|
|
|
1866
1866
|
function Mt(e) {
|
|
1867
1867
|
return N(e);
|
|
1868
1868
|
}
|
|
1869
|
-
class
|
|
1869
|
+
class Sn {
|
|
1870
1870
|
_groups = /* @__PURE__ */ new Map();
|
|
1871
1871
|
getOrCreateGroup(t) {
|
|
1872
1872
|
const n = Mt(t);
|
|
@@ -1962,7 +1962,7 @@ class ye {
|
|
|
1962
1962
|
n !== -1 && t.splice(n, 1);
|
|
1963
1963
|
}
|
|
1964
1964
|
}
|
|
1965
|
-
class
|
|
1965
|
+
class On {
|
|
1966
1966
|
_notifier;
|
|
1967
1967
|
_items;
|
|
1968
1968
|
_keys;
|
|
@@ -1972,7 +1972,7 @@ class Sn {
|
|
|
1972
1972
|
constructor(t, n, i, r, s, o) {
|
|
1973
1973
|
this._notifier = ut(), this._items = i, this._keys = kt(i), this._queryClient = t, this._parent = n;
|
|
1974
1974
|
const a = r !== void 0 && s !== void 0, c = o !== void 0;
|
|
1975
|
-
(a || c) && (this._outputSignal =
|
|
1975
|
+
(a || c) && (this._outputSignal = Oe(() => {
|
|
1976
1976
|
this._notifier.consume();
|
|
1977
1977
|
let f = this._items;
|
|
1978
1978
|
if (a) {
|
|
@@ -2137,7 +2137,7 @@ function pe(e, t, n, i, r) {
|
|
|
2137
2137
|
break;
|
|
2138
2138
|
}
|
|
2139
2139
|
}
|
|
2140
|
-
a = new
|
|
2140
|
+
a = new On(
|
|
2141
2141
|
r,
|
|
2142
2142
|
n,
|
|
2143
2143
|
Array.isArray(t) ? t : [],
|
|
@@ -2179,21 +2179,21 @@ function Y(e, t, n, i, r, s) {
|
|
|
2179
2179
|
if (Array.isArray(e)) {
|
|
2180
2180
|
for (let a = 0; a < e.length; a++) {
|
|
2181
2181
|
const c = e[a];
|
|
2182
|
-
typeof c == "object" && c !== null && !(c instanceof Q) && !
|
|
2182
|
+
typeof c == "object" && c !== null && !(c instanceof Q) && !S.has(c) && (e[a] = Y(c, t, n, i, r, s));
|
|
2183
2183
|
}
|
|
2184
2184
|
return e;
|
|
2185
2185
|
}
|
|
2186
|
-
if (Object.getPrototypeOf(e) === me && !
|
|
2186
|
+
if (Object.getPrototypeOf(e) === me && !S.has(e)) {
|
|
2187
2187
|
const a = e;
|
|
2188
2188
|
for (const c of Object.keys(a)) {
|
|
2189
2189
|
const f = a[c];
|
|
2190
|
-
typeof f == "object" && f !== null && !(f instanceof Q) && !
|
|
2190
|
+
typeof f == "object" && f !== null && !(f instanceof Q) && !S.has(f) && (a[c] = Y(f, t, n, i, r, s));
|
|
2191
2191
|
}
|
|
2192
2192
|
}
|
|
2193
2193
|
return e;
|
|
2194
2194
|
}
|
|
2195
2195
|
function ve(e) {
|
|
2196
|
-
return typeof e == "object" && e !== null && !(e instanceof Q) && !
|
|
2196
|
+
return typeof e == "object" && e !== null && !(e instanceof Q) && !S.has(e);
|
|
2197
2197
|
}
|
|
2198
2198
|
function xn(e, t, n, i, r, s) {
|
|
2199
2199
|
const { key: o, data: a, shape: c, rawKeys: f } = e, h = c.shape, u = n.prepareEntity(o, a, c), l = u.data, g = l !== a, p = g && f !== void 0 && u.entityRefs !== void 0 ? new Map(u.entityRefs) : /* @__PURE__ */ new Map();
|
|
@@ -2211,11 +2211,11 @@ function xn(e, t, n, i, r, s) {
|
|
|
2211
2211
|
s
|
|
2212
2212
|
), u.notify()) : we(h, a, u, a, t, n, i, p, s), s && u.liveCollections.length > 0)
|
|
2213
2213
|
for (const v of u.liveCollections) {
|
|
2214
|
-
const
|
|
2215
|
-
if (Array.isArray(
|
|
2216
|
-
for (const k of
|
|
2214
|
+
const O = v.instance.getRawValue();
|
|
2215
|
+
if (Array.isArray(O))
|
|
2216
|
+
for (const k of O) {
|
|
2217
2217
|
if (typeof k != "object" || k === null) continue;
|
|
2218
|
-
const R =
|
|
2218
|
+
const R = S.get(k);
|
|
2219
2219
|
if (R === void 0) continue;
|
|
2220
2220
|
const L = n.entityMap.getEntity(R);
|
|
2221
2221
|
L !== void 0 && p.set(L, (p.get(L) ?? 0) + 1);
|
|
@@ -2283,7 +2283,7 @@ function we(e, t, n, i, r, s, o, a, c) {
|
|
|
2283
2283
|
}
|
|
2284
2284
|
}
|
|
2285
2285
|
function ft(e) {
|
|
2286
|
-
return typeof e == "object" && e !== null && !Array.isArray(e) && Object.getPrototypeOf(e) === me && !
|
|
2286
|
+
return typeof e == "object" && e !== null && !Array.isArray(e) && Object.getPrototypeOf(e) === me && !S.has(e);
|
|
2287
2287
|
}
|
|
2288
2288
|
function Un(e) {
|
|
2289
2289
|
if (e !== void 0)
|
|
@@ -2341,21 +2341,45 @@ class qn {
|
|
|
2341
2341
|
}
|
|
2342
2342
|
/**
|
|
2343
2343
|
* Returns the registered adapter instance for the given adapter class.
|
|
2344
|
-
*
|
|
2344
|
+
*
|
|
2345
|
+
* Resolution order:
|
|
2346
|
+
* 1. Exact class match in the registered adapters.
|
|
2347
|
+
* 2. Subclass match — if any registered adapter is an `instanceof adapterClass`,
|
|
2348
|
+
* return it. This lets queries declare an abstract base adapter (e.g.
|
|
2349
|
+
* `TopicQueryAdapter`) and have the consumer-supplied concrete subclass
|
|
2350
|
+
* (e.g. a `WebSocket`-backed adapter) resolve to it.
|
|
2351
|
+
* 3. Auto-instantiate via the no-arg constructor (for adapters like
|
|
2352
|
+
* `RESTQueryAdapter` that default to `globalThis.fetch`).
|
|
2353
|
+
*
|
|
2354
|
+
* In dev builds, step 2 verifies that at most one registered adapter
|
|
2355
|
+
* matches the lookup and throws otherwise. The dev-only check is stripped
|
|
2356
|
+
* from production builds.
|
|
2357
|
+
*
|
|
2358
|
+
* Throws if none of those succeed.
|
|
2345
2359
|
*/
|
|
2346
2360
|
getAdapter(t) {
|
|
2347
|
-
|
|
2348
|
-
if (
|
|
2349
|
-
|
|
2350
|
-
|
|
2351
|
-
|
|
2352
|
-
|
|
2353
|
-
|
|
2354
|
-
|
|
2361
|
+
const n = this.adapters.get(t);
|
|
2362
|
+
if (n) return n;
|
|
2363
|
+
let i;
|
|
2364
|
+
for (const s of this.adapters.values())
|
|
2365
|
+
if (s instanceof t) {
|
|
2366
|
+
if (i !== void 0)
|
|
2367
|
+
throw new Error(
|
|
2368
|
+
`Adapter lookup for ${t.name} matches multiple registered adapters: ${i.constructor.name} and ${s.constructor.name}. Register only one adapter per lookup base on a single QueryClient, or split into separate QueryClients.`
|
|
2369
|
+
);
|
|
2370
|
+
i ??= s;
|
|
2355
2371
|
}
|
|
2356
|
-
|
|
2372
|
+
if (i !== void 0)
|
|
2373
|
+
return this.adapters.set(t, i), i;
|
|
2374
|
+
let r;
|
|
2375
|
+
try {
|
|
2376
|
+
r = new t();
|
|
2377
|
+
} catch {
|
|
2378
|
+
throw new Error(
|
|
2379
|
+
`No adapter registered for ${t.name} and auto-instantiation failed. Pass an instance via QueryClient config: new QueryClient({ store, adapters: [new ${t.name}(...)] })`
|
|
2380
|
+
);
|
|
2357
2381
|
}
|
|
2358
|
-
return
|
|
2382
|
+
return this.adapters.set(t, r), r.register(this), r;
|
|
2359
2383
|
}
|
|
2360
2384
|
getContext() {
|
|
2361
2385
|
return this.context;
|
|
@@ -2438,7 +2462,7 @@ class qn {
|
|
|
2438
2462
|
*/
|
|
2439
2463
|
parseAndApplyRootEntity(t, n, i, r, s = !1, o) {
|
|
2440
2464
|
typeof i.idField == "symbol" && typeof t == "object" && t !== null && !("__entityRef" in t) && (t[Ut] = n);
|
|
2441
|
-
const a = this.parseData(t, i, o), c = nt(a.ctx, a.data, r, s), f =
|
|
2465
|
+
const a = this.parseData(t, i, o), c = nt(a.ctx, a.data, r, s), f = S.get(c.data);
|
|
2442
2466
|
return this.entityMap.getEntity(f);
|
|
2443
2467
|
}
|
|
2444
2468
|
prepareEntity(t, n, i) {
|
|
@@ -2470,8 +2494,8 @@ class qn {
|
|
|
2470
2494
|
/* isPartialEvent */
|
|
2471
2495
|
!0
|
|
2472
2496
|
);
|
|
2473
|
-
const
|
|
2474
|
-
nt(v,
|
|
2497
|
+
const O = sn(h, r, v);
|
|
2498
|
+
nt(v, O, !0);
|
|
2475
2499
|
} catch (w) {
|
|
2476
2500
|
if (this.context.log?.warn?.("Failed to apply mutation event", w), u === void 0) {
|
|
2477
2501
|
const v = this.entityMap.getEntity(c);
|
|
@@ -2516,7 +2540,7 @@ class qn {
|
|
|
2516
2540
|
// ======================================================
|
|
2517
2541
|
getOrCreateMatcher(t) {
|
|
2518
2542
|
let n = this.constraintRegistry.get(t);
|
|
2519
|
-
return n === void 0 && (n = new
|
|
2543
|
+
return n === void 0 && (n = new Sn(), this.constraintRegistry.set(t, n)), n;
|
|
2520
2544
|
}
|
|
2521
2545
|
registerLiveCollection(t) {
|
|
2522
2546
|
for (const [n, i] of t._entityDefsByTypename)
|
|
@@ -2577,4 +2601,4 @@ export {
|
|
|
2577
2601
|
te as r,
|
|
2578
2602
|
nn as t
|
|
2579
2603
|
};
|
|
2580
|
-
//# sourceMappingURL=QueryClient-
|
|
2604
|
+
//# sourceMappingURL=QueryClient-CmMSNSpt.js.map
|