fetchium 0.0.0 → 0.1.1

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 (210) hide show
  1. package/CHANGELOG.md +250 -0
  2. package/README.md +287 -0
  3. package/dist/cjs/development/QueryClient-CLi3ONNM.js +2 -0
  4. package/dist/cjs/development/QueryClient-CLi3ONNM.js.map +1 -0
  5. package/dist/cjs/development/QueryController-BQA49OYU.js +2 -0
  6. package/dist/cjs/development/QueryController-BQA49OYU.js.map +1 -0
  7. package/dist/cjs/development/index.js +2 -0
  8. package/dist/cjs/development/index.js.map +1 -0
  9. package/dist/cjs/development/mutation-CikIl_6k.js +2 -0
  10. package/dist/cjs/development/mutation-CikIl_6k.js.map +1 -0
  11. package/dist/cjs/development/package.json +3 -0
  12. package/dist/cjs/development/react/index.js +2 -0
  13. package/dist/cjs/development/react/index.js.map +1 -0
  14. package/dist/cjs/development/rest/index.js +2 -0
  15. package/dist/cjs/development/rest/index.js.map +1 -0
  16. package/dist/cjs/development/shared-Ct5zKrt4.js +2 -0
  17. package/dist/cjs/development/shared-Ct5zKrt4.js.map +1 -0
  18. package/dist/cjs/development/stores/async.js +2 -0
  19. package/dist/cjs/development/stores/async.js.map +1 -0
  20. package/dist/cjs/development/stores/sync.js +2 -0
  21. package/dist/cjs/development/stores/sync.js.map +1 -0
  22. package/dist/cjs/development/subscriptions/polling.js +2 -0
  23. package/dist/cjs/development/subscriptions/polling.js.map +1 -0
  24. package/dist/cjs/development/topic/index.js +2 -0
  25. package/dist/cjs/development/topic/index.js.map +1 -0
  26. package/dist/cjs/production/QueryClient-N0MJmuHW.js +2 -0
  27. package/dist/cjs/production/QueryClient-N0MJmuHW.js.map +1 -0
  28. package/dist/cjs/production/QueryController-BQA49OYU.js +2 -0
  29. package/dist/cjs/production/QueryController-BQA49OYU.js.map +1 -0
  30. package/dist/cjs/production/index.js +2 -0
  31. package/dist/cjs/production/index.js.map +1 -0
  32. package/dist/cjs/production/mutation-P_Yb4LI9.js +2 -0
  33. package/dist/cjs/production/mutation-P_Yb4LI9.js.map +1 -0
  34. package/dist/cjs/production/package.json +3 -0
  35. package/dist/cjs/production/react/index.js +2 -0
  36. package/dist/cjs/production/react/index.js.map +1 -0
  37. package/dist/cjs/production/rest/index.js +2 -0
  38. package/dist/cjs/production/rest/index.js.map +1 -0
  39. package/dist/cjs/production/shared-Ct5zKrt4.js +2 -0
  40. package/dist/cjs/production/shared-Ct5zKrt4.js.map +1 -0
  41. package/dist/cjs/production/stores/async.js +2 -0
  42. package/dist/cjs/production/stores/async.js.map +1 -0
  43. package/dist/cjs/production/stores/sync.js +2 -0
  44. package/dist/cjs/production/stores/sync.js.map +1 -0
  45. package/dist/cjs/production/subscriptions/polling.js +2 -0
  46. package/dist/cjs/production/subscriptions/polling.js.map +1 -0
  47. package/dist/cjs/production/topic/index.js +2 -0
  48. package/dist/cjs/production/topic/index.js.map +1 -0
  49. package/dist/esm/ConstraintMatcher.d.ts +42 -0
  50. package/dist/esm/ConstraintMatcher.d.ts.map +1 -0
  51. package/dist/esm/EntityInstance.d.ts +38 -0
  52. package/dist/esm/EntityInstance.d.ts.map +1 -0
  53. package/dist/esm/EntityStore.d.ts +14 -0
  54. package/dist/esm/EntityStore.d.ts.map +1 -0
  55. package/dist/esm/GcManager.d.ts +38 -0
  56. package/dist/esm/GcManager.d.ts.map +1 -0
  57. package/dist/esm/LiveCollection.d.ts +86 -0
  58. package/dist/esm/LiveCollection.d.ts.map +1 -0
  59. package/dist/esm/MutationResult.d.ts +22 -0
  60. package/dist/esm/MutationResult.d.ts.map +1 -0
  61. package/dist/esm/NetworkManager.d.ts +62 -0
  62. package/dist/esm/NetworkManager.d.ts.map +1 -0
  63. package/dist/esm/QueryClient.d.ts +98 -0
  64. package/dist/esm/QueryClient.d.ts.map +1 -0
  65. package/dist/esm/QueryController.d.ts +49 -0
  66. package/dist/esm/QueryController.d.ts.map +1 -0
  67. package/dist/esm/QueryResult.d.ts +67 -0
  68. package/dist/esm/QueryResult.d.ts.map +1 -0
  69. package/dist/esm/applyEntities.d.ts +12 -0
  70. package/dist/esm/applyEntities.d.ts.map +1 -0
  71. package/dist/esm/development/QueryClient-Dtde3pss.js +2572 -0
  72. package/dist/esm/development/QueryClient-Dtde3pss.js.map +1 -0
  73. package/dist/esm/development/QueryController-Ch_ncxiI.js +14 -0
  74. package/dist/esm/development/QueryController-Ch_ncxiI.js.map +1 -0
  75. package/dist/esm/development/index.js +32 -0
  76. package/dist/esm/development/index.js.map +1 -0
  77. package/dist/esm/development/mutation-UZshUQAf.js +58 -0
  78. package/dist/esm/development/mutation-UZshUQAf.js.map +1 -0
  79. package/dist/esm/development/react/index.js +40 -0
  80. package/dist/esm/development/react/index.js.map +1 -0
  81. package/dist/esm/development/rest/index.js +142 -0
  82. package/dist/esm/development/rest/index.js.map +1 -0
  83. package/dist/esm/development/shared-DcuVH8Pf.js +15 -0
  84. package/dist/esm/development/shared-DcuVH8Pf.js.map +1 -0
  85. package/dist/esm/development/stores/async.js +214 -0
  86. package/dist/esm/development/stores/async.js.map +1 -0
  87. package/dist/esm/development/stores/sync.js +149 -0
  88. package/dist/esm/development/stores/sync.js.map +1 -0
  89. package/dist/esm/development/subscriptions/polling.js +25 -0
  90. package/dist/esm/development/subscriptions/polling.js.map +1 -0
  91. package/dist/esm/development/topic/index.js +86 -0
  92. package/dist/esm/development/topic/index.js.map +1 -0
  93. package/dist/esm/errors.d.ts +4 -0
  94. package/dist/esm/errors.d.ts.map +1 -0
  95. package/dist/esm/fieldRef.d.ts +15 -0
  96. package/dist/esm/fieldRef.d.ts.map +1 -0
  97. package/dist/esm/index.d.ts +15 -0
  98. package/dist/esm/index.d.ts.map +1 -0
  99. package/dist/esm/mutation.d.ts +34 -0
  100. package/dist/esm/mutation.d.ts.map +1 -0
  101. package/dist/esm/parseEntities.d.ts +44 -0
  102. package/dist/esm/parseEntities.d.ts.map +1 -0
  103. package/dist/esm/production/QueryClient-YqnBxFy1.js +2457 -0
  104. package/dist/esm/production/QueryClient-YqnBxFy1.js.map +1 -0
  105. package/dist/esm/production/QueryController-Ch_ncxiI.js +14 -0
  106. package/dist/esm/production/QueryController-Ch_ncxiI.js.map +1 -0
  107. package/dist/esm/production/index.js +32 -0
  108. package/dist/esm/production/index.js.map +1 -0
  109. package/dist/esm/production/mutation-pgFl1uIY.js +58 -0
  110. package/dist/esm/production/mutation-pgFl1uIY.js.map +1 -0
  111. package/dist/esm/production/react/index.js +40 -0
  112. package/dist/esm/production/react/index.js.map +1 -0
  113. package/dist/esm/production/rest/index.js +142 -0
  114. package/dist/esm/production/rest/index.js.map +1 -0
  115. package/dist/esm/production/shared-DcuVH8Pf.js +15 -0
  116. package/dist/esm/production/shared-DcuVH8Pf.js.map +1 -0
  117. package/dist/esm/production/stores/async.js +214 -0
  118. package/dist/esm/production/stores/async.js.map +1 -0
  119. package/dist/esm/production/stores/sync.js +149 -0
  120. package/dist/esm/production/stores/sync.js.map +1 -0
  121. package/dist/esm/production/subscriptions/polling.js +25 -0
  122. package/dist/esm/production/subscriptions/polling.js.map +1 -0
  123. package/dist/esm/production/topic/index.js +86 -0
  124. package/dist/esm/production/topic/index.js.map +1 -0
  125. package/dist/esm/proxy.d.ts +20 -0
  126. package/dist/esm/proxy.d.ts.map +1 -0
  127. package/dist/esm/proxyId.d.ts +8 -0
  128. package/dist/esm/proxyId.d.ts.map +1 -0
  129. package/dist/esm/query-types.d.ts +60 -0
  130. package/dist/esm/query-types.d.ts.map +1 -0
  131. package/dist/esm/query.d.ts +64 -0
  132. package/dist/esm/query.d.ts.map +1 -0
  133. package/dist/esm/react/index.d.ts +2 -0
  134. package/dist/esm/react/index.d.ts.map +1 -0
  135. package/dist/esm/react/use-query.d.ts +5 -0
  136. package/dist/esm/react/use-query.d.ts.map +1 -0
  137. package/dist/esm/rest/RESTMutation.d.ts +18 -0
  138. package/dist/esm/rest/RESTMutation.d.ts.map +1 -0
  139. package/dist/esm/rest/RESTQuery.d.ts +24 -0
  140. package/dist/esm/rest/RESTQuery.d.ts.map +1 -0
  141. package/dist/esm/rest/RESTQueryController.d.ts +34 -0
  142. package/dist/esm/rest/RESTQueryController.d.ts.map +1 -0
  143. package/dist/esm/rest/index.d.ts +5 -0
  144. package/dist/esm/rest/index.d.ts.map +1 -0
  145. package/dist/esm/retry.d.ts +4 -0
  146. package/dist/esm/retry.d.ts.map +1 -0
  147. package/dist/esm/stores/async.d.ts +80 -0
  148. package/dist/esm/stores/async.d.ts.map +1 -0
  149. package/dist/esm/stores/shared.d.ts +12 -0
  150. package/dist/esm/stores/shared.d.ts.map +1 -0
  151. package/dist/esm/stores/sync.d.ts +41 -0
  152. package/dist/esm/stores/sync.d.ts.map +1 -0
  153. package/dist/esm/subscriptions/polling.d.ts +6 -0
  154. package/dist/esm/subscriptions/polling.d.ts.map +1 -0
  155. package/dist/esm/testing/MockClient.d.ts +64 -0
  156. package/dist/esm/testing/MockClient.d.ts.map +1 -0
  157. package/dist/esm/testing/auto-generate.d.ts +20 -0
  158. package/dist/esm/testing/auto-generate.d.ts.map +1 -0
  159. package/dist/esm/testing/entity-factory.d.ts +13 -0
  160. package/dist/esm/testing/entity-factory.d.ts.map +1 -0
  161. package/dist/esm/testing/index.d.ts +6 -0
  162. package/dist/esm/testing/index.d.ts.map +1 -0
  163. package/dist/esm/testing/types.d.ts +37 -0
  164. package/dist/esm/testing/types.d.ts.map +1 -0
  165. package/dist/esm/topic/TopicQuery.d.ts +10 -0
  166. package/dist/esm/topic/TopicQuery.d.ts.map +1 -0
  167. package/dist/esm/topic/TopicQueryController.d.ts +43 -0
  168. package/dist/esm/topic/TopicQueryController.d.ts.map +1 -0
  169. package/dist/esm/topic/index.d.ts +3 -0
  170. package/dist/esm/topic/index.d.ts.map +1 -0
  171. package/dist/esm/type-utils.d.ts +16 -0
  172. package/dist/esm/type-utils.d.ts.map +1 -0
  173. package/dist/esm/typeDefs.d.ts +86 -0
  174. package/dist/esm/typeDefs.d.ts.map +1 -0
  175. package/dist/esm/types.d.ts +277 -0
  176. package/dist/esm/types.d.ts.map +1 -0
  177. package/dist/esm/utils.d.ts +38 -0
  178. package/dist/esm/utils.d.ts.map +1 -0
  179. package/index.d.ts +1 -0
  180. package/package.json +181 -5
  181. package/plugin/.claude-plugin/plugin.json +10 -0
  182. package/plugin/agents/fetchium.md +168 -0
  183. package/plugin/docs/api/fetchium-react.md +135 -0
  184. package/plugin/docs/api/fetchium.md +674 -0
  185. package/plugin/docs/api/stores-async.md +219 -0
  186. package/plugin/docs/api/stores-sync.md +133 -0
  187. package/plugin/docs/core/entities.md +351 -0
  188. package/plugin/docs/core/queries.md +600 -0
  189. package/plugin/docs/core/streaming.md +550 -0
  190. package/plugin/docs/core/types.md +374 -0
  191. package/plugin/docs/data/caching.md +298 -0
  192. package/plugin/docs/data/live-data.md +435 -0
  193. package/plugin/docs/data/mutations.md +465 -0
  194. package/plugin/docs/guides/auth.md +318 -0
  195. package/plugin/docs/guides/error-handling.md +351 -0
  196. package/plugin/docs/guides/offline.md +270 -0
  197. package/plugin/docs/guides/testing.md +301 -0
  198. package/plugin/docs/quickstart.md +170 -0
  199. package/plugin/docs/reference/pagination.md +519 -0
  200. package/plugin/docs/reference/rest-queries.md +107 -0
  201. package/plugin/docs/reference/why-signalium.md +364 -0
  202. package/plugin/docs/setup/project-setup.md +319 -0
  203. package/plugin/install.mjs +88 -0
  204. package/plugin/skills/design/SKILL.md +140 -0
  205. package/plugin/skills/teach/SKILL.md +105 -0
  206. package/stores/async.d.ts +1 -0
  207. package/stores/async.js +15 -0
  208. package/stores/sync.d.ts +1 -0
  209. package/stores/sync.js +15 -0
  210. package/index.js +0 -1
