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.
Files changed (75) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/cjs/development/QueryAdapter-DUo338ga.js.map +1 -1
  3. package/dist/cjs/development/{QueryClient-vYETX2J2.js → QueryClient-Ce5Mnumb.js} +2 -2
  4. package/dist/cjs/development/QueryClient-Ce5Mnumb.js.map +1 -0
  5. package/dist/cjs/development/index.js +1 -1
  6. package/dist/cjs/{production/mutation-BnIsaYdm.js → development/mutation-GI_gTQEB.js} +2 -2
  7. package/dist/cjs/development/mutation-GI_gTQEB.js.map +1 -0
  8. package/dist/cjs/development/react/index.js +1 -1
  9. package/dist/cjs/development/rest/index.js +1 -1
  10. package/dist/cjs/development/topic/index.js +1 -1
  11. package/dist/cjs/development/topic/index.js.map +1 -1
  12. package/dist/cjs/production/QueryAdapter-DUo338ga.js.map +1 -1
  13. package/dist/cjs/production/{QueryClient-DJoA1ac6.js → QueryClient-BXGk-5PR.js} +2 -2
  14. package/dist/cjs/production/QueryClient-BXGk-5PR.js.map +1 -0
  15. package/dist/cjs/production/index.js +1 -1
  16. package/dist/cjs/{development/mutation-Beh3eks8.js → production/mutation-Bleah98u.js} +2 -2
  17. package/dist/cjs/production/mutation-Bleah98u.js.map +1 -0
  18. package/dist/cjs/production/react/index.js +1 -1
  19. package/dist/cjs/production/rest/index.js +1 -1
  20. package/dist/cjs/production/topic/index.js +1 -1
  21. package/dist/cjs/production/topic/index.js.map +1 -1
  22. package/dist/esm/QueryAdapter.d.ts +11 -0
  23. package/dist/esm/QueryAdapter.d.ts.map +1 -1
  24. package/dist/esm/QueryClient.d.ts +20 -6
  25. package/dist/esm/QueryClient.d.ts.map +1 -1
  26. package/dist/esm/QueryResult.d.ts.map +1 -1
  27. package/dist/esm/development/QueryAdapter-Bu5UJjE4.js.map +1 -1
  28. package/dist/esm/development/{QueryClient-zAD_O9xj.js → QueryClient-CmMSNSpt.js} +72 -48
  29. package/dist/esm/development/QueryClient-CmMSNSpt.js.map +1 -0
  30. package/dist/esm/development/index.js +2 -2
  31. package/dist/esm/development/{mutation-lw06SxbJ.js → mutation-BAM3eYqd.js} +2 -2
  32. package/dist/esm/development/mutation-BAM3eYqd.js.map +1 -0
  33. package/dist/esm/development/react/index.js +1 -1
  34. package/dist/esm/development/rest/index.js +2 -2
  35. package/dist/esm/development/topic/index.js +19 -18
  36. package/dist/esm/development/topic/index.js.map +1 -1
  37. package/dist/esm/mutation.d.ts +3 -3
  38. package/dist/esm/mutation.d.ts.map +1 -1
  39. package/dist/esm/production/QueryAdapter-Bu5UJjE4.js.map +1 -1
  40. package/dist/esm/production/{QueryClient-DSAzqTG6.js → QueryClient-3aWu_mJE.js} +62 -44
  41. package/dist/esm/production/QueryClient-3aWu_mJE.js.map +1 -0
  42. package/dist/esm/production/index.js +2 -2
  43. package/dist/esm/production/{mutation-Dmb9k9FG.js → mutation-YpiJLNWU.js} +2 -2
  44. package/dist/esm/production/mutation-YpiJLNWU.js.map +1 -0
  45. package/dist/esm/production/react/index.js +1 -1
  46. package/dist/esm/production/rest/index.js +2 -2
  47. package/dist/esm/production/topic/index.js +19 -18
  48. package/dist/esm/production/topic/index.js.map +1 -1
  49. package/dist/esm/query.d.ts +3 -3
  50. package/dist/esm/query.d.ts.map +1 -1
  51. package/dist/esm/topic/TopicQuery.d.ts +3 -2
  52. package/dist/esm/topic/TopicQuery.d.ts.map +1 -1
  53. package/package.json +1 -1
  54. package/plugin/docs/api/fetchium.md +2 -2
  55. package/plugin/docs/api/stores-async.md +9 -3
  56. package/plugin/docs/api/stores-sync.md +9 -3
  57. package/plugin/docs/core/entities.md +2 -2
  58. package/plugin/docs/core/queries.md +12 -19
  59. package/plugin/docs/core/streaming.md +7 -9
  60. package/plugin/docs/data/mutations.md +1 -1
  61. package/plugin/docs/guides/auth.md +65 -42
  62. package/plugin/docs/guides/error-handling.md +9 -5
  63. package/plugin/docs/guides/offline.md +11 -8
  64. package/plugin/docs/guides/testing.md +1 -1
  65. package/plugin/docs/quickstart.md +1 -1
  66. package/plugin/docs/reference/rest-queries.md +9 -9
  67. package/plugin/docs/setup/project-setup.md +5 -5
  68. package/dist/cjs/development/QueryClient-vYETX2J2.js.map +0 -1
  69. package/dist/cjs/development/mutation-Beh3eks8.js.map +0 -1
  70. package/dist/cjs/production/QueryClient-DJoA1ac6.js.map +0 -1
  71. package/dist/cjs/production/mutation-BnIsaYdm.js.map +0 -1
  72. package/dist/esm/development/QueryClient-zAD_O9xj.js.map +0 -1
  73. package/dist/esm/development/mutation-lw06SxbJ.js.map +0 -1
  74. package/dist/esm/production/QueryClient-DSAzqTG6.js.map +0 -1
  75. package/dist/esm/production/mutation-Dmb9k9FG.js.map +0 -1
@@ -1,6 +1,6 @@
1
- import { A as r, E as s, G as t, L as o, a as n, M as i, N as M, b as g, c as u, d as y, e as f, Q as C, f as N, g as Q, h as d, R as k, i as l, j as p, k as m, q as E, r as R, t as w } from "./QueryClient-zAD_O9xj.js";
1
+ import { A as r, E as s, G as t, L as o, a as n, M as i, N as M, b as g, c as u, d as y, e as f, Q as C, f as N, g as Q, h as d, R as k, i as l, j as p, k as m, q as E, r as R, t as w } from "./QueryClient-CmMSNSpt.js";
2
2
  import { Q as F } from "./QueryAdapter-Bu5UJjE4.js";
3
- import { M as A, g as K, m as Y } from "./mutation-lw06SxbJ.js";
3
+ import { M as A, g as K, m as Y } from "./mutation-BAM3eYqd.js";
4
4
  export {
5
5
  r as ARRAY_KEY,
6
6
  s as Entity,
@@ -1,5 +1,5 @@
1
1
  import { getContext as h } from "signalium";
2
- import { l as y, h as D, m as w, V as u, t as d } from "./QueryClient-zAD_O9xj.js";
2
+ import { l as y, h as D, m as w, V as u, t as d } from "./QueryClient-CmMSNSpt.js";
3
3
  class x {
4
4
  static adapter;
5
5
  params;
@@ -55,4 +55,4 @@ export {
55
55
  S as g,
56
56
  C as m
57
57
  };
58
- //# sourceMappingURL=mutation-lw06SxbJ.js.map
58
+ //# sourceMappingURL=mutation-BAM3eYqd.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mutation-BAM3eYqd.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":";;AA+BO,MAAeA,EAAS;AAAA,EAC7B,OAAO;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAQT,cAAc;AACZ,WAAOC,EAAsB,IAAI;AAAA,EACnC;AACF;AAMA,MAAMC,wBAAuB,QAAA,GAEhBC,IAAsB,CAACC,MAAoC;AACtE,QAAMC,IAAiBH,EAAiB,IAAIE,CAAG;AAE/C,MAAIC,MAAmB;AACrB,UAAM,IAAI,MAAM,+BAA+B;AAGjD,SAAOA,IAAiB;AAC1B;AAMA,SAASC,EAAwBC,GAAuE;AACtG,MAAIC,IAASN,EAAiB,IAAIK,CAAa;AAE/C,MAAIC,MAAW;AACb,WAAOA;AAGT,MAAIC;AAEJ,QAAMC,IAAS,MAAoC;AACjD,QAAID,MAAuB;AACzB,aAAOA;AAGT,UAAME,IAAW,IAAIJ,EAAA,GACfK,IAAWC,EAAkBF,CAAQ,GACrC,EAAE,QAAAG,MAAWF,GAEbG,IAAK,YAAY,OAAOH,EAAS,QAAQ,eAAe,KAAKE,CAAM,CAAC,CAAC,IAErEE,IAAaF,EAAO,UAAU,CAAA,GAC9BG,IAAgBD,aAAsBE,IACxCF,IACAG,EAAE,OAAOH,CAAU,GACjBI,IAAcN,EAAO,QACrBO,IACJD,MAAgB,SACVA,aAAuBF,IAAeE,IAAcD,EAAE,OAAOC,CAAW,IAC1E,QAEAE,IAAgBf,EAAkC;AACxD,QAAI,CAACe;AACH,YAAM,IAAI;AAAA,QACR,mBAAmBf,EAAc,IAAI;AAAA,MAAA;AAKzC,WAAAE,IAAqB;AAAA,MACnB,IAAAM;AAAA,MACA,cAAAE;AAAA,MACA,eAAAI;AAAA,MACA,UAAAT;AAAA,MACA,mBAAmBE,EAAO,qBAAqB;AAAA,MAC/C,QAAQA,EAAO;AAAA,MACf,SAASA,EAAO;AAAA,MAChB,eAAe,OAAOF,EAAS,QAAQ,cAAe;AAAA,MACtD,cAAAU;AAAA,IAAA,GAGKb;AAAA,EACT;AAEA,SAAAP,EAAiB,IAAIK,GAAeG,CAAM,GACnCA;AACT;AAMO,SAASa,EACdhB,GAC8E;AAC9E,QAAMF,IAAiBC,EAAwBC,CAAa,GAEtDiB,IAAcC,EAAWC,CAAkB;AAEjD,MAAIF,MAAgB;AAClB,UAAM,IAAI,MAAM,uBAAuB;AAGzC,SAAOA,EAAY,YAAsBnB,GAAgB;AAC3D;"}
@@ -1,6 +1,6 @@
1
1
  import { useReactive as i } from "signalium/react";
2
2
  import { reactive as f } from "signalium";
3
- import { k as u } from "../QueryClient-zAD_O9xj.js";
3
+ import { k as u } from "../QueryClient-CmMSNSpt.js";
4
4
  function n(e) {
5
5
  if (Array.isArray(e))
6
6
  return e.map(n);
@@ -1,6 +1,6 @@
1
- import { n as v, o as U, f as O } from "../QueryClient-zAD_O9xj.js";
1
+ import { n as v, o as U, f as O } from "../QueryClient-CmMSNSpt.js";
2
2
  import { Q as T } from "../QueryAdapter-Bu5UJjE4.js";
3
- import { M as w } from "../mutation-lw06SxbJ.js";
3
+ import { M as w } from "../mutation-BAM3eYqd.js";
4
4
  class P extends T {
5
5
  _fetch;
6
6
  _baseUrl;
@@ -1,20 +1,6 @@
1
- import { f as l } from "../QueryClient-zAD_O9xj.js";
1
+ import { f as l } from "../QueryClient-CmMSNSpt.js";
2
2
  import { Q as d } from "../QueryAdapter-Bu5UJjE4.js";
3
- class g extends l {
4
- static adapter;
5
- getIdentityKey() {
6
- return `topic:${this.topic}`;
7
- }
8
- getConfig() {
9
- return {
10
- staleTime: 0,
11
- subscribe: () => () => {
12
- this._topicAdapter?.unsubscribe(this.topic);
13
- }
14
- };
15
- }
16
- }
17
- class _ extends d {
3
+ class f extends d {
18
4
  _topics = /* @__PURE__ */ new Map();
19
5
  /**
20
6
  * Resolve the pending promise for a topic with initial data.
@@ -79,8 +65,23 @@ class _ extends d {
79
65
  this.queryClient.applyMutationEvent(e);
80
66
  }
81
67
  }
68
+ class _ extends l {
69
+ // Explicit type lets subclasses override with adapters that take constructor args.
70
+ static adapter = f;
71
+ getIdentityKey() {
72
+ return `topic:${this.topic}`;
73
+ }
74
+ getConfig() {
75
+ return {
76
+ staleTime: 0,
77
+ subscribe: () => () => {
78
+ this._topicAdapter?.unsubscribe(this.topic);
79
+ }
80
+ };
81
+ }
82
+ }
82
83
  export {
83
- g as TopicQuery,
84
- _ as TopicQueryAdapter
84
+ _ as TopicQuery,
85
+ f as TopicQueryAdapter
85
86
  };
86
87
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../../src/topic/TopicQuery.ts","../../../../src/topic/TopicQueryAdapter.ts"],"sourcesContent":["import { Query } from '../query.js';\nimport type { TopicQueryAdapter } from './TopicQueryAdapter.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 static override adapter: typeof 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","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"],"names":["TopicQuery","Query","TopicQueryAdapter","QueryAdapter","topic","data","state","error","ctx","_signal","topicCtx","existing","resolve","reject","promise","res","rej","event"],"mappings":";;AAQO,MAAeA,UAAmBC,EAAM;AAAA,EAC7C,OAAgB;AAAA,EAIhB,iBAAyB;AACvB,WAAO,SAAS,KAAK,KAAK;AAAA,EAC5B;AAAA,EAEA,YAAgC;AAC9B,WAAO;AAAA,MACL,WAAW;AAAA,MACX,WAAW,MACF,MAAM;AAEX,QADiB,KAA6B,eACrC,YAAY,KAAK,KAAK;AAAA,MACjC;AAAA,IACF;AAAA,EAEJ;AACF;ACNO,MAAeC,UAA0BC,EAAa;AAAA,EACnD,8BAAc,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAqBZ,aAAaC,GAAeC,GAAqB;AACzD,UAAMC,IAAQ,KAAK,QAAQ,IAAIF,CAAK;AAEpC,QAAIE,MAAU,QAAW;AACvB,WAAK,QAAQ,IAAIF,GAAO,EAAE,QAAQ,aAAa,MAAAC,GAAM;AACrD;AAAA,IACF;AAEA,IAAIC,EAAM,WAAW,cACnBA,EAAM,SAAS,aACfA,EAAM,OAAOD,GACbC,EAAM,QAASD,CAAI;AAAA,EAEvB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOU,YAAYD,GAAeG,GAAsB;AACzD,UAAMD,IAAQ,KAAK,QAAQ,IAAIF,CAAK;AAEpC,QAAIE,MAAU,QAAW;AACvB,WAAK,QAAQ,IAAIF,GAAO,EAAE,QAAQ,YAAY,OAAAG,GAAO;AACrD;AAAA,IACF;AAEA,IAAID,EAAM,WAAW,cACnBA,EAAM,SAAS,YACfA,EAAM,QAAQC,GACdD,EAAM,OAAQC,CAAK;AAAA,EAEvB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMU,WAAWH,GAAqB;AACxC,SAAK,QAAQ,OAAOA,CAAK;AAAA,EAC3B;AAAA,EAEU,WAAiB;AACzB,SAAK,QAAQ,MAAA;AAAA,EACf;AAAA,EAEA,MAAe,KAAKI,GAAYC,GAAwC;AACtE,UAAMC,IAAWF;AACjB,IAAAE,EAAS,gBAAgB;AACzB,UAAMN,IAAQM,EAAS,OAEjBC,IAAW,KAAK,QAAQ,IAAIP,CAAK;AAEvC,QAAIO;AACF,cAAQA,EAAS,QAAA;AAAA,QACf,KAAK;AACH,iBAAOA,EAAS;AAAA,QAClB,KAAK;AACH,gBAAMA,EAAS;AAAA,QACjB,KAAK;AACH,iBAAOA,EAAS;AAAA,MAAA;AAKtB,QAAIC,GACAC;AACJ,UAAMC,IAAU,IAAI,QAAiB,CAACC,GAAKC,MAAQ;AACjD,MAAAJ,IAAUG,GACVF,IAASG;AAAA,IACX,CAAC;AAED,gBAAK,QAAQ,IAAIZ,GAAO,EAAE,QAAQ,WAAW,SAAAU,GAAS,SAAAF,GAAS,QAAAC,GAAQ,GACvE,KAAK,UAAUT,CAAK,GAEbU;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA,EAMU,kBAAkBG,GAA4B;AACtD,SAAK,YAAa,mBAAmBA,CAAK;AAAA,EAC5C;AACF;"}
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":";;AAsBO,MAAeA,UAA0BC,EAAa;AAAA,EACnD,8BAAc,IAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAqBZ,aAAaC,GAAeC,GAAqB;AACzD,UAAMC,IAAQ,KAAK,QAAQ,IAAIF,CAAK;AAEpC,QAAIE,MAAU,QAAW;AACvB,WAAK,QAAQ,IAAIF,GAAO,EAAE,QAAQ,aAAa,MAAAC,GAAM;AACrD;AAAA,IACF;AAEA,IAAIC,EAAM,WAAW,cACnBA,EAAM,SAAS,aACfA,EAAM,OAAOD,GACbC,EAAM,QAASD,CAAI;AAAA,EAEvB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOU,YAAYD,GAAeG,GAAsB;AACzD,UAAMD,IAAQ,KAAK,QAAQ,IAAIF,CAAK;AAEpC,QAAIE,MAAU,QAAW;AACvB,WAAK,QAAQ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AAY,KAAK,KAAK;AAAA,MACjC;AAAA,IACF;AAAA,EAEJ;AACF;"}
@@ -2,7 +2,7 @@ import { ReactiveTask } from 'signalium';
2
2
  import { ExtractType, InternalTypeDef, MutationEffects, RetryConfig, TypeDefShape } from './types.js';
3
3
  import { type QueryContext } from './QueryClient.js';
4
4
  import { type CapturedDefinition } from './fieldRef.js';
5
- import type { QueryAdapter } from './QueryAdapter.js';
5
+ import type { QueryAdapterClass } from './QueryAdapter.js';
6
6
  export interface MutationConfigOptions {
7
7
  retry?: RetryConfig | number | false;
8
8
  }
@@ -15,10 +15,10 @@ export interface MutationDefinition<Request, Response> {
15
15
  config?: MutationConfigOptions;
16
16
  effects?: MutationEffects;
17
17
  hasGetEffects: boolean;
18
- adapterClass: typeof QueryAdapter;
18
+ adapterClass: QueryAdapterClass;
19
19
  }
20
20
  export declare abstract class Mutation {
21
- static adapter?: typeof QueryAdapter;
21
+ static adapter?: QueryAdapterClass;
22
22
  readonly params?: TypeDefShape;
23
23
  readonly result?: TypeDefShape;
24
24
  readonly optimisticUpdates?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"mutation.d.ts","sourceRoot":"","sources":["../../src/mutation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,YAAY,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,eAAe,EAAW,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/G,OAAO,EAAsB,KAAK,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEzE,OAAO,EAA4C,KAAK,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAClG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAMtD,MAAM,WAAW,qBAAqB;IACpC,KAAK,CAAC,EAAE,WAAW,GAAG,MAAM,GAAG,KAAK,CAAC;CACtC;AAED,MAAM,WAAW,kBAAkB,CAAC,OAAO,EAAE,QAAQ;IACnD,EAAE,EAAE,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,KAAG,MAQ7D,CAAC;AAmEF,wBAAgB,WAAW,CAAC,CAAC,SAAS,QAAQ,EAC5C,aAAa,EAAE,UAAU,CAAC,GACzB,YAAY,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAU9E"}
@@ -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":"AAkBO,MAAeA,EAAa;AAAA,EACvB;AAAA;AAAA;AAAA;AAAA;AAAA,EAMV,SAASC,GAA2C;AAClD,SAAK,cAAcA;AAAA,EACrB;AAwCF;"}
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 ct, relay as It, setScopeOwner as pe, reactiveMethod as ge, signal as Mt, context as kt, getContext as ve, task as _e, reactiveSignal as me, isSignal as we, watcher as Ee } from "signalium";
1
+ import { notifier as ct, relay as Nt, setScopeOwner as pe, reactiveMethod as ge, signal as Mt, context as kt, getContext as ve, task as _e, reactiveSignal as me, isSignal as we, watcher as Ee } from "signalium";
2
2
  import { registerCustomHash as be, hashValue as D } from "signalium/utils";
3
3
  import { d as Ft } from "./shared-DcuVH8Pf.js";
4
4
  import { SyncQueryStore as Ce, MemoryPersistentStore as xe } from "./stores/sync.js";
@@ -121,35 +121,35 @@ class Se {
121
121
  destroy() {
122
122
  }
123
123
  }
124
- const Y = /* @__PURE__ */ Symbol("fieldRef"), I = /* @__PURE__ */ Symbol("fieldRefPath"), ut = /* @__PURE__ */ Symbol("DEFINITION_TARGET"), G = /* @__PURE__ */ Symbol("CANCEL_PROXY"), Ae = /\[([^\]]+)\]/g;
124
+ const Y = /* @__PURE__ */ Symbol("fieldRef"), N = /* @__PURE__ */ Symbol("fieldRefPath"), ut = /* @__PURE__ */ Symbol("DEFINITION_TARGET"), G = /* @__PURE__ */ Symbol("CANCEL_PROXY"), Ae = /\[([^\]]+)\]/g;
125
125
  function Pt(e) {
126
126
  const t = {
127
127
  [Y]: !0,
128
- [I]: e
128
+ [N]: e
129
129
  };
130
130
  return new Proxy(t, De);
131
131
  }
132
132
  const De = {
133
133
  get(e, t) {
134
134
  if (t === Y) return !0;
135
- if (t === I) return e[I];
135
+ if (t === N) return e[N];
136
136
  if (t === Symbol.toPrimitive || t === "toString" || t === "valueOf") {
137
- const n = e[I];
137
+ const n = e[N];
138
138
  return () => `[${n.join(".")}]`;
139
139
  }
140
140
  if (typeof t == "symbol") return;
141
- const i = e[I];
141
+ const i = e[N];
142
142
  return Pt([...i, t]);
143
143
  },
144
144
  has(e, t) {
145
- return t === Y || t === I;
145
+ return t === Y || t === N;
146
146
  }
147
147
  };
148
148
  function Lt(e) {
149
149
  return typeof e == "object" && e !== null && e[Y] === !0;
150
150
  }
151
151
  function jt(e) {
152
- return e[I];
152
+ return e[N];
153
153
  }
154
154
  function qt(e) {
155
155
  return new Proxy(e, {
@@ -162,7 +162,7 @@ function qt(e) {
162
162
  }
163
163
  });
164
164
  }
165
- function Ne(e) {
165
+ function Ie(e) {
166
166
  const t = e[ut];
167
167
  e[G]();
168
168
  const i = {};
@@ -188,7 +188,7 @@ function dt(e, t) {
188
188
  }
189
189
  return i;
190
190
  }
191
- function Ie(e, t) {
191
+ function Ne(e, t) {
192
192
  return e.replace(Ae, (i, n) => {
193
193
  const s = n.split("."), r = dt(s, t);
194
194
  return r != null ? encodeURIComponent(String(r)) : "";
@@ -198,7 +198,7 @@ function W(e, t) {
198
198
  if (Lt(e))
199
199
  return dt(jt(e), t);
200
200
  if (typeof e == "string")
201
- return Ie(e, t);
201
+ return Ne(e, t);
202
202
  if (Array.isArray(e))
203
203
  return e.map((i) => W(i, t));
204
204
  if (typeof e == "object" && e !== null && Object.getPrototypeOf(e) === Object.prototype) {
@@ -1036,7 +1036,7 @@ function ci(e, t, i, n, s) {
1036
1036
  i.typenameField;
1037
1037
  const u = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Map(), v = () => ({ __entityRef: t });
1038
1038
  let p;
1039
- f?.hasSubscribe && a && "__subscribe" in a && (p = It((E) => {
1039
+ f?.hasSubscribe && a && "__subscribe" in a && (p = Nt((E) => {
1040
1040
  const h = (b) => {
1041
1041
  b.__eventSource = t, s.applyMutationEvent(b);
1042
1042
  }, m = a.__subscribe.call(g, h);
@@ -1047,11 +1047,11 @@ function ci(e, t, i, n, s) {
1047
1047
  if (w.includes("__typename") || w.push("__typename"), a)
1048
1048
  for (const E of Object.keys(a))
1049
1049
  w.includes(E) || w.push(E);
1050
- let N, O = w;
1050
+ let I, O = w;
1051
1051
  function K() {
1052
1052
  const E = e._extraMethods;
1053
- if (E !== N) {
1054
- if (N = E, O = w.slice(), E !== void 0)
1053
+ if (E !== I) {
1054
+ if (I = E, O = w.slice(), E !== void 0)
1055
1055
  for (const m of Object.keys(E))
1056
1056
  O.includes(m) || O.push(m);
1057
1057
  const h = e._extraGetters;
@@ -1261,14 +1261,14 @@ class ne {
1261
1261
  destroy() {
1262
1262
  }
1263
1263
  }
1264
- const ui = new ie(), Ni = kt(ui);
1264
+ const ui = new ie(), Ii = kt(ui);
1265
1265
  function vt(e, t = typeof window > "u") {
1266
1266
  let i;
1267
1267
  e === !1 ? i = 0 : e === void 0 || e === !0 ? i = t ? 0 : 3 : typeof e == "number" ? i = e : i = e.retries;
1268
1268
  const n = typeof e == "object" && e.retryDelay ? e.retryDelay : (s) => 1e3 * Math.pow(2, s);
1269
1269
  return { retries: i, retryDelay: n };
1270
1270
  }
1271
- class Ii {
1271
+ class Ni {
1272
1272
  static cache;
1273
1273
  /**
1274
1274
  * The adapter class responsible for sending requests for this query type.
@@ -1298,7 +1298,7 @@ class V {
1298
1298
  let i = Rt.get(t);
1299
1299
  if (i !== void 0)
1300
1300
  return i;
1301
- const n = new t(), s = Ne(n), r = String(s.methods.getIdentityKey.call(s.fields)), o = s.fields.result, a = o instanceof _ ? o : Je.object(o), c = (a.mask & d.ENTITY) !== 0, f = t.cache, l = s.fields.fetchNext, u = t.adapter;
1301
+ const n = new t(), s = Ie(n), r = String(s.methods.getIdentityKey.call(s.fields)), o = s.fields.result, a = o instanceof _ ? o : Je.object(o), c = (a.mask & d.ENTITY) !== 0, f = t.cache, l = s.fields.fetchNext, u = t.adapter;
1302
1302
  if (!u)
1303
1303
  throw new Error(
1304
1304
  `Query class "${t.name}" must define a static \`adapter\` property. Extend RESTQuery (from fetchium/rest) or set \`static adapter = MyAdapter\` on your query class.`
@@ -1406,8 +1406,8 @@ class di {
1406
1406
  }
1407
1407
  constructor(t, i, n, s) {
1408
1408
  this.def = t, this.queryClient = i, this.queryKey = n, this.params = s, this._extraMethods = { __refetch: this.refetch }, t.statics.hasSendNext && (this._extraMethods.__fetchNext = this.fetchNext);
1409
- const r = Nt(s);
1410
- this._queryId = r !== void 0 ? D(r) : 0, this.relay = It(
1409
+ const r = It(s);
1410
+ this._queryId = r !== void 0 ? D(r) : 0, this.relay = Nt(
1411
1411
  (o) => {
1412
1412
  this._relayState = o;
1413
1413
  const a = () => {
@@ -1420,8 +1420,8 @@ class di {
1420
1420
  a();
1421
1421
  return;
1422
1422
  }
1423
- const v = Nt(this.params), p = _t(this.def, v), g = p !== this.storageKey;
1424
- g && (this.currentParams = v, this.storageKey = p), this.getOrCreateExecutionContext(), this.initialized ? l || f ? (this.queryClient.activateQuery(this), f && this.updatedAt !== void 0 && this.setupSubscription(), (this.config?.refreshStaleOnReconnect ?? !0) && this.isStale && this.runDebounced()) : g && (this.setupSubscription(), this.runDebounced()) : (this.queryClient.activateQuery(this), this.initialize());
1423
+ const v = It(this.params), p = _t(this.def, v), g = p !== this.storageKey;
1424
+ g && (this.currentParams = v, this.storageKey = p), this.getOrCreateExecutionContext(), this.initialized ? l || 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()) : g && (this.setupSubscription(), this.runDebounced()) : (this.queryClient.activateQuery(this), this.initialize());
1425
1425
  };
1426
1426
  return c(!0), {
1427
1427
  update: c,
@@ -2096,9 +2096,9 @@ function Ei(e, t, i, n, s, r) {
2096
2096
  r
2097
2097
  ), u.notify()) : ye(l, a, u, a, t, i, n, p, r), r && u.liveCollections.length > 0)
2098
2098
  for (const w of u.liveCollections) {
2099
- const N = w.instance.getRawValue();
2100
- if (Array.isArray(N))
2101
- for (const O of N) {
2099
+ const I = w.instance.getRawValue();
2100
+ if (Array.isArray(I))
2101
+ for (const O of I) {
2102
2102
  if (typeof O != "object" || O === null) continue;
2103
2103
  const K = x.get(O);
2104
2104
  if (K === void 0) continue;
@@ -2177,7 +2177,7 @@ function Fi(e) {
2177
2177
  function bi(e) {
2178
2178
  return we(e);
2179
2179
  }
2180
- function Nt(e) {
2180
+ function It(e) {
2181
2181
  if (e === void 0)
2182
2182
  return;
2183
2183
  const t = {};
@@ -2226,21 +2226,39 @@ class Ti {
2226
2226
  }
2227
2227
  /**
2228
2228
  * Returns the registered adapter instance for the given adapter class.
2229
- * Throws if no adapter of that class has been registered.
2229
+ *
2230
+ * Resolution order:
2231
+ * 1. Exact class match in the registered adapters.
2232
+ * 2. Subclass match — if any registered adapter is an `instanceof adapterClass`,
2233
+ * return it. This lets queries declare an abstract base adapter (e.g.
2234
+ * `TopicQueryAdapter`) and have the consumer-supplied concrete subclass
2235
+ * (e.g. a `WebSocket`-backed adapter) resolve to it.
2236
+ * 3. Auto-instantiate via the no-arg constructor (for adapters like
2237
+ * `RESTQueryAdapter` that default to `globalThis.fetch`).
2238
+ *
2239
+ * In dev builds, step 2 verifies that at most one registered adapter
2240
+ * matches the lookup and throws otherwise. The dev-only check is stripped
2241
+ * from production builds.
2242
+ *
2243
+ * Throws if none of those succeed.
2230
2244
  */
2231
2245
  getAdapter(t) {
2232
- let i = this.adapters.get(t);
2233
- if (!i) {
2234
- try {
2235
- i = new t();
2236
- } catch {
2237
- throw new Error(
2238
- `No adapter registered for ${t.name} and auto-instantiation failed. Pass an instance via QueryClient config: new QueryClient({ store, adapters: [new ${t.name}(...)] })`
2239
- );
2240
- }
2241
- this.adapters.set(t, i), i.register(this);
2246
+ const i = this.adapters.get(t);
2247
+ if (i) return i;
2248
+ let n;
2249
+ for (const r of this.adapters.values())
2250
+ r instanceof t && (n ??= r);
2251
+ if (n !== void 0)
2252
+ return this.adapters.set(t, n), n;
2253
+ let s;
2254
+ try {
2255
+ s = new t();
2256
+ } catch {
2257
+ throw new Error(
2258
+ `No adapter registered for ${t.name} and auto-instantiation failed. Pass an instance via QueryClient config: new QueryClient({ store, adapters: [new ${t.name}(...)] })`
2259
+ );
2242
2260
  }
2243
- return i;
2261
+ return this.adapters.set(t, s), s.register(this), s;
2244
2262
  }
2245
2263
  getContext() {
2246
2264
  return this.context;
@@ -2355,8 +2373,8 @@ class Ti {
2355
2373
  /* isPartialEvent */
2356
2374
  !0
2357
2375
  );
2358
- const N = Ze(l, s, w);
2359
- tt(w, N, !0);
2376
+ const I = Ze(l, s, w);
2377
+ tt(w, I, !0);
2360
2378
  } catch (g) {
2361
2379
  if (this.context.log?.warn?.("Failed to apply mutation event", g), u === void 0) {
2362
2380
  const w = this.entityMap.getEntity(c);
@@ -2444,22 +2462,22 @@ export {
2444
2462
  B as R,
2445
2463
  _ as V,
2446
2464
  ft as a,
2447
- Ni as b,
2465
+ Ii as b,
2448
2466
  L as c,
2449
2467
  Se as d,
2450
2468
  ne as e,
2451
- Ii as f,
2469
+ Ni as f,
2452
2470
  Ti as g,
2453
2471
  Ci as h,
2454
2472
  ui as i,
2455
2473
  Di as j,
2456
2474
  ki as k,
2457
2475
  qt as l,
2458
- Ne as m,
2476
+ Ie as m,
2459
2477
  W as n,
2460
2478
  Fi as o,
2461
2479
  Mi as q,
2462
2480
  Wt as r,
2463
2481
  Je as t
2464
2482
  };
2465
- //# sourceMappingURL=QueryClient-DSAzqTG6.js.map
2483
+ //# sourceMappingURL=QueryClient-3aWu_mJE.js.map