package/CHANGELOG.md ADDED
@@ -0,0 +1,250 @@
1
+ # fetchium
2
+
3
+ ## 0.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 610f77f: Export `TypeDefSymbol` so downstream consumers can emit `.d.ts` files without TS4029 errors when using `TypeDef<T>` in public type positions, such as when extending `Entity`.
8
+
9
+ ## 0.1.0
10
+
11
+ ### Minor Changes
12
+
13
+ - c92035c: Initial pre-release of Fetchium
14
+
15
+ ## 1.1.2
16
+
17
+ ### Patch Changes
18
+
19
+ - 0b6b650: Add setSuspended API for more explicit suspension support
20
+
21
+ ## 1.1.1
22
+
23
+ ### Patch Changes
24
+
25
+ - bb0a5a9: Fix entity proxies not being created for preloaded entities from cache, and `__entityRef` not being resolved in proxy get handler. This fixes validation errors when accessing nested entities loaded from persistent cache.
26
+
27
+ ## 1.1.0
28
+
29
+ ### Minor Changes
30
+
31
+ - af443c5: Add request body support to query() function
32
+
33
+ Queries can now send JSON request bodies for POST requests, enabling read-like operations that require complex data structures (e.g., fetching prices for an array of tokens).
34
+
35
+ **New features:**
36
+ - Added `body` field to query definitions for specifying request body schema
37
+ - Body parameters are automatically serialized as JSON with `Content-Type: application/json` header
38
+ - Body params work alongside path params and search params
39
+ - All query features (caching, staleTime, deduplication) work with body queries
40
+
41
+ **API changes:**
42
+ - Query methods are now restricted to `GET` and `POST` only (PUT, PATCH, DELETE should use `mutation()`)
43
+
44
+ **Example:**
45
+
46
+ ```typescript
47
+ const getPrices = query(() => ({
48
+ path: '/prices',
49
+ method: 'POST',
50
+ body: {
51
+ tokens: t.array(t.string),
52
+ },
53
+ searchParams: {
54
+ currency: t.string,
55
+ },
56
+ response: {
57
+ prices: t.array(t.object({ token: t.string, price: t.number })),
58
+ },
59
+ cache: { staleTime: 30_000 },
60
+ }));
61
+
62
+ // Usage: POST /prices?currency=USD with body: {"tokens":["ETH","BTC"]}
63
+ const result = getPrices({ tokens: ['ETH', 'BTC'], currency: 'USD' });
64
+ ```
65
+
66
+ ## 1.0.18
67
+
68
+ ### Patch Changes
69
+
70
+ - 395730a: Fix entity cache keys to include shapeKey, preventing stale entity validation errors after schema changes
71
+
72
+ ## 1.0.17
73
+
74
+ ### Patch Changes
75
+
76
+ - b244daa: Fix infinite query cache hydration and Hermes Uint32Array compatibility
77
+ - Fix Hermes (React Native) compatibility by spreading Set to Array before Uint32Array conversion, which prevents empty refIds buffers
78
+ - Fix infinite query cache loading by properly handling the array of pages when parsing entities, ensuring entity proxies resolve correctly after app restart
79
+
80
+ ## 1.0.16
81
+
82
+ ### Patch Changes
83
+
84
+ - 4a3bc06: Fix union parseValue check
85
+
86
+ ## 1.0.15
87
+
88
+ ### Patch Changes
89
+
90
+ - a95ed74: Ensure entities have a unique prototype
91
+ - aa50869: Fix Record parsing and reorganize/expand parsing tests
92
+
93
+ ## 1.0.14
94
+
95
+ ### Patch Changes
96
+
97
+ - 7462836: Add mutation support
98
+ - 84265ca: Add API resilience features:
99
+ - Array filtering for parse failures
100
+ - Undefined fallback for optional types
101
+ - `t.result` wrapper for handling and exposing parse errors directly
102
+ - f07ed0e: Add separate dev-mode and prod-mode builds
103
+ - 093cbb2: Add baseUrl and ability to override baseUrl + other request options
104
+ - Updated dependencies [f07ed0e]
105
+ - signalium@2.1.6
106
+
107
+ ## 1.0.13
108
+
109
+ ### Patch Changes
110
+
111
+ - d2d633e: Ensure Entity methods can call other methods
112
+
113
+ ## 1.0.12
114
+
115
+ ### Patch Changes
116
+
117
+ - f3e1ef0: Fix case-insensitive enum type inference
118
+ - 11116da: Add more tests for shapeKey and fix some small issues
119
+ - 0219742: Fix initialization error handling
120
+ - Updated dependencies [985abb0]
121
+ - signalium@2.1.5
122
+
123
+ ## 1.0.11
124
+
125
+ ### Patch Changes
126
+
127
+ - 7f94377: Fixup format registry and add global format type registry
128
+ - d1f9def: Add ability to defined cached methods to entities
129
+ - e0a4844: Add ability for Entities to subscribe to streams when in use
130
+ - 6b961f0: Add support for Signal query parameters and debounced updates
131
+ - Updated dependencies [2cf6766]
132
+ - signalium@2.1.4
133
+
134
+ ## 1.0.10
135
+
136
+ ### Patch Changes
137
+
138
+ - 24495ac: Add t.enum.caseInsensitive()
139
+ - 047d4dc: Allow all primitive types in search params
140
+ - 9b2c2f3: Add extend to Entity and Object typedefs
141
+ - c8fc4b8: Allow typenames to be optional on entities
142
+ - 0245106: Add streamOrphans and optimisticInserts
143
+
144
+ ## 1.0.9
145
+
146
+ ### Patch Changes
147
+
148
+ - 9257412: Add t.optional/t.nullable/t.nullish
149
+ - Updated dependencies [7350348]
150
+ - Updated dependencies [c78b461]
151
+ - signalium@2.1.2
152
+
153
+ ## 1.0.8
154
+
155
+ ### Patch Changes
156
+
157
+ - f76ade3: Add support for stream and infinite queries for useQuery results
158
+
159
+ ## 1.0.7
160
+
161
+ ### Patch Changes
162
+
163
+ - 82e7818: Add useQuery for reading query results. Calling `useReactive` on a query result
164
+ will cause the result itself to entangle, but not the value of the result (e.g.
165
+ the entities inside the result). This can lead to cases where the result is not
166
+ re-rendered when the entities inside the result change. By cloning the result,
167
+ we effectively reify it and force it to flatten, entangling all of the nested
168
+ entities with that read from React.
169
+
170
+ ## 1.0.6
171
+
172
+ ### Patch Changes
173
+
174
+ - c883a52: Add no-op implementations of MemoryEvictionManager, RefetchManager, and NetworkManager for SSR environments. These can be injected into QueryClient constructor to avoid creating timers and event listeners in server-side rendering contexts.
175
+
176
+ ## 1.0.5
177
+
178
+ ### Patch Changes
179
+
180
+ - 00ae954: Signalium:
181
+ - Add support for Sets, Maps, and Dates in the `hashValue` function
182
+ - Note: This may cause some _minor_ differences in reactive functions that receive these types as parameters, they should essentially run less often in those cases. The impact of this should be minimal, so we're not considering it a breaking change.
183
+
184
+ Query:
185
+ - Add shape checking to make sure that if the shape of a query is changed, the query key will change as well, preventing stale data with a different shape from being returned from the query store
186
+ - Fix an issue where shrinking the `maxCount` of a query would cause an error when trying to activate the query
187
+
188
+ - Updated dependencies [00ae954]
189
+ - signalium@2.1.1
190
+
191
+ ## 1.0.4
192
+
193
+ ### Patch Changes
194
+
195
+ - e202f05: Fix package.json main export
196
+
197
+ ## 1.0.3
198
+
199
+ ### Patch Changes
200
+
201
+ - cfe249d: Export QueryClientContext
202
+
203
+ ## 1.0.2
204
+
205
+ ### Patch Changes
206
+
207
+ - 5f34de3: Add exports for entity and registerFormat
208
+
209
+ ## 1.0.1
210
+
211
+ ### Patch Changes
212
+
213
+ - 39d3df8: Export type definitions for queries
214
+
215
+ ## 1.0.0
216
+
217
+ ### Minor Changes
218
+
219
+ - 1a94943: Add NetworkManager and network mode options
220
+ - 0f609e4: Adds infinite query, includes some minor breaking API changes
221
+ - 4c35e93: Add Stream Query support
222
+ - f59a776: Add async store and split out stores into separate import paths
223
+
224
+ ### Patch Changes
225
+
226
+ - Updated dependencies [e64597d]
227
+ - Updated dependencies [4c35e93]
228
+ - signalium@2.1.0
229
+
230
+ ## 0.1.0
231
+
232
+ ### Minor Changes
233
+
234
+ - 919ecd9: Remove unused decoders dependency and prepare for initial pre-release
235
+
236
+ ## 0.0.2
237
+
238
+ ### Patch Changes
239
+
240
+ - 6eddfdc: Adds `staleTime`, `gcTime`, and `refetchInterval` options to queries.
241
+ - Updated dependencies [6eddfdc]
242
+ - signalium@2.0.9
243
+
244
+ ## 0.0.1
245
+
246
+ ### Patch Changes
247
+
248
+ - e6c39ee: Initial Signalium Query release
249
+ - Updated dependencies [e6c39ee]
250
+ - signalium@2.0.7
package/README.md ADDED
@@ -0,0 +1,287 @@
1
+ # fetchium
2
+
3
+ A reactive query client built on [Signalium](https://signalium.dev) that provides powerful data fetching, caching, and entity management with automatic reactivity.
4
+
5
+ ## IMPORTANT NOTE: This package is still in development and the API is subject to change.
6
+
7
+ v1.0.0 was published prematurely and we are not treating it as the stable v1 release from a semver perspective. APIs are not expected to change dramatically, but breaking changes may occur, and v1.1.0 will be the first stable release.
8
+
9
+ ## Features
10
+
11
+ - **Entity-Based Caching**: Global entity map with automatic deduplication across queries
12
+ - **Signalium Reactivity**: Automatic reactive updates when entities change
13
+ - **REST Query API**: Type-safe REST queries with path and search parameter interpolation
14
+ - **Infinite Queries**: Built-in support for paginated data fetching
15
+ - **Stream Queries**: Real-time updates via subscriptions
16
+ - **Smart Refetching**: Configurable stale-time, refetch intervals, and network-aware fetching
17
+ - **Request Deduplication**: Automatic deduplication of in-flight requests
18
+ - **Offline Support**: Response caching with configurable garbage collection
19
+ - **TypeScript First**: Full type inference for queries and responses
20
+ - **Framework Agnostic**: Works with React, or use standalone
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ npm install fetchium signalium
26
+ ```
27
+
28
+ For React support:
29
+
30
+ ```bash
31
+ npm install fetchium signalium react
32
+ ```
33
+
34
+ ## Quick Start
35
+
36
+ ### Basic Query
37
+
38
+ ```typescript
39
+ import { QueryClient, SyncQueryStore, MemoryPersistentStore, query, t } from 'fetchium';
40
+
41
+ // Create a query client
42
+ const store = new SyncQueryStore(new MemoryPersistentStore());
43
+ const client = new QueryClient(store, {
44
+ fetch: globalThis.fetch,
45
+ });
46
+
47
+ // Define a query
48
+ const getUser = query(() => ({
49
+ path: '/users/[id]',
50
+ response: {
51
+ id: t.number,
52
+ name: t.string,
53
+ email: t.string,
54
+ },
55
+ }));
56
+
57
+ // Use the query with standard async/await syntax
58
+ const user = await getUser({ id: '123' });
59
+ console.log(user.name); // Fully typed!
60
+ ```
61
+
62
+ ### Entity Queries
63
+
64
+ Define entities to enable automatic caching and deduplication:
65
+
66
+ ```typescript
67
+ import { entity, t } from 'fetchium';
68
+
69
+ // Define an entity
70
+ const User = entity('User', () => ({
71
+ id: t.number,
72
+ name: t.string,
73
+ email: t.string,
74
+ }));
75
+
76
+ // Use in a query
77
+ const getUser = query(() => ({
78
+ path: '/users/[id]',
79
+ response: User,
80
+ }));
81
+
82
+ // Multiple queries returning the same entity will share cached data
83
+ const user1 = await getUser({ id: '123' });
84
+ const user2 = await getUserFromTeam({ teamId: '456' }); // May return same User entity
85
+
86
+ // Both references will update reactively when the entity changes!
87
+ ```
88
+
89
+ ### Search Parameters
90
+
91
+ ```typescript
92
+ const listUsers = query(() => ({
93
+ path: '/users',
94
+ searchParams: {
95
+ page: t.number,
96
+ limit: t.number,
97
+ status: t.string.optional,
98
+ },
99
+ response: {
100
+ users: t.array(User),
101
+ total: t.number,
102
+ },
103
+ }));
104
+
105
+ // Use with search params
106
+ const result = await listUsers({
107
+ page: 1,
108
+ limit: 10,
109
+ status: 'active',
110
+ });
111
+ ```
112
+
113
+ ### Stream Options
114
+
115
+ For real-time updates on queries, use the `stream` option:
116
+
117
+ ```typescript
118
+ import { query } from 'fetchium';
119
+
120
+ const getUser = query(() => ({
121
+ path: '/users/[id]',
122
+ response: { user: User },
123
+ stream: {
124
+ type: User,
125
+ subscribe: (context, params, onUpdate) => {
126
+ const ws = new WebSocket(`wss://api.example.com/users/${params.id}`);
127
+
128
+ ws.onmessage = event => {
129
+ const update = JSON.parse(event.data);
130
+ onUpdate(update);
131
+ };
132
+
133
+ // Return unsubscribe function
134
+ return () => ws.close();
135
+ },
136
+ }));
137
+
138
+ // Subscribe to updates
139
+ const userStream = subscribeToUser({ id: '123' });
140
+ const user = await userStream;
141
+ // User will reactively update when new data arrives
142
+ ```
143
+
144
+ ## Caching Options
145
+
146
+ Configure caching behavior per query:
147
+
148
+ ```typescript
149
+ const getUser = query(() => ({
150
+ path: '/users/[id]',
151
+ response: User,
152
+ cache: {
153
+ staleTime: 5000, // Data is fresh for 5 seconds
154
+ gcTime: 300000, // Cache persists for 5 minutes after last use
155
+ networkMode: 'online', // Only fetch when online
156
+ retry: 3, // Retry failed requests 3 times
157
+ refreshStaleOnReconnect: true, // Refetch stale data on reconnect
158
+ },
159
+ }));
160
+ ```
161
+
162
+ ## React Integration
163
+
164
+ ```typescript
165
+ import { QueryClientContext } from 'fetchium';
166
+ import { reactive } from 'signalium/react';
167
+
168
+ // Provide the client
169
+ function App() {
170
+ return (
171
+ <QueryClientContext.Provider value={client}>
172
+ <UserProfile userId="123" />
173
+ </QueryClientContext.Provider>
174
+ );
175
+ }
176
+
177
+ // Use queries in components
178
+ const UserProfile = reactive(({ userId }) => {
179
+ const user = getUser({ id: userId });
180
+
181
+ // While the user is loading initially, show a loading state
182
+ if (!user.isReady) {
183
+ return <div>Loading...</div>;
184
+ }
185
+
186
+ // Once the user is loaded and the result is ready, `user.value` is guaranteed
187
+ // to be defined and have a loaded user value.
188
+ return (
189
+ <div>
190
+ <h1>{user.value.name}</h1>
191
+ <p>{user.value.email}</p>
192
+ </div>
193
+ );
194
+ });
195
+ ```
196
+
197
+ ## Store Types
198
+
199
+ ### Synchronous Store
200
+
201
+ For in-memory only or synchronous persistence:
202
+
203
+ ```typescript
204
+ import { SyncQueryStore, MemoryPersistentStore } from 'fetchium';
205
+
206
+ const store = new SyncQueryStore(new MemoryPersistentStore());
207
+ ```
208
+
209
+ ### Asynchronous Store
210
+
211
+ For async persistence (IndexedDB, AsyncStorage, etc.):
212
+
213
+ ```typescript
214
+ import { AsyncQueryStore } from 'fetchium/stores/async';
215
+
216
+ const store = new AsyncQueryStore({
217
+ async get(key) {
218
+ /* ... */
219
+ },
220
+ async set(key, value) {
221
+ /* ... */
222
+ },
223
+ async delete(key) {
224
+ /* ... */
225
+ },
226
+ async clear() {
227
+ /* ... */
228
+ },
229
+ });
230
+ ```
231
+
232
+ ## Type Definitions
233
+
234
+ The `t` object provides type-safe validators:
235
+
236
+ - **Primitives**: `t.string`, `t.number`, `t.boolean`, `t.null`, `t.undefined`
237
+ - **Collections**: `t.array(type)`, `t.record(type)`, `t.object({ ... })`
238
+ - **Unions**: `t.union(t.string, t.number, t.null)`
239
+ - **Entities**: `entity(() => ({ ... }))`
240
+
241
+ ## Network Management
242
+
243
+ Control network status and behavior:
244
+
245
+ ```typescript
246
+ import { NetworkManager } from 'fetchium';
247
+
248
+ const networkManager = new NetworkManager();
249
+
250
+ // Manually control network status
251
+ networkManager.setOnline(false);
252
+
253
+ // Listen to browser events (default)
254
+ networkManager.listen();
255
+
256
+ // Use in QueryClient
257
+ const client = new QueryClient(store, {
258
+ fetch,
259
+ networkManager,
260
+ });
261
+ ```
262
+
263
+ ## API Reference
264
+
265
+ ### Core Exports
266
+
267
+ - `QueryClient` - Main query client class
268
+ - `QueryClientContext` - React context for client
269
+ - `query()` - Define a query
270
+ - `t` - Type definition helpers
271
+ - `entity()` - Define an entity type
272
+ - `SyncQueryStore` / `AsyncQueryStore` - Store implementations
273
+ - `NetworkManager` - Network status manager
274
+
275
+ ### Type Utilities
276
+
277
+ - `QueryResult<T>` - Result type for queries
278
+ - `QueryContext` - Context passed to fetch functions
279
+ - `QueryCacheOptions` - Cache configuration options
280
+
281
+ ## License
282
+
283
+ ISC
284
+
285
+ ## Contributing
286
+
287
+ See the main [Signalium repository](https://github.com/Signalium/signalium) for contributing guidelines.
@@ -0,0 +1,2 @@
1
+ "use strict";const b=require("signalium"),A=require("signalium/utils"),Vt=require("./shared-Ct5zKrt4.js"),Nt=require("./stores/sync.js");var L=(e=>(e.Always="always",e.Online="online",e.OfflineFirst="offlineFirst",e))(L||{}),u=(e=>(e[e.UNDEFINED=1]="UNDEFINED",e[e.NULL=2]="NULL",e[e.NUMBER=4]="NUMBER",e[e.STRING=8]="STRING",e[e.BOOLEAN=16]="BOOLEAN",e[e.OBJECT=32]="OBJECT",e[e.ARRAY=64]="ARRAY",e[e.ID=128]="ID",e[e.RECORD=256]="RECORD",e[e.UNION=512]="UNION",e[e.ENTITY=1024]="ENTITY",e[e.HAS_FORMAT=4096]="HAS_FORMAT",e[e.IS_EAGER_FORMAT=8192]="IS_EAGER_FORMAT",e[e.PARSE_RESULT=16384]="PARSE_RESULT",e[e.LIVE=32768]="LIVE",e))(u||{});const I=Symbol("array"),F=Symbol("record"),lt=Symbol("QUERY_ID");var Z=(e=>(e[e.Array=0]="Array",e[e.Value=1]="Value",e))(Z||{});class ${type;entityDefs;constraintFieldRefs;sort;valueType;onCreate;onUpdate;onDelete;constructor(t,n,i,r,s,o,a,c){this.type=t,this.entityDefs=n,this.constraintFieldRefs=i,this.sort=r,this.valueType=s,this.onCreate=o,this.onUpdate=a,this.onDelete=c}static array(t,n,i){return new $(0,t,n,i,void 0,void 0,void 0,void 0)}static value(t,n,i,r,s,o){return new $(1,t,n,void 0,i,r,s,o)}}const R=new WeakMap;function P(e){return R.get(e)}var tt=(e=>(e[e.Query=0]="Query",e[e.Entity=1]="Entity",e))(tt||{});class Oe{constructor(t,n,i){this._onEvict=n,this._intervalId=setInterval(this._tick,t*6e4*i)}_currentFlush=new Map;_nextFlush=new Map;_intervalId;schedule(t,n){this._nextFlush.set(t,n)}cancel(t){this._currentFlush.delete(t),this._nextFlush.delete(t)}_tick=()=>{const{_currentFlush:t,_nextFlush:n,_onEvict:i}=this;for(const[r,s]of t)i(r,s);this._currentFlush=n,this._nextFlush=new Map};destroy(){clearInterval(this._intervalId)}}class Kt{_buckets=new Map;_nextTickEntries=new Map;_nextTickScheduled=!1;_onEvict;_multiplier;constructor(t,n=1){this._onEvict=t,this._multiplier=n}schedule(t,n,i){if(n===1/0)return;if(n===0){const{_nextTickEntries:o}=this;o.set(t,i),this._nextTickScheduled||(this._nextTickScheduled=!0,setTimeout(this._flushNextTick,0));return}const{_buckets:r}=this;let s=r.get(n);s||(s=new Oe(n,this._onEvict,this._multiplier),r.set(n,s)),s.schedule(t,i)}cancel(t,n){if(n!==1/0){if(n===0){this._nextTickEntries.delete(t);return}this._buckets.get(n)?.cancel(t)}}_flushNextTick=()=>{const{_nextTickEntries:t,_onEvict:n}=this;this._nextTickScheduled=!1;for(const[i,r]of t)n(i,r);t.clear()};destroy(){const{_buckets:t,_nextTickEntries:n}=this;for(const i of t.values())i.destroy();t.clear(),n.clear()}}class Bt{schedule(t,n,i){}cancel(t,n){}destroy(){}}const J=Symbol("fieldRef"),M=Symbol("fieldRefPath"),dt=Symbol("DEFINITION_TARGET"),X=Symbol("CANCEL_PROXY"),Re=/\[([^\]]+)\]/g;function Qt(e){const t={[J]:!0,[M]:e};return new Proxy(t,Se)}const Se={get(e,t){if(t===J)return!0;if(t===M)return e[M];if(t===Symbol.toPrimitive||t==="toString"||t==="valueOf"){const i=e[M];return()=>`[${i.join(".")}]`}if(typeof t=="symbol")return;const n=e[M];return Qt([...n,t])},has(e,t){return t===J||t===M}};function Yt(e){return typeof e=="object"&&e!==null&&e[J]===!0}function Gt(e){return e[M]}function ht(e){let t=!1;return new Proxy(e,{set(n,i,r){return n[i]=r,!0},get(n,i){if(t)throw new Error("Definition proxy accessed after extraction. Avoid arrow functions that capture `this`.");return i===dt?n:i===X?()=>{t=!0}:typeof i=="symbol"?n[i]:Qt([i])}})}function Ht(e){const t=e[dt];e[X]();const n={};for(const s of Object.getOwnPropertyNames(t))n[s]=t[s];const i={};let r=Object.getPrototypeOf(t);for(;r&&r!==Object.prototype;){for(const s of Object.getOwnPropertyNames(r)){if(s==="constructor")continue;const o=Object.getOwnPropertyDescriptor(r,s);typeof o.value=="function"&&!(s in i)&&(i[s]=o.value)}r=Object.getPrototypeOf(r)}return{fields:n,methods:i}}function yt(e,t){let n=t;for(const i of e){if(n==null)return;n=n[i]}return n}function xe(e,t){return e.replace(Re,(n,i)=>{const r=i.split("."),s=yt(r,t);return s!=null?encodeURIComponent(String(s)):""})}function Y(e,t){if(Yt(e))return yt(Gt(e),t);if(typeof e=="string")return xe(e,t);if(Array.isArray(e))return e.map(n=>Y(n,t));if(typeof e=="object"&&e!==null&&Object.getPrototypeOf(e)===Object.prototype){const n={};for(const i of Object.keys(e))n[i]=Y(e[i],t);return n}return e}function st(e,t,n){const i=e.fields,r=e.methods,s={params:t},o={};for(const[a,c]of Object.entries(i))o[a]=Y(c,s);o.params=t,o.context=n;for(const[a,c]of Object.entries(r))o[a]=c.bind(o);return o}class pt{static cache;constructor(){return ht(this)}}const Wt=Object.entries,ot=Object.keys;let zt=()=>{};{const t=(i,r)=>{if(i.size!==r.size)return!1;for(const s of i)if(!r.has(s))return!1;return!0},n=(i,r)=>{if(i===r)return!0;if(typeof i!=typeof r)return!1;if(typeof i=="number"){const s=r;if((i&65535)!==(s&65535))return!1;const o=i>>16,a=s>>16;return!(o!==0&&a!==0&&o!==a)}if(typeof i=="string")return i===r;if(i instanceof Set&&r instanceof Set)return t(i,r);if(i instanceof v&&r instanceof v){const s=i.mask,o=r.mask;if((s&65535)!==(o&65535))return!1;const a=s>>16,c=o>>16;if(a!==0&&c!==0&&a!==c)return!1;if(i.shape===r.shape)return!0;if(i.shape!==void 0&&r.shape!==void 0&&typeof i.shape=="object"&&typeof r.shape=="object"){const f=i.shape,d=r.shape;for(const l of Object.keys(f))if(l in d&&!n(f[l],d[l]))return!1;for(const l of Object.keys(d))if(l in f&&!n(f[l],d[l]))return!1}return!0}return!1};zt=(i,r,s,o)=>{if(!n(s,o))throw new Error(`[fetchium] Entity typename '${i}' has incompatible type for field '${r}' across different entity definitions`)}}function Dt(e){return typeof e=="number"?e|u.UNDEFINED:e instanceof v?(e.mask&u.UNDEFINED)!==0?e:v.cloneWith(e,u.UNDEFINED):e}function It(e){return e instanceof v&&(e.mask&u.OBJECT)!==0&&(e.mask&(u.ENTITY|u.ARRAY|u.UNION|u.RECORD|u.LIVE))===0}function Jt(e,t,n){const i=new Set;for(const s of e)if(s!==void 0)for(const o of Object.keys(s))i.add(o);const r={};for(const s of i){let o=0,a;const c=[];let f=!0;for(const d of e){const l=d?.[s];l!==void 0?(o++,a===void 0&&(a=l),a!==void 0&&l!==a&&!It(l)&&zt(n,s,a,l),It(l)?c.push(l.shape):(f=!1,c.push(void 0))):(f=!1,c.push(void 0))}if(f&&o>0){const d=Jt(c,t,n),l=new v(u.OBJECT,d);r[s]=o<t?Dt(l):l}else r[s]=o<t?Dt(a):a}return r}class v{mask;shape;typenameField=void 0;typenameValue=void 0;idField=void 0;values=void 0;_methods=void 0;_entityConfig=void 0;_entityClass=void 0;_entityCache=void 0;_liveConfig=void 0;constructor(t,n,i,r,s,o){this.mask=t,this.shape=n,this.values=i,this.typenameField=r,this.typenameValue=s,this.idField=o}static merge(t){if(t.length===1)return t[0];const n=t.length,i=t.map(f=>f.shape),r=t[0].typenameValue??"(unknown)",s=Jt(i,n,r);let o,a,c;for(const f of t){if(o===void 0&&f.idField!==void 0)o=f.idField;else if(o!==void 0&&f.idField!==void 0&&f.idField!==o)throw new Error(`[fetchium] Entity typename '${f.typenameValue}' has conflicting id fields: '${String(o)}' vs '${String(f.idField)}'`);a===void 0&&(a=f.typenameField),c===void 0&&(c=f.typenameValue)}return new v(u.ENTITY|u.OBJECT,s,void 0,a,c,o)}static cloneWith(t,n){const i=new v(n|t.mask,t.shape,t.values,t.typenameField,t.typenameValue,t.idField);return i._methods=t._methods,i._entityConfig=t._entityConfig,i._entityClass=t._entityClass,i._entityCache=t._entityCache,i._liveConfig=t._liveConfig,i}}class q extends Set{lowercaseMap;constructor(t){super(t),this.lowercaseMap=new Map;for(const n of t)if(typeof n=="string"){const i=n.toLowerCase(),r=this.lowercaseMap.get(i);if(r!==void 0)throw new Error(`Case-insensitive enum cannot have multiple values with the same lowercase form: '${r}' and '${n}' both become '${i}'`);this.lowercaseMap.set(i,n)}}has(t){return this.get(t)!==void 0}get(t){if(typeof t=="string")return this.lowercaseMap.get(t.toLowerCase());if(super.has(t))return t}}const Ae=1128875347;A.registerCustomHash(q,e=>{let t=Ae;for(const n of e)t+=A.hashValue(n);return t>>>0});function gt(e,t){return new v(e,t)}function Ne(e){return gt(u.ARRAY,e)}function De(e){return gt(u.RECORD|u.OBJECT,e)}function Ie(e){return gt(u.PARSE_RESULT,e)}function Xt(e,t){let n=e,i,r,s;for(const[o,a]of Wt(t))switch(typeof a){case"number":if((a&u.ID)!==0){if(i!==void 0)throw new Error(`Duplicate id field: ${o}`);i=o}break;case"string":if(r!==void 0&&r!==o)throw new Error(`Duplicate typename field: ${o}`);r=o,s=a;break;case"object":if(a instanceof q||a instanceof Set)break;a.mask&u.LIVE&&(n|=u.LIVE);break}return new v(n,t,void 0,r,s,i)}function Fe(e){return Xt(u.OBJECT,e)}function Ft(e,t,n){const i=e.mask;if((i&u.UNION)!==0){const r=e;if(r.typenameField!==void 0){if(n!==void 0&&n!==r.typenameField)throw new Error(`Union typename field conflict: Cannot merge unions with different typename fields ('${n}' vs '${r.typenameField}')`);n=r.typenameField}const s=r.shape;if(s!==void 0)for(const o of[...ot(s),I,F]){const a=s[o];if(t[o]!==void 0&&t[o]!==a)throw new Error(`Union merge conflict: Duplicate typename value '${String(o)}' found when merging nested unions (${String(t[o])} vs ${String(a)})`);t[o]=a}}else if((i&u.ARRAY)!==0){if(t[I]!==void 0)throw new Error("Array shape already defined");t[I]=e.shape}else if((i&u.RECORD)!==0){if(t[F]!==void 0)throw new Error("Record shape already defined");t[F]=e.shape}else{const r=e.typenameField,s=e.typenameValue;if(s===void 0)throw new Error("Object definitions must have a typename to be in a union with other objects, records, or arrays");if(n!==void 0&&r!==n)throw new Error("Object definitions must have the same typename field to be in the same union");n=r,t[s]=e}return n}function vt(...e){const t=e;let n=0,i=0,r,s,o,a,c=0;for(const d of t){if(typeof d=="number"){n|=d;continue}if(d instanceof Set){if(s===void 0)s=new Set(d);else for(const l of d)s.add(l);continue}if(i++,c|=d.mask,i===1){r=d;continue}i===2&&(o=Object.create(null),a=Ft(r,o,a)),a=Ft(d,o,a)}if(i===0)return s===void 0?n:n===0?s:new v(n|u.UNION,void 0,s);if(i===1)return v.cloneWith(r,n);const f=n|c|u.UNION;return new v(f,o,s,a)}function mt(e,t,n){const i=e;if(typeof i=="number")return i|t;if(i instanceof Set)return vt(e,t);let r=n.get(i);return r===void 0&&(r=v.cloneWith(i,t),n.set(i,r)),r}const Me=new WeakMap,ke=new WeakMap,Te=new WeakMap;function Pe(e){return mt(e,u.UNDEFINED|u.NULL,Te)}function je(e){return mt(e,u.UNDEFINED,Me)}function Le(e){return mt(e,u.NULL,ke)}function $e(e){return e}function Ue(e){return new Set([e])}const Zt=((...e)=>new Set(e));Zt.caseInsensitive=(...e)=>new q(e);const _t=16;let qe=0;const at=[],te=[],ee=new Map,ne=new Map,et=new WeakSet;class G{_raw;_formatted;_parsed;_formatId;constructor(t,n,i){this._raw=t,this._formatId=n,i?(this._formatted=at[n](t),this._parsed=!0):this._parsed=!1,et.add(this)}getValue(){return this._parsed||(this._formatted=at[this._formatId](this._raw),this._parsed=!0),this._formatted}toJSON(){return this._parsed?te[this._formatId](this._formatted):this._raw}}function Ve(e){const t=ee.get(e);if(t===void 0)throw new Error(`Format ${e} not registered`);return t}function Mt(e){const t=e>>_t;return ne.get(t)}function wt(e,t,n,i,r){const s=qe++;at[s]=n,te[s]=i,ne.set(s,e);const o=r?.eager??!0,c=s<<_t|t|u.HAS_FORMAT|(o?u.IS_EAGER_FORMAT:0);ee.set(e,c)}wt("date",u.STRING,e=>{const t=e.match(/^(\d{4})-(\d{2})-(\d{2})$/);if(!t)throw new Error(`Invalid date string: ${e}. Expected YYYY-MM-DD format.`);const[,n,i,r]=t,s=new Date(Date.UTC(parseInt(n,10),parseInt(i,10)-1,parseInt(r,10)));if(isNaN(s.getTime()))throw new Error(`Invalid date string: ${e}`);return s},e=>{const t=e.getUTCFullYear(),n=String(e.getUTCMonth()+1).padStart(2,"0"),i=String(e.getUTCDate()).padStart(2,"0");return`${t}-${n}-${i}`});wt("date-time",u.STRING,e=>{const t=new Date(e);if(isNaN(t.getTime()))throw new Error(`Invalid date-time string: ${e}`);return t},e=>e.toISOString());const kt=new WeakMap;function U(e){let t=kt.get(e);if(t===void 0){const n=new e,i=n[dt]??n;n[X]&&n[X]();const r={};for(const[f,d]of Wt(i)){if(!(typeof d=="number"||typeof d=="string"||d instanceof Set||d instanceof v||d instanceof q))throw new Error(`[fetchium] Entity '${e.name}' field '${f}' has an invalid type definition. All entity fields must be type definitions (e.g. t.string, t.number, t.entity(...), etc). Got: ${typeof d=="object"?d?.constructor?.name??typeof d:typeof d}`);r[f]=d}const s=Object.getPrototypeOf(e.prototype);if(s!=null){const f=s.constructor;if(f!==pt&&typeof f=="function"){const l=U(f).shape;for(const h of ot(l))if(h in r&&r[h]!==l[h])throw new Error(`Cannot extend: field '${h}' already exists in type definition`)}}const o={},a=e.prototype;for(const f of Object.getOwnPropertyNames(a))f!=="constructor"&&typeof a[f]=="function"&&(o[f]=a[f]);t=Xt(u.ENTITY|u.OBJECT,r),t._entityClass=e,ot(o).length>0&&(t._methods=o),typeof o.__subscribe=="function"&&(t._entityConfig={hasSubscribe:!0});const c=e;c.cache&&(t._entityCache=c.cache),kt.set(e,t)}return t}function Ke(e){return U(e)}function ie(e,t){if(t==null)return;const n=new Map;if(Array.isArray(t))for(const i of t){const[r,s]=i,a=U(r).typenameValue;if(a===void 0)continue;const c=[];for(const[f,d]of Object.entries(s))c.push([f,d]);c.length>0&&n.set(a,c)}else{const r=Object.entries(t);if(r.length===0)return;const s=r.map(([o,a])=>[o,a]);for(const o of e){const a=o.typenameValue;a!==void 0&&n.set(a,s)}}return n.size>0?n:void 0}function re(e){return Array.isArray(e)?e.map(t=>U(t)):[U(e)]}function Be(e,t){const n=re(e),i=n.length===1?n[0]:vt(...n.map(o=>o)),r=u.ARRAY|u.LIVE,s=new v(r,i);return s._liveConfig=$.array(n,ie(n,t?.constraints),t?.sort),s}function Qe(e,t,n){const i=re(t),r=e,s=u.LIVE,o=new v(s,void 0);return o._liveConfig=$.value(i,ie(i,n?.constraints),r,n.onCreate,n.onUpdate,n.onDelete),o}const se={format:Ve,typename:$e,const:Ue,enum:Zt,id:u.ID|u.STRING|u.NUMBER,string:u.STRING,number:u.NUMBER,boolean:u.BOOLEAN,null:u.NULL,undefined:u.UNDEFINED,array:Ne,object:Fe,record:De,union:vt,nullish:Pe,optional:je,nullable:Le,result:Ie,entity:Ke,liveArray:Be,liveValue:Qe};function Q(e){if(e instanceof q)return Array.from(e).map(i=>typeof i=="string"?`"${i}"`:String(i)).join(" | ");if(e instanceof Set)return Array.from(e).map(i=>typeof i=="string"?`"${i}"`:String(i)).join(" | ");if(typeof e=="string")return`"${e}"`;if(typeof e=="boolean")return String(e);if(typeof e=="number"){if((e&u.HAS_FORMAT)!==0){const r=Mt(e);if(r)return`"${r}"`}const i=[];return e&u.UNDEFINED&&i.push("undefined"),e&u.NULL&&i.push("null"),e&u.NUMBER&&i.push("number"),e&u.STRING&&i.push("string"),e&u.BOOLEAN&&i.push("boolean"),e&u.OBJECT&&i.push("object"),e&u.ARRAY&&i.push("array"),i.length===0?"unknown":i.length===1?i[0]:i.join(" | ")}let t=e.mask;if(t&u.UNION){const n=e,i=[];if(n.values!==void 0&&n.values.size>0)for(const s of n.values){const o=typeof s=="string"?`"${s}"`:String(s);i.push(o)}if(n.shape!==void 0){n.shape[I]!==void 0&&i.push(`Array<${Q(n.shape[I])}>`),n.shape[F]!==void 0&&i.push(`Record<string, ${Q(n.shape[F])}>`);for(const[s,o]of Object.entries(n.shape))s!==I&&s!==F&&i.push(s)}if(t=n.mask,(t&u.HAS_FORMAT)!==0){const s=Mt(t);s&&i.push(`"${s}"`)}return t&u.UNDEFINED&&i.push("undefined"),t&u.NULL&&i.push("null"),t&u.NUMBER&&i.push("number"),t&u.STRING&&i.push("string"),t&u.BOOLEAN&&i.push("boolean"),i.length===0?"union":i.join(" | ")}if(t&u.ENTITY)return`Entity<${e.typenameValue}>`;if(t&u.ARRAY){const n=e.shape;return`Array<${Q(n)}>`}if(t&u.RECORD){const n=e.shape;return`Record<string, ${Q(n)}>`}if(t&u.OBJECT){const n=e.typenameValue;return n?`Object<${n}>`:"object"}return"unknown"}function B(e,t,n){return new TypeError(`Validation error at ${e}: expected ${Q(t)}, got ${typeof n=="object"?n===null?"null":Array.isArray(n)?"array":"object":typeof n}`)}const oe=Array.isArray;function Tt(e){if(e===null)return u.NULL;switch(typeof e){case"number":return u.NUMBER;case"string":return u.STRING;case"boolean":return u.BOOLEAN;case"undefined":return u.UNDEFINED;case"object":return oe(e)?u.ARRAY:u.OBJECT;default:throw new Error(`Invalid type: ${typeof e}`)}}function Ye(e){return j(e)}function j(e){if(e===null||typeof e!="object")return e;if(oe(e))return e.map(n=>j(n));if(e instanceof Date)return new Date(e.getTime());if(e instanceof Map){const n=new Map;for(const[i,r]of e)n.set(j(i),j(r));return n}if(e instanceof Set){const n=new Set;for(const i of e)n.add(j(i));return n}const t={};for(const n of Object.keys(e))t[n]=j(e[n]);return t}const Et=Object.entries,Ge=()=>{};class ct{queryClient=void 0;preloadedEntities=void 0;warn=Ge;isPartialEvent=!1;seen=void 0;seenByKey=void 0;reset(t,n,i,r=!1){this.queryClient=t,this.preloadedEntities=n,this.warn=i,this.isPartialEvent=r,t!==void 0&&(this.seen===void 0?(this.seen=new Map,this.seenByKey=new Map):(this.seen.clear(),this.seenByKey.clear()))}}function ae(e,t,n){return k(e,t,n,"")}function He(e,t,n){return Ct(e,t,n)}function Pt(e,t,n,i){const r=e>>_t;if((e&u.IS_EAGER_FORMAT)!==0)try{return new G(t,r,!0)}catch(o){if((e&u.UNDEFINED)!==0){n.warn("Invalid formatted value for optional type, defaulting to undefined",{value:t,path:i,error:o instanceof Error?o.message:String(o)});return}throw o}return new G(t,r,!1)}function k(e,t,n,i){const r=t;if(r instanceof q){const c=r.get(e);if(c===void 0)throw B(i,r,e);return c}if(r instanceof Set){if(!r.has(e))throw B(i,r,e);return e}if(typeof r=="string"){if(e==null)return r;if(e!==r)throw B(i,r,e);return e}if(typeof r=="number"){const c=Tt(e);if((r&c)===0){if((r&u.UNDEFINED)!==0){n.warn("Invalid value for optional type, defaulting to undefined",{value:e,path:i});return}throw B(i,r,e)}return(r&u.HAS_FORMAT)!==0&&e!==null&&e!==void 0?Pt(r,e,n,i):e}const s=r.mask,o=r._liveConfig;if(o!==void 0&&o.type===Z.Value)return o.valueType!==void 0?k(e,o.valueType,n,i):e;if((s&u.PARSE_RESULT)!==0)try{return{success:!0,value:k(e,r.shape,n,i)}}catch(c){return{success:!1,error:c instanceof Error?c:new Error(String(c))}}const a=Tt(e);if((s&a)===0&&!r.values?.has(e)){if((s&u.UNDEFINED)!==0){n.warn("Invalid value for optional type, defaulting to undefined",{value:e,path:i});return}throw B(i,s,e)}return a<u.OBJECT?(s&u.HAS_FORMAT)!==0&&e!==null&&e!==void 0?Pt(s,e,n,i):e:(s&u.UNION)!==0?We(a,e,r,n,i):a===u.ARRAY?ce(e,r.shape,n,i):(s&u.RECORD)!==0?fe(e,r.shape,n,i):(s&u.ENTITY)!==0&&n.queryClient!==void 0?Ct(e,r,n):ue(e,r,n,i)}function We(e,t,n,i,r){if(e===u.ARRAY){const s=n.shape[I];return s===void 0||typeof s=="number"?t:ce(t,s,i,r)}else{const s=n.typenameField,o=s?t[s]:void 0;if(o===void 0||typeof o!="string"){const c=n.shape[F];if(c===void 0)throw new Error(`Typename field '${s}' is required for union discrimination but was not found in the data`);return fe(t,c,i,r)}const a=n.shape[o];if(a===void 0||typeof a=="number")throw new Error(`Unknown typename '${o}' in union`);return a.mask&u.ENTITY&&i.queryClient!==void 0?Ct(t,a,i):ue(t,a,i,r)}}function ce(e,t,n,i){const r=[];for(let s=0;s<e.length;s++)try{r.push(k(e[s],t,n,`${i}[${s}]`))}catch(o){n.warn("Failed to parse array item, filtering out",{index:s,value:e[s],error:o instanceof Error?o.message:String(o)})}return r}function fe(e,t,n,i){for(const[r,s]of Et(e))e[r]=k(s,t,n,`${i}["${r}"]`);return e}function ue(e,t,n,i){if(R.has(e))return e;const r=t.shape;for(const[s,o]of Et(r))e[s]=k(e[s],o,n,`${i}.${s}`);return e}function Ct(e,t,n){const i=n.queryClient,r=n.preloadedEntities;let s,o;if(r!==void 0)s=e.__entityRef,o=s;else{const p=e[t.idField];if(p==null||typeof p!="string"&&typeof p!="number")throw new Error(`Entity id must be a string or number: ${t.typenameValue} (got ${typeof p})`);o=p,s=A.hashValue([t.typenameValue,o])}const a=n.seenByKey.get(s);if(a!==void 0)return a.data;if(r!==void 0){const w=i.entityMap.getEntity(s)?.data??r.get(s);if(w===void 0)throw new Error(`Cached entity ${s} not found in preloaded map`);e=w}const c={};typeof t.idField=="symbol"&&(c[t.idField]=o);const f=i.entityMap.getEntity(s),d=n.isPartialEvent&&f!==void 0,l={key:s,shape:t,data:c,rawKeys:d?new Set(Object.keys(e)):void 0};n.seen.set(c,l),n.seenByKey.set(s,l);const h=`[[${t.typenameValue}:${o}]]`,g=t.shape;for(const[p,w]of Et(g))d&&!(p in e)||(c[p]=k(e[p],w,n,`${h}.${p}`));return c}function ze(e,t){return Je(e,t.shape,t.typenameField)}function Je(e,t,n){if(t===void 0)return!0;for(const i of Object.keys(t)){if(i===n)continue;const r=t[i];if(r instanceof v){if((r.mask&u.UNDEFINED)!==0)continue;if(!(i in e)||e[i]===void 0)return!1}else if(typeof r=="number"){if((r&u.UNDEFINED)!==0)continue;if(!(i in e)||e[i]===void 0)return!1}else if(!(i in e)||e[i]===void 0)return!1}return!0}const Xe=Object.prototype,z=new WeakMap;function D(e){if(typeof e!="object"||e===null)return e;if(et.has(e))return D(e.getValue());if(R.has(e))return e;if(Array.isArray(e)){let t=z.get(e);return t===void 0&&(t=new Proxy(e,Ze),z.set(e,t)),t}if(Object.getPrototypeOf(e)===Xe){let t=z.get(e);return t===void 0&&(t=new Proxy(e,tn),z.set(e,t)),t}return e}const Ze={get(e,t,n){if(typeof t=="string"){const i=Number(t);if(Number.isInteger(i)&&i>=0&&i<e.length)return D(e[i])}return Reflect.get(e,t,n)},set(){throw new Error("Cannot mutate a read-only array")},deleteProperty(){throw new Error("Cannot mutate a read-only array")}},tn={get(e,t,n){return typeof t=="string"?D(e[t]):Reflect.get(e,t,n)},set(){throw new Error("Cannot mutate a read-only object")},deleteProperty(){throw new Error("Cannot mutate a read-only object")},has(e,t){return t in e},ownKeys(e){return Reflect.ownKeys(e)},getOwnPropertyDescriptor(e,t){return Object.getOwnPropertyDescriptor(e,t)}};class en{_notifier;_queryClient;_proxies=new Map;key;typename;id;idField;data;refCount=0;entityRefs;liveCollections=[];satisfiedDefs=new WeakSet;parseId=-1;_entityCache;_extraMethods;_extraGetters;constructor(t,n,i,r,s,o){this._notifier=b.notifier(),this._queryClient=o,this.key=t,this.typename=n,this.id=i,this.idField=r,this.data=s,this.entityRefs=void 0}retain(){this.refCount++;const t=this._entityCache?.gcTime;t!==void 0&&this._queryClient.gcManager.cancel(this.key,t)}release(){if(--this.refCount>0)return;if(this.refCount<0)throw new Error(`Entity ${this.typename}:${this.id} released more times than retained`);const t=this._entityCache?.gcTime;t!==void 0?this._queryClient.gcManager.schedule(this.key,t,tt.Entity):this.evict()}evict(){const t=this.liveCollections.slice();this.liveCollections.length=0;for(const i of t)i.destroy();this._queryClient.entityMap.remove(this.key);const n=this.entityRefs;if(this.entityRefs=void 0,n)for(const i of n.keys())i.release()}setChildRefs(t,n){const i=this.entityRefs;if(t!==void 0&&t.size>0)for(const r of t.keys())(i===void 0||!i.has(r))&&r.retain();if(i!==void 0&&i.size>0)for(const r of i.keys())(t===void 0||!t.has(r))&&r.release();this.entityRefs=t,n&&this.save()}addChildRef(t){this.entityRefs===void 0&&(this.entityRefs=new Map);const n=this.entityRefs.get(t)??0;this.entityRefs.set(t,n+1),n===0&&t.retain(),this.save()}removeChildRef(t){if(this.entityRefs===void 0)return;const n=this.entityRefs.get(t);n!==void 0&&(n<=1?(this.entityRefs.delete(t),t.release()):this.entityRefs.set(t,n-1),this.save())}getProxy(t){const n=t;let i=this._proxies.get(n);return i===void 0&&(i=rn(this,this.key,t,this._notifier,this._queryClient),this._proxies.set(n,i)),i}get proxy(){return this._proxies.values().next().value}satisfiesDef(t){return this.satisfiedDefs.has(t)?!0:ze(this.data,t)?(this.satisfiedDefs.add(t),!0):!1}save(){this._queryClient.entityMap.save(this)}notify(){this._notifier.notify()}consume(){this._notifier.consume()}}function nn(e,t,n){const i=[];for(const r of e){if(typeof r!="object"||r===null)continue;const s=R.get(r);if(s===void 0)continue;const o=n.entityMap.getEntity(s);o!==void 0&&o.satisfiesDef(t)&&i.push(r)}return i}function rn(e,t,n,i,r){const s=n.shape??{},o=n,a=o._methods,c=o._entityClass,f=o._entityConfig,d=c?c.prototype:pt.prototype,l=n.typenameField,h=new Map,g=new Map,p=()=>({__entityRef:t});let w;f?.hasSubscribe&&a&&"__subscribe"in a&&(w=b.relay(E=>{const y=C=>{C.__eventSource=t,r.applyMutationEvent(C)},_=a.__subscribe.call(m,y);return E.value=m,_}));let m;if(l&&!(l in s))throw new Error(`typenameField "${l}" must be declared in the entity shape`);const S=Object.keys(s);if(S.includes("__typename")||S.push("__typename"),a)for(const E of Object.keys(a))S.includes(E)||S.push(E);let T,x=S;function V(){const E=e._extraMethods;if(E!==T){if(T=E,x=S.slice(),E!==void 0)for(const _ of Object.keys(E))x.includes(_)||x.push(_);const y=e._extraGetters;if(y!==void 0)for(const _ of Object.keys(y))x.includes(_)||x.push(_)}return x}const K={getPrototypeOf(){return d},get(E,y){if(typeof y=="symbol")return;if(y==="toJSON")return p;if(y==="__context")return r.getContext();if(y==="__typename")return e.typename;if(w?.value,i.consume(),typeof y=="string"){const C=e._extraGetters;if(C!==void 0&&y in C)return C[y]();const N=e._extraMethods;if(N!==void 0&&y in N){let O=h.get(y);return O||(O=N[y].bind(m),h.set(y,O)),O}if(a&&y in a){let O=h.get(y);return O||(O=b.reactiveMethod(m,a[y].bind(m)),h.set(y,O)),O}}const _=e.data[y];if(typeof _=="object"&&_!==null&&et.has(_))return D(_.getValue());if(Array.isArray(_)&&typeof y=="string"){const C=s[y];if(C instanceof v&&(C.mask&u.ARRAY)!==0){const N=C.shape;if(N instanceof v&&(N.mask&u.ENTITY)!==0){const O=N.typenameValue;if(O!==void 0){const xt=r.getEntityDefsForTypename(O);if(xt!==void 0&&xt.length>1){const nt=g.get(y);if(nt!==void 0&&nt.source===_)return D(nt.filtered);const At=nn(_,N,r);return g.set(y,{source:_,filtered:At}),D(At)}}}}return D(_)}return D(_)},set(){throw new Error("Entity properties are read-only")},has(E,y){if(y==="__typename")return!0;if(typeof y=="string"){const _=e._extraGetters;if(_&&y in _)return!0;const C=e._extraMethods;if(C&&y in C||a&&y in a)return!0}return y in s},ownKeys(){return V()},getOwnPropertyDescriptor(E,y){if(y==="__typename")return{enumerable:!0,configurable:!0,value:e.typename,writable:!1};if(y in s)return{enumerable:!0,configurable:!0,value:K.get(E,y,m),writable:!1};if(typeof y=="string"){const _=e._extraGetters;if(_&&y in _)return{enumerable:!0,configurable:!0,value:K.get(E,y,m),writable:!1};const C=e._extraMethods;if(C&&y in C)return{enumerable:!0,configurable:!0,value:K.get(E,y,m),writable:!1};if(a&&y in a)return{enumerable:!1,configurable:!0,value:K.get(E,y,m),writable:!1}}}};return m=new Proxy({},K),R.set(m,t),b.setScopeOwner(m,r),m}class sn{instances=new Map;persistEntity;constructor(t){this.persistEntity=t}hasEntity(t){return this.instances.has(t)}getEntity(t){return this.instances.get(t)}getOrCreateEntity(t,n,i,r){let s=this.instances.get(t);if(s===void 0){const o=i.idField;if(o===void 0)throw new Error(`Entity id field is required ${i.typenameValue}`);const a=n[o];if(typeof a!="string"&&typeof a!="number")throw new Error(`Entity id must be string or number: ${i.typenameValue}`);const c=i;s=new en(t,i.typenameValue,a,o,n,r),s._entityCache=c._entityCache,this.instances.set(t,s)}return s.parseId=r.currentParseId,s}remove(t){this.instances.delete(t)}save(t){let n;if(t.entityRefs){n=new Set;for(const i of t.entityRefs.keys())n.add(i.key)}this.persistEntity(t.key,t.data,n)}}class bt{onlineSignal;manualOverride=void 0;eventListenersAttached=!1;constructor(t){const n=t??this.detectOnlineStatus();this.onlineSignal=b.signal(n),this.canAttachListeners()&&this.attachEventListeners()}get isOnline(){return this.manualOverride!==void 0?this.manualOverride:this.onlineSignal.value}setNetworkStatus(t){this.manualOverride=t,this.onlineSignal.value=t}clearManualOverride(){this.manualOverride=void 0,this.onlineSignal.value=this.detectOnlineStatus()}getOnlineSignal(){return this.onlineSignal}detectOnlineStatus(){return typeof navigator<"u"&&"onLine"in navigator?navigator.onLine:!0}canAttachListeners(){return typeof window<"u"&&typeof window.addEventListener=="function"}destroy(){this.eventListenersAttached&&this.handleOnline&&this.handleOffline&&(window.removeEventListener("online",this.handleOnline),window.removeEventListener("offline",this.handleOffline),this.eventListenersAttached=!1)}handleOnline=void 0;handleOffline=void 0;attachEventListeners(){this.eventListenersAttached||(this.handleOnline=()=>{this.manualOverride===void 0&&(this.onlineSignal.value=!0)},this.handleOffline=()=>{this.manualOverride===void 0&&(this.onlineSignal.value=!1)},window.addEventListener("online",this.handleOnline),window.addEventListener("offline",this.handleOffline),this.eventListenersAttached=!0)}}class Ot{static onlineSignal=b.signal(!0);get isOnline(){return!0}setNetworkStatus(t){}clearManualOverride(){}getOnlineSignal(){return Ot.onlineSignal}destroy(){}}const le=new bt,on=b.context(le);function Rt(e,t=typeof window>"u"){let n;e===!1?n=0:e===void 0||e===!0?n=t?0:3:typeof e=="number"?n=e:n=e.retries;const i=typeof e=="object"&&e.retryDelay?e.retryDelay:r=>1e3*Math.pow(2,r);return{retries:n,retryDelay:i}}class an{static cache;static controller;params;config;constructor(){return ht(this)}}const jt=new WeakMap;class W{constructor(t,n){this.captured=n,this.statics=t}statics;createExecutionContext(t,n){return st(this.captured,t,n)}resolveOptions(t){const{methods:n}=this.captured,i=n.getConfig?n.getConfig.call(t):t.config,r=Rt(i?.retry);return{config:i,retryConfig:r}}static for(t){let n=jt.get(t);if(n!==void 0)return n;const i=new t,r=Ht(i),s=String(r.methods.getIdentityKey.call(r.fields)),o=r.fields.result,a=o instanceof v?o:se.object(o),c=(a.mask&u.ENTITY)!==0,f=t.cache,d=r.fields.fetchNext,l=t.controller;if(!l)throw new Error(`Query class "${t.name}" must define a static \`controller\` property. Extend RESTQuery (from fetchium/rest) or set \`static controller = MyController\` on your query class.`);const h=typeof l.prototype.sendNext=="function",g=c?a:new v(u.ENTITY|u.OBJECT,a.shape,void 0,void 0,s,lt);return n=new W({id:s,shape:g,cache:f,rawFetchNext:d,hasSendNext:h,isEntityResult:c,controllerClass:l},r),jt.set(t,n),n}}const cn=(e,t)=>{const n=W.for(e);return St(n,t)};function fn(e,...t){const n=W.for(e),i=b.getContext(be);if(i===void 0)throw new Error("QueryClient not found");const r=t[0];return i.getQuery(n,r)}function de(e,t){return new Promise((n,i)=>{if(t?.aborted){i(t.reason);return}const r=setTimeout(n,e);t?.addEventListener("abort",()=>{clearTimeout(r),i(t.reason)},{once:!0})})}async function ft(e,t,n){if(t.retries<0)throw new Error("retries must be non-negative");const i=Math.max(0,t.retries);let r;for(let s=0;s<=i;s++){n?.throwIfAborted();try{return await e()}catch(o){if(r=o,s>=i)throw o;await de(t.retryDelay(s),n)}}throw r}class un{def;queryKey;storageKey=-1;relay;queryClient;initialized=!1;updatedAt=void 0;params=void 0;unsubscribe=void 0;_relayState=void 0;wasPaused=!1;currentParams=void 0;debounceTimer=void 0;config=void 0;retryConfig=Rt(void 0);_abortController=void 0;_executionCtx=void 0;_executionCtxKey=-1;rootEntity;_extraMethods={};_queryId=0;get key(){return this.queryKey}get relayState(){if(!this._relayState)throw new Error("Relay state not initialized");return this._relayState}constructor(t,n,i,r){this.def=t,this.queryClient=n,this.queryKey=i,this.params=r,this._extraMethods={__refetch:this.refetch},t.statics.hasSendNext&&(this._extraMethods.__fetchNext=this.fetchNext);const s=qt(r);this._queryId=s!==void 0?A.hashValue(s):0,this.relay=b.relay(o=>{this._relayState=o;const a=()=>{clearTimeout(this.debounceTimer),this.debounceTimer=void 0,this._abortController?.abort(),this._abortController=void 0,this._fetchNextAbort?.abort(),this._fetchNextAbort=void 0,this._fetchNextPromise=void 0,this.unsubscribe?.(),this.unsubscribe=void 0;const f=this.config?.gcTime??Vt.DEFAULT_GC_TIME;this.queryClient.gcManager.schedule(this.queryKey,f,tt.Query)},c=(f=!1)=>{const{wasPaused:d,isPaused:l,initialized:h}=this;if(this.wasPaused=l,l&&!d&&h){a();return}const g=qt(this.params),p=St(this.def,g),w=p!==this.storageKey;w&&(this.currentParams=g,this.storageKey=p),this.getOrCreateExecutionContext(),this.initialized?d||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())};return c(!0),{update:c,deactivate:a}},{desc:`Query(${t.statics.id})`})}applyData(t,n,i=!1,r){const s=this.def;return this.rootEntity=this.queryClient.parseAndApplyRootEntity(t,this._queryId,s.statics.shape,n,i,r),this.rootEntity._extraMethods===void 0&&(this.rootEntity._extraMethods=this._extraMethods,this.rootEntity._extraGetters={__hasNext:()=>this.hasNext,__isFetchingNext:()=>this._fetchNextPromise!==void 0}),this.rootEntity.getProxy(s.statics.shape)}saveQueryMetadata(){if(this.rootEntity===void 0||this.updatedAt===void 0)return;const t=new Map(this.rootEntity.entityRefs??[]);t.set(this.rootEntity,1),this.queryClient.saveQueryData(this.def,this.storageKey,{__entityRef:this.rootEntity.key},this.updatedAt,t)}async initialize(){const t=this.queryClient,n=this.relayState;this.initialized=!0;let i;try{i=await t.loadCachedQuery(this.def,this.storageKey),i!==void 0&&(this.updatedAt=i.updatedAt,n.value=this.applyData(i.value,!1,!1,i.preloadedEntities))}catch(r){t.store.deleteQuery(this.storageKey),t.getContext().log?.warn?.("Failed to initialize query, the query cache may be corrupted or invalid",r)}if(!this.isPaused)try{if(i!==void 0&&this.setupSubscription(),i===void 0||this.isStale){if(await de(0),this.isPaused)return;this.runQueryImmediately()}}catch(r){n.setError(r)}}setupSubscription(){this.unsubscribe?.(),this.unsubscribe=void 0;const t=this.config?.subscribe;if(!t)return;const n=this._executionCtx;this.unsubscribe=t.call(n,i=>{i.__eventSource=this.queryKey,this.queryClient.applyMutationEvent(i)})}getOrCreateExecutionContext(){return(this._executionCtx===void 0||this._executionCtxKey!==this.storageKey)&&(this._executionCtxKey=this.storageKey,this._executionCtx=this.def.createExecutionContext(this.currentParams??{},this.queryClient.getContext()),this._executionCtx.refetch=()=>this.refetch(),this._executionCtx.rawFetchNext=this.def.statics.rawFetchNext),this.resolveAndApplyOptions(),this._executionCtx}resolveAndApplyOptions(){const t=this.def.resolveOptions(this._executionCtx);this.config=t.config,this.retryConfig=t.retryConfig}async runQuery(){const t=this.def;if(this.isPaused)throw new Error("Query is paused due to network status");const n=this.getOrCreateExecutionContext(),i=this.queryClient.getController(t.statics.controllerClass),r=this._abortController?.signal??new AbortController().signal;return ft(async()=>{const s=await i.send(n,r);this.updatedAt=Date.now();const o=this.applyData(s,!0);return this.saveQueryMetadata(),this.unsubscribe===void 0&&this.setupSubscription(),o},this.retryConfig,r)}runQueryImmediately(){this._abortController?.abort(),this._abortController=new AbortController,this._fetchNextAbort?.abort(),this._fetchNextAbort=void 0,this._fetchNextPromise=void 0,this.relayState.setPromise(this.runQuery())}runDebounced(){if(this.relayState.isPending)return;const t=this.config?.debounce??0;clearTimeout(this.debounceTimer),this.debounceTimer=setTimeout(()=>{this.debounceTimer=void 0,this.runQueryImmediately()},t)}refetch=()=>this.relayState.isPending?this.relay:(this.runQueryImmediately(),this.relay);markStale(){this.updatedAt=0}get resolvedParams(){return this.currentParams}_fetchNextPromise=void 0;_fetchNextAbort=void 0;fetchNext=()=>{if(this.updatedAt===void 0)throw new Error("Cannot call __fetchNext before initial data has loaded");return this._fetchNextPromise!==void 0?this._fetchNextPromise:(queueMicrotask(()=>this.rootEntity?.notify()),this._fetchNextPromise=this.runFetchNext().then(t=>(this._fetchNextPromise=void 0,this.rootEntity?.notify(),t),t=>{throw this._fetchNextPromise=void 0,this.rootEntity?.notify(),t}),this._fetchNextPromise)};get hasNext(){if(this.rootEntity===void 0||!this._executionCtx)return!1;const t=this.queryClient.getController(this.def.statics.controllerClass);return t.hasNext?(this._executionCtx.resultData=this.rootEntity.data,t.hasNext(this._executionCtx)):!1}async runFetchNext(){const t=this.def;this._fetchNextAbort=new AbortController;const n=this._fetchNextAbort.signal,i=this.getOrCreateExecutionContext();i.resultData=this.rootEntity.data;const r=this.queryClient.getController(t.statics.controllerClass);return ft(async()=>{const s=await r.sendNext(i,n);this.updatedAt=Date.now();const o=this.applyData(s,!0,!0);return this.saveQueryMetadata(),o},this.retryConfig,n)}get isStale(){if(this.updatedAt===void 0)return!0;const t=this.config?.staleTime??0;return Date.now()-this.updatedAt>=t}get isPaused(){const t=this.config?.networkMode??L.Online;if(t===L.Always)return!1;const n=this.queryClient.networkManager.getOnlineSignal().value;switch(t){case L.Online:return!n;case L.OfflineFirst:return!n&&this.updatedAt===void 0;default:return!1}}}class ln{def;queryClient;_inFlight=!1;task;constructor(t,n){this.def=t,this.queryClient=n,this.task=this.createTask()}createTask(){return b.task(async t=>{if(this._inFlight)throw new Error("A mutation is already in progress. Await the previous call before starting a new one.");this._inFlight=!0;try{const n=await this.executeWithRetry(t),i=this.validateResponse(n);return this.processEffects(t,i),i}finally{this._inFlight=!1}},{desc:`Mutation(${this.def.id})`})}validateResponse(t){const n=this.def.responseShape;if(!(n instanceof v))return t;const i=this.queryClient.getContext().log?.warn??(()=>{}),r=new ct;return r.reset(void 0,void 0,i),ae(t,n,r)}processEffects(t,n){let i;if(this.def.hasGetEffects){const s=st(this.def.captured,t??{},this.queryClient.getContext());s.result=n,i=s.getEffects()}else if(this.def.effects!==void 0){const s={params:t,result:n};i=Y(this.def.effects,s)}if(i===void 0)return;const r=this.queryClient;it(i.creates,"create",r),it(i.updates,"update",r),it(i.deletes,"delete",r),i.invalidates&&r.invalidateQueries(i.invalidates)}executeWithRetry(t){const n=Rt(this.def.config?.retry,!0),i=this.queryClient.getController(this.def.controllerClass);if(!i.sendMutation)throw new Error(`Controller "${this.def.controllerClass.name}" does not implement sendMutation(). Add a sendMutation() method to handle mutations.`);return ft(async()=>{const r=new AbortController,s=st(this.def.captured,t??{},this.queryClient.getContext());return await i.sendMutation(s,r.signal)},n)}}function dn(e){return typeof e=="string"?e:U(e).typenameValue}function it(e,t,n){if(e)for(const[i,r]of e){const s=dn(i);s!==void 0&&n.applyMutationEvent({type:t,typename:s,data:r})}}const he="__eventSource";function ye(e){return{field:e,segments:e.indexOf(".")!==-1?e.split("."):void 0}}function hn(e){return e.map(ye)}function yn(e,t){if(t.segments===void 0)return e[t.field];let n=e;for(const i of t.segments){if(n==null)return;n=n[i]}return n}function pe(e,t){const n=[];for(let i=0;i<t.length;i++){const r=t[i],s=yn(e,r);if(s===void 0)return;n.push(r.field,s)}return A.hashValue(n)}function pn(e,t){if(e===void 0)return;const n=new Map;for(const[i,r]of e){const s=r.slice().sort((c,f)=>c[0]<f[0]?-1:c[0]>f[0]?1:0),o=[];let a=!0;for(const[c,f]of s){let d;if(Yt(f)){const l=Gt(f);d=yt(l,t)}else d=f;if(d===void 0){a=!1;break}o.push(c,d)}a&&n.set(i,A.hashValue(o))}return n.size>0?n:void 0}function Lt(e,t){const n=e.get(t);if(n!==void 0)return n.map(([i])=>i).sort()}class gn{fields;fieldPaths;_bindings=new Map;constructor(t){this.fields=t,this.fieldPaths=t.map(ye)}register(t,n){let i=this._bindings.get(t);i===void 0&&(i=new Set,this._bindings.set(t,i)),i.add(n)}unregister(t,n){const i=this._bindings.get(t);i!==void 0&&(i.delete(n),i.size===0&&this._bindings.delete(t))}getMatching(t){return this._bindings.get(t)}get isEmpty(){return this._bindings.size===0}}function $t(e){return A.hashValue(e)}class vn{_groups=new Map;getOrCreateGroup(t){const n=$t(t);let i=this._groups.get(n);return i===void 0&&(i=new gn(t),this._groups.set(n,i)),i}register(t,n,i){this.getOrCreateGroup(n).register(t,i)}unregister(t,n,i){const r=$t(n),s=this._groups.get(r);s!==void 0&&(s.unregister(t,i),s.isEmpty&&this._groups.delete(r))}registerBinding(t,n){const i=t._constraintHashes.get(n);if(i===void 0)return;const r=Lt(t._constraintFieldRefs,n);r!==void 0&&this.register(i,r,t)}unregisterBinding(t,n){const i=t._constraintHashes.get(n);if(i===void 0)return;const r=Lt(t._constraintFieldRefs,n);r!==void 0&&this.unregister(i,r,t)}routeEvent(t,n,i,r,s,o){for(const a of this._groups.values()){const c=pe(n,a.fieldPaths);if(c===void 0)continue;const f=a.getMatching(c);if(f!==void 0)for(const d of f)d.onEvent(t,i,r,s,o)}}}function Ut(e){const t=new Set;for(const n of e)if(typeof n=="object"&&n!==null){const i=P(n);i!==void 0&&t.add(i)}return t}class ge{_queryClient;_parent;_constraintHashes;_entityDefsByTypename;_constraintFieldRefs;instance;constructor(t,n,i,r,s,o){this._queryClient=i,this._parent=r,this._constraintHashes=s,this._constraintFieldRefs=n,this.instance=o,this._entityDefsByTypename=new Map;for(const a of t)a.typenameValue!==void 0&&this._entityDefsByTypename.set(a.typenameValue,a);et.add(this)}getValue(){return this.instance.getValue()}toJSON(){return this.instance.getRawValue()}reset(t){this.instance.reset(t)}append(t){this.instance.append(t)}onEvent(t,n,i,r,s){const o=this._entityDefsByTypename.get(t);if(o===void 0)return;const a=this._queryClient.entityMap.getEntity(n);if(i==="delete"){const f=a!==void 0?a.getProxy(o):s;f!==void 0&&(this.instance.onEvent(n,f,s??a?.data??{},"delete"),r?.());return}if(a===void 0||!a.satisfiesDef(o))return;r?.();const c=a.getProxy(o);this.instance.onEvent(n,c,a.data,i)}destroy(){this._queryClient.unregisterLiveCollection(this);const t=this._parent.liveCollections,n=t.indexOf(this);n!==-1&&t.splice(n,1)}}class mn{_notifier;_items;_keys;_outputSignal;_queryClient;_parent;constructor(t,n,i,r,s,o){this._notifier=b.notifier(),this._items=i,this._keys=Ut(i),this._queryClient=t,this._parent=n;const a=r!==void 0&&s!==void 0,c=o!==void 0;(a||c)&&(this._outputSignal=b.reactiveSignal(()=>{this._notifier.consume();let f=this._items;if(a){const d=[];for(const l of f){if(typeof l!="object"||l===null){d.push(l);continue}const h=P(l);if(h===void 0){d.push(l);continue}const g=t.entityMap.getEntity(h);if(g===void 0){d.push(l);continue}g.consume(),pe(g.data,r)===s&&d.push(l)}f=d}return c&&(f=(f===this._items?f.slice():f).sort(o)),f}))}onEvent(t,n,i,r){switch(r){case"create":this.add(t,n);break;case"update":!this.has(t)&&n!==void 0&&this.add(t,n);break;case"delete":this.remove(t);break}}getValue(){return this._outputSignal!==void 0?this._outputSignal.value:(this._notifier.consume(),this._items)}getRawValue(){return this._items}add(t,n){if(this._keys.has(t))return!1;this._keys.add(t),this._items.push(n);const i=this._queryClient.entityMap.getEntity(t);return i!==void 0&&(this._parent.addChildRef(i),i.save()),this._notifier.notify(),!0}remove(t){if(!this._keys.has(t))return!1;this._keys.delete(t);const n=this._findIndex(t);n!==-1&&this._items.splice(n,1);const i=this._queryClient.entityMap.getEntity(t);return i!==void 0&&this._parent.removeChildRef(i),this._notifier.notify(),!0}has(t){return this._keys.has(t)}reset(t){const n=this._items,i=Array.isArray(t)?t:[];this._items=i,this._keys=Ut(i);for(const r of i)if(typeof r=="object"&&r!==null){const s=P(r);if(s!==void 0){const o=this._queryClient.entityMap.getEntity(s);o!==void 0&&this._parent.addChildRef(o)}}for(const r of n)if(typeof r=="object"&&r!==null){const s=P(r);if(s!==void 0){const o=this._queryClient.entityMap.getEntity(s);o!==void 0&&this._parent.removeChildRef(o)}}this._notifier.notify()}append(t){if(Array.isArray(t))for(const n of t){if(typeof n!="object"||n===null)continue;const i=P(n);i!==void 0&&this.add(i,n)}}_findIndex(t){for(let n=0;n<this._items.length;n++){const i=this._items[n];if(typeof i=="object"&&i!==null&&P(i)===t)return n}return-1}}class _n{_notifier;_value;_createdKeys;_deletedKeys;_queryClient;_parent;_onCreate;_onUpdate;_onDelete;constructor(t,n,i,r,s,o){this._notifier=b.notifier(),this._value=i,this._createdKeys=new Set,this._deletedKeys=new Set,this._queryClient=t,this._parent=n,this._onCreate=r,this._onUpdate=s,this._onDelete=o}onEvent(t,n,i,r){switch(r){case"create":if(this._createdKeys.has(t))return;this._createdKeys.add(t),this._value=this._onCreate(this._value,n);break;case"update":this._value=this._onUpdate(this._value,n??i);break;case"delete":if(this._deletedKeys.has(t))return;this._deletedKeys.add(t),this._value=this._onDelete(this._value,n??i);break}this._notifier.notify()}getValue(){return this._notifier.consume(),this._value}getRawValue(){return this._value}reset(t){this._value=t,this._createdKeys.clear(),this._deletedKeys.clear(),this._notifier.notify()}append(t){}}function ve(e,t,n,i,r){let s=e.constraintFieldRefs;if(s===void 0){s=new Map;for(const f of e.entityDefs){const d=f.typenameValue;d!==void 0&&s.set(d,[[he,n.key]])}}const o=pn(s,i)??new Map;let a;if(e.type===Z.Array){let f,d;if(e.constraintFieldRefs!==void 0&&o.size>0&&o.size===1)for(const[l]of e.constraintFieldRefs){const h=o.get(l);if(h!==void 0){d=h;const g=e.constraintFieldRefs.get(l);g!==void 0&&(f=hn(g.map(([p])=>p)));break}}a=new mn(r,n,Array.isArray(t)?t:[],f,d,e.sort)}else a=new _n(r,n,t,e.onCreate,e.onUpdate,e.onDelete);const c=new ge(e.entityDefs,s,r,n,o,a);return n.liveCollections.push(c),r.registerLiveCollection(c),c}const me=Object.entries,_e=Object.prototype;function rt(e,t,n,i=!1){const r=e.queryClient;r.currentParseId++;const s=e.seen,o=new Map;return{data:H(t,s,r,n,o,i),entityRefs:o}}function H(e,t,n,i,r,s){if(typeof e!="object"||e===null)return e;const o=t.get(e);if(o!==void 0)return wn(o,t,n,i,r,s);if(Array.isArray(e)){for(let a=0;a<e.length;a++){const c=e[a];typeof c=="object"&&c!==null&&!(c instanceof G)&&!R.has(c)&&(e[a]=H(c,t,n,i,r,s))}return e}if(Object.getPrototypeOf(e)===_e&&!R.has(e)){const a=e;for(const c of Object.keys(a)){const f=a[c];typeof f=="object"&&f!==null&&!(f instanceof G)&&!R.has(f)&&(a[c]=H(f,t,n,i,r,s))}}return e}function we(e){return typeof e=="object"&&e!==null&&!(e instanceof G)&&!R.has(e)}function wn(e,t,n,i,r,s){const{key:o,data:a,shape:c,rawKeys:f}=e,d=c.shape,l=n.prepareEntity(o,a,c),h=l.data,g=h!==a,p=g&&f!==void 0&&l.entityRefs!==void 0?new Map(l.entityRefs):new Map;if(g?(Ee(d,a,h,f,l,h,t,n,i,p,s),l.notify()):Ce(d,a,l,a,t,n,i,p,s),s&&l.liveCollections.length>0)for(const m of l.liveCollections){const S=m.instance.getRawValue();if(Array.isArray(S))for(const T of S){if(typeof T!="object"||T===null)continue;const x=R.get(T);if(x===void 0)continue;const V=n.entityMap.getEntity(x);V!==void 0&&p.set(V,(p.get(V)??0)+1)}}l.setChildRefs(p.size>0?p:void 0,i);const w=l.getProxy(c);return r.set(l,(r.get(l)??0)+1),w}function Ee(e,t,n,i,r,s,o,a,c,f,d){for(const[l,h]of me(e))if(!(i!==void 0&&!i.has(l)))if(we(t[l])&&(t[l]=H(t[l],o,a,c,f,d)),h instanceof v&&h._liveConfig!==void 0){const g=n[l];g instanceof ge?d?g.append(t[l]):g.reset(t[l]):n[l]=ve(h._liveConfig,t[l],r,s,a)}else{const g=t[l],p=n[l];if(ut(g)&&ut(p)){const w=h instanceof v&&h.shape!==void 0?h.shape:void 0;if(w!==void 0)Ee(w,g,p,void 0,r,s,o,a,c,f,d);else for(const m of Object.keys(g))p[m]=g[m];n[l]=p}else n[l]=g}}function Ce(e,t,n,i,r,s,o,a,c){for(const[f,d]of me(e))if(f in t)if(we(t[f])&&(t[f]=H(t[f],r,s,o,a,c)),d instanceof v&&d._liveConfig!==void 0)t[f]=ve(d._liveConfig,t[f],n,i,s);else{const l=t[f];if(ut(l)){const h=d instanceof v&&d.shape!==void 0?d.shape:void 0;h!==void 0&&Ce(h,l,n,i,r,s,o,a,c)}}}function ut(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.getPrototypeOf(e)===_e&&!R.has(e)}function En(e){if(e!==void 0)return typeof e=="string"?e:typeof e=="function"?e():e.value}function Cn(e){return b.isSignal(e)}function qt(e){if(e===void 0)return;const t={};for(const[n,i]of Object.entries(e))Cn(i)?t[n]=i.value:t[n]=i;return t}const St=(e,t)=>A.hashValue([e.statics.id,t]);class bn{entityMap;queryInstances=new Map;mutationInstances=new Map;gcManager;networkManager;isServer;store;currentParseId=0;context;typenameRegistry=new Map;constraintRegistry=new Map;mergedDefCache=new Map;controllers=new Map;networkUnsubscribe;constructor(t={}){const{store:n=new Nt.SyncQueryStore(new Nt.MemoryPersistentStore),log:i,evictionMultiplier:r,controllers:s,networkManager:o,gcManager:a,...c}=t;this.isServer=typeof window>"u",this.store=n,this.context={...c,log:i??console,evictionMultiplier:r},this.gcManager=t.gcManager??(this.isServer?new Bt:new Kt(this.handleEviction,r)),this.networkManager=t.networkManager??new bt,this.entityMap=new sn((l,h,g)=>this.store.saveEntity(l,h,g));for(const l of t.controllers??[])this.controllers.set(l.constructor,l),l.register(this);const f=this.networkManager.getOnlineSignal(),d=b.watcher(()=>f.value);this.networkUnsubscribe=d.addListener(()=>{const l=f.value;for(const h of this.controllers.values())h.onNetworkStatusChange?.(l)},{skipInitial:!0}),this.store.purgeStaleQueries?.()}getController(t){let n=this.controllers.get(t);if(!n){try{n=new t}catch{throw new Error(`No controller registered for ${t.name} and auto-instantiation failed. Pass an instance via QueryClient config: new QueryClient({ store, controllers: [new ${t.name}(...)] })`)}this.controllers.set(t,n),n.register(this)}return n}getContext(){return this.context}registerEntityDef(t){const n=t.typenameValue;if(n===void 0||t._entityClass===void 0)return;const i=this.typenameRegistry.get(n);if(i!==void 0){if(i.indexOf(t)!==-1)return;i.push(t),this.mergedDefCache.delete(n),this.getMergedDef(n)}else this.typenameRegistry.set(n,[t])}getEntityDefsForTypename(t){return this.typenameRegistry.get(t)}getMergedDef(t){let n=this.mergedDefCache.get(t);if(n!==void 0)return n;const i=this.typenameRegistry.get(t);if(i!==void 0)return n=v.merge(i),this.mergedDefCache.set(t,n),n}saveQueryData(t,n,i,r,s){const o=s!==void 0&&s.size>0?new Set([...s.keys()].map(a=>a.key)):void 0;this.store.saveQuery(t,n,i,r,o)}activateQuery(t){const{def:n,queryKey:i,storageKey:r,config:s}=t;this.store.activateQuery(n,r);const o=s?.gcTime??Vt.DEFAULT_GC_TIME;this.gcManager.cancel(i,o)}loadCachedQuery(t,n){return this.store.loadQuery(t,n)}getQuery(t,n){const i=St(t,n);let r=this.queryInstances.get(i);return r===void 0&&(r=new un(t,this,i,n),this.queryInstances.set(i,r)),r.relay}getMutation(t){const n=t.id;let i=this.mutationInstances.get(n);return i===void 0&&(i=new ln(t,this),this.mutationInstances.set(n,i)),i.task}parseData(t,n,i){const r=this.context.log?.warn??(()=>{}),s=new ct;return s.reset(this,i,r),{data:ae(t,n,s),ctx:s}}applyRefs(t,n=!0,i=!1){return rt(t.ctx,t.data,n,i)}parseAndApplyRootEntity(t,n,i,r,s=!1,o){typeof i.idField=="symbol"&&typeof t=="object"&&t!==null&&!("__entityRef"in t)&&(t[lt]=n);const a=this.parseData(t,i,o),c=rt(a.ctx,a.data,r,s),f=R.get(c.data);return this.entityMap.getEntity(f)}prepareEntity(t,n,i){return this.registerEntityDef(i),this.entityMap.getOrCreateEntity(t,n,i,this)}applyMutationEvent(t){const{type:n,typename:i}=t,r=this.getMergedDef(i);if(r===void 0)return;const s=r.idField;if(s===void 0||typeof s=="symbol")return;const o=t.data,a=t.id!==void 0?t.id:n==="delete"&&(typeof o=="string"||typeof o=="number")?o:o[s];if(a===void 0)return;const c=A.hashValue([i,a]),f=t.__eventSource,d=typeof o=="object"&&o!==null?o:{},l=this.entityMap.getEntity(c);if(n==="delete"){const w=l!==void 0?l.data:d;this.routeEvent(i,w,c,n,f,void 0,w);return}try{const w=this.context.log?.warn??(()=>{}),m=new ct;m.reset(this,void 0,w,!0);const S=He(d,r,m);rt(m,S,!0)}catch(w){if(this.context.log?.warn?.("Failed to apply mutation event",w),l===void 0){const m=this.entityMap.getEntity(c);m!==void 0&&m.evict()}return}const h=this.entityMap.getEntity(c);if(h===void 0)return;this.entityMap.save(h);const g=l===void 0;let p=!1;this.routeEvent(i,h.data,c,n,f,()=>{p=!0}),g&&!p&&h.evict()}invalidateQueries(t){for(const n of t){const i=Array.isArray(n),r=i?n[0]:n,s=i?n[1]:void 0,a=W.for(r).statics.id;for(const[,c]of this.queryInstances)c.def.statics.id===a&&(s===void 0||On(c.resolvedParams,s))&&c.markStale()}}handleEviction=(t,n)=>{if(n===tt.Query){const r=this.queryInstances.get(t);if(r===void 0)return;r.rootEntity?.evict(),this.queryInstances.delete(t);return}const i=this.entityMap.getEntity(t);i!==void 0&&i.evict()};getOrCreateMatcher(t){let n=this.constraintRegistry.get(t);return n===void 0&&(n=new vn,this.constraintRegistry.set(t,n)),n}registerLiveCollection(t){for(const[n,i]of t._entityDefsByTypename)this.registerEntityDef(i),this.getOrCreateMatcher(n).registerBinding(t,n)}unregisterLiveCollection(t){for(const n of t._entityDefsByTypename.keys()){const i=this.constraintRegistry.get(n);i!==void 0&&i.unregisterBinding(t,n)}}routeEvent(t,n,i,r,s,o,a){const c=this.constraintRegistry.get(t);if(c===void 0)return;const f=s!==void 0?{...n,[he]:s}:n;c.routeEvent(t,f,i,r,o,a)}destroy(){this.networkUnsubscribe?.(),this.gcManager.destroy(),this.networkManager.destroy();for(const t of this.controllers.values())t.destroy?.();this.controllers.clear(),this.queryInstances.clear(),this.mutationInstances.clear(),this.constraintRegistry.clear(),this.typenameRegistry.clear(),this.mergedDefCache.clear()}}const be=b.context(void 0);function On(e,t){if(e===void 0)return!1;for(const n in t)if(e[n]!==t[n])return!1;return!0}exports.ARRAY_KEY=I;exports.Entity=pt;exports.GcManager=Kt;exports.LiveFieldConfig=$;exports.LiveFieldType=Z;exports.Mask=u;exports.NetworkManager=bt;exports.NetworkManagerContext=on;exports.NetworkMode=L;exports.NoOpGcManager=Bt;exports.NoOpNetworkManager=Ot;exports.QUERY_ID=lt;exports.Query=an;exports.QueryClient=bn;exports.QueryClientContext=be;exports.RECORD_KEY=F;exports.ValidatorDef=v;exports.createDefinitionProxy=ht;exports.defaultNetworkManager=le;exports.draft=Ye;exports.extractDefinition=Ht;exports.fetchQuery=fn;exports.queryKeyForClass=cn;exports.registerFormat=wt;exports.reifyValue=Y;exports.resolveBaseUrl=En;exports.t=se;
2
+ //# sourceMappingURL=QueryClient-CLi3ONNM.js.map