@fozy-labs/rx-toolkit 0.5.4 → 0.6.2

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 (303) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +22 -13
  3. package/dist/common/devtools/reduxDevtools.js +17 -2
  4. package/dist/common/react/index.d.ts +1 -0
  5. package/dist/common/react/index.js +1 -0
  6. package/dist/common/react/useIsomorphicLayoutEffect.d.ts +17 -0
  7. package/dist/common/react/useIsomorphicLayoutEffect.js +17 -0
  8. package/dist/index.d.ts +1 -2
  9. package/dist/index.js +1 -2
  10. package/dist/query/api/createApi.d.ts +4 -0
  11. package/dist/query/api/createApi.js +9 -0
  12. package/dist/query/api/index.d.ts +1 -0
  13. package/dist/query/api/index.js +1 -0
  14. package/dist/query/constants.d.ts +12 -0
  15. package/dist/query/constants.js +15 -0
  16. package/dist/query/core/api/Api.d.ts +20 -0
  17. package/dist/query/core/api/Api.js +129 -0
  18. package/dist/query/core/api/constants.d.ts +2 -0
  19. package/dist/query/core/api/constants.js +3 -0
  20. package/dist/query/core/api/index.d.ts +3 -0
  21. package/dist/query/core/api/index.js +3 -0
  22. package/dist/query/core/api/mergeHooks.d.ts +2 -0
  23. package/dist/query/core/api/mergeHooks.js +26 -0
  24. package/dist/query/core/api/normalizeLinks.d.ts +2 -0
  25. package/dist/query/core/api/normalizeLinks.js +11 -0
  26. package/dist/query/core/cache/CacheEntry.d.ts +21 -0
  27. package/dist/query/core/cache/CacheEntry.js +54 -0
  28. package/dist/query/core/cache/CacheMap.d.ts +19 -0
  29. package/dist/query/core/cache/CacheMap.js +32 -0
  30. package/dist/query/core/cache/QueryCacheEntry.d.ts +21 -0
  31. package/dist/query/core/cache/QueryCacheEntry.js +136 -0
  32. package/dist/query/core/cache/index.d.ts +3 -0
  33. package/dist/query/core/cache/index.js +3 -0
  34. package/dist/query/core/command/Command.d.ts +67 -0
  35. package/dist/query/core/command/Command.js +253 -0
  36. package/dist/query/core/command/CommandAgent.d.ts +17 -0
  37. package/dist/query/core/command/CommandAgent.js +67 -0
  38. package/dist/query/core/command/LinkManager.d.ts +24 -0
  39. package/dist/query/core/command/LinkManager.js +71 -0
  40. package/dist/query/core/command/index.d.ts +2 -0
  41. package/dist/query/core/command/index.js +2 -0
  42. package/dist/query/core/errors/CacheEntryRemovedError.d.ts +7 -0
  43. package/dist/query/core/errors/CacheEntryRemovedError.js +9 -0
  44. package/dist/query/core/errors/MachineStateError.d.ts +8 -0
  45. package/dist/query/core/errors/MachineStateError.js +10 -0
  46. package/dist/query/core/errors/MachineTransitionError.d.ts +7 -0
  47. package/dist/query/core/errors/MachineTransitionError.js +9 -0
  48. package/dist/query/core/errors/index.d.ts +3 -0
  49. package/dist/query/core/errors/index.js +3 -0
  50. package/dist/query/core/index.d.ts +8 -0
  51. package/dist/query/core/index.js +8 -0
  52. package/dist/query/core/machine/Machine.d.ts +21 -0
  53. package/dist/query/core/machine/Machine.js +42 -0
  54. package/dist/query/core/machine/MachineBase.d.ts +31 -0
  55. package/dist/query/core/machine/MachineBase.js +176 -0
  56. package/dist/query/core/machine/MachineError.d.ts +10 -0
  57. package/dist/query/core/machine/MachineError.js +19 -0
  58. package/dist/query/core/machine/MachinePending.d.ts +13 -0
  59. package/dist/query/core/machine/MachinePending.js +32 -0
  60. package/dist/query/core/machine/MachineRefreshError.d.ts +12 -0
  61. package/dist/query/core/machine/MachineRefreshError.js +23 -0
  62. package/dist/query/core/machine/MachineRefreshing.d.ts +15 -0
  63. package/dist/query/core/machine/MachineRefreshing.js +43 -0
  64. package/dist/query/core/machine/MachineSuccess.d.ts +12 -0
  65. package/dist/query/core/machine/MachineSuccess.js +23 -0
  66. package/dist/query/core/machine/MachineWithData.d.ts +25 -0
  67. package/dist/query/core/machine/MachineWithData.js +73 -0
  68. package/dist/query/core/machine/index.d.ts +9 -0
  69. package/dist/query/core/machine/index.js +9 -0
  70. package/dist/query/core/machine/machine-helpers.d.ts +9 -0
  71. package/dist/query/core/machine/machine-helpers.js +80 -0
  72. package/dist/query/core/patcher/Patcher.d.ts +30 -0
  73. package/dist/query/core/patcher/Patcher.js +122 -0
  74. package/dist/query/core/patcher/index.d.ts +1 -0
  75. package/dist/query/core/patcher/index.js +1 -0
  76. package/dist/query/core/resource/Resource.d.ts +105 -0
  77. package/dist/query/core/resource/Resource.js +340 -0
  78. package/dist/query/core/resource/ResourceAgent.d.ts +37 -0
  79. package/dist/query/core/resource/ResourceAgent.js +179 -0
  80. package/dist/query/core/resource/index.d.ts +2 -0
  81. package/dist/query/core/resource/index.js +2 -0
  82. package/dist/query/core/snapshoter/Snapshoter.d.ts +22 -0
  83. package/dist/query/core/snapshoter/Snapshoter.js +78 -0
  84. package/dist/query/core/snapshoter/index.d.ts +2 -0
  85. package/dist/query/core/snapshoter/index.js +1 -0
  86. package/dist/query/core/syncer/Syncer.d.ts +32 -0
  87. package/dist/query/core/syncer/Syncer.js +85 -0
  88. package/dist/query/core/syncer/index.d.ts +2 -0
  89. package/dist/query/core/syncer/index.js +1 -0
  90. package/dist/query/index.d.ts +5 -10
  91. package/dist/query/index.js +5 -13
  92. package/dist/query/lib/broadcastSyncDriver.d.ts +5 -0
  93. package/dist/query/lib/broadcastSyncDriver.js +46 -0
  94. package/dist/query/lib/index.d.ts +3 -0
  95. package/dist/query/lib/index.js +3 -0
  96. package/dist/{query-v2 → query}/lib/stableStringify.js +5 -3
  97. package/dist/query/lib/toKeyed.d.ts +11 -0
  98. package/dist/query/lib/toKeyed.js +18 -0
  99. package/dist/query/react/ReactHooksPlugin.d.ts +31 -0
  100. package/dist/query/react/ReactHooksPlugin.js +21 -0
  101. package/dist/query/react/index.d.ts +3 -0
  102. package/dist/query/react/index.js +3 -0
  103. package/dist/query/react/useCommand.d.ts +2 -0
  104. package/dist/query/react/useCommand.js +14 -0
  105. package/dist/query/react/useResource.d.ts +2 -0
  106. package/dist/query/react/useResource.js +16 -0
  107. package/dist/query/types/api.d.ts +39 -0
  108. package/dist/query/types/cache.d.ts +51 -0
  109. package/dist/query/types/command.d.ts +52 -0
  110. package/dist/query/types/common.d.ts +65 -0
  111. package/dist/query/types/index.d.ts +8 -4
  112. package/dist/query/types/index.js +8 -5
  113. package/dist/query/types/plugin-hkt.d.ts +64 -0
  114. package/dist/query/types/resource.d.ts +49 -0
  115. package/dist/query/types/snapshot.d.ts +27 -0
  116. package/dist/query/types/snapshot.js +2 -0
  117. package/dist/query/types/state.d.ts +24 -0
  118. package/dist/signals/base/ComputeCache.js +1 -1
  119. package/dist/signals/base/Devtools.js +2 -6
  120. package/dist/signals/signals/Computed.d.ts +1 -0
  121. package/dist/signals/signals/Computed.js +5 -1
  122. package/dist/signals/signals/Effect.d.ts +0 -4
  123. package/dist/signals/signals/Effect.js +0 -6
  124. package/dist/signals/signals/LocalState.d.ts +1 -10
  125. package/dist/signals/signals/LocalState.js +0 -12
  126. package/dist/signals/signals/Signal.d.ts +2 -8
  127. package/dist/signals/signals/Signal.js +1 -10
  128. package/dist/signals/signals/State.d.ts +2 -1
  129. package/dist/signals/signals/State.js +9 -0
  130. package/dist/signals/types/SignalOptions.d.ts +0 -2
  131. package/dist/signals/types/normalizeSignalOptions.js +0 -3
  132. package/dist/signals/types/signals.types.d.ts +3 -1
  133. package/docs/CHANGELOG.md +54 -2
  134. package/docs/contributing/release/README.md +2 -8
  135. package/docs/migrations/0.6.0.md +224 -0
  136. package/docs/query/README.md +52 -562
  137. package/docs/query/api/README.md +59 -0
  138. package/docs/query/api/_CacheEntry.md +39 -0
  139. package/docs/query/api/_CacheMap.md +30 -0
  140. package/docs/query/api/_QueryCacheEntry.md +81 -0
  141. package/docs/query/api/command-agent.md +60 -0
  142. package/docs/query/api/command.md +76 -0
  143. package/docs/query/api/resource-agent.md +68 -0
  144. package/docs/query/api/resource.md +77 -0
  145. package/docs/query/concepts/agent.md +70 -0
  146. package/docs/query/concepts/architecture.md +139 -0
  147. package/docs/query/concepts/cache.md +81 -0
  148. package/docs/query/concepts/dataflows.md +473 -0
  149. package/docs/query/concepts/keyed.md +42 -0
  150. package/docs/query/concepts/machine.md +106 -0
  151. package/docs/query/concepts/patching.md +85 -0
  152. package/docs/query/usage/broadcast.md +188 -0
  153. package/docs/query/usage/command.md +203 -0
  154. package/docs/query/usage/lifecycle.md +114 -0
  155. package/docs/query/usage/links.md +125 -0
  156. package/docs/query/usage/plugins.md +96 -0
  157. package/docs/query/usage/resource.md +206 -0
  158. package/docs/query/usage/snapshot.md +80 -0
  159. package/docs/usage/react/README.md +45 -91
  160. package/package.json +5 -7
  161. package/dist/query/SKIP_TOKEN.d.ts +0 -1
  162. package/dist/query/SKIP_TOKEN.js +0 -1
  163. package/dist/query/api/createCommand.d.ts +0 -21
  164. package/dist/query/api/createCommand.js +0 -20
  165. package/dist/query/api/createOperation.d.ts +0 -5
  166. package/dist/query/api/createOperation.js +0 -6
  167. package/dist/query/api/createResource.d.ts +0 -3
  168. package/dist/query/api/createResource.js +0 -2
  169. package/dist/query/api/createResourceDuplicator.d.ts +0 -4
  170. package/dist/query/api/createResourceDuplicator.js +0 -2
  171. package/dist/query/api/resetAllQueriesCache.d.ts +0 -1
  172. package/dist/query/api/resetAllQueriesCache.js +0 -4
  173. package/dist/query/core/Command/Command.d.ts +0 -35
  174. package/dist/query/core/Command/Command.js +0 -210
  175. package/dist/query/core/Command/CommandAgent.d.ts +0 -19
  176. package/dist/query/core/Command/CommandAgent.js +0 -54
  177. package/dist/query/core/Command/index.d.ts +0 -2
  178. package/dist/query/core/Command/index.js +0 -2
  179. package/dist/query/core/Operation/Operation.d.ts +0 -8
  180. package/dist/query/core/Operation/Operation.js +0 -4
  181. package/dist/query/core/Operation/OperationAgent.d.ts +0 -4
  182. package/dist/query/core/Operation/OperationAgent.js +0 -4
  183. package/dist/query/core/QueriesCache.d.ts +0 -9
  184. package/dist/query/core/QueriesCache.js +0 -28
  185. package/dist/query/core/QueriesLifetimeHooks.d.ts +0 -22
  186. package/dist/query/core/QueriesLifetimeHooks.js +0 -86
  187. package/dist/query/core/ResetAllQueriesSignal.d.ts +0 -6
  188. package/dist/query/core/ResetAllQueriesSignal.js +0 -11
  189. package/dist/query/core/Resource/Resource.d.ts +0 -51
  190. package/dist/query/core/Resource/Resource.js +0 -232
  191. package/dist/query/core/Resource/ResourceAgent.d.ts +0 -35
  192. package/dist/query/core/Resource/ResourceAgent.js +0 -110
  193. package/dist/query/core/Resource/ResourceDuplicator.d.ts +0 -73
  194. package/dist/query/core/Resource/ResourceDuplicator.js +0 -227
  195. package/dist/query/core/Resource/ResourceDuplicatorAgent.d.ts +0 -35
  196. package/dist/query/core/Resource/ResourceDuplicatorAgent.js +0 -110
  197. package/dist/query/core/Resource/ResourceRef.d.ts +0 -16
  198. package/dist/query/core/Resource/ResourceRef.js +0 -136
  199. package/dist/query/lib/IndirectMap.d.ts +0 -19
  200. package/dist/query/lib/IndirectMap.js +0 -88
  201. package/dist/query/lib/ReactiveCache.d.ts +0 -62
  202. package/dist/query/lib/ReactiveCache.js +0 -80
  203. package/dist/query/react/useCommandAgent.d.ts +0 -24
  204. package/dist/query/react/useCommandAgent.js +0 -39
  205. package/dist/query/react/useOperationAgent.d.ts +0 -6
  206. package/dist/query/react/useOperationAgent.js +0 -6
  207. package/dist/query/react/useResourceAgent.d.ts +0 -6
  208. package/dist/query/react/useResourceAgent.js +0 -31
  209. package/dist/query/react/useResourceRef.d.ts +0 -5
  210. package/dist/query/react/useResourceRef.js +0 -13
  211. package/dist/query/types/Command.types.d.ts +0 -154
  212. package/dist/query/types/Command.types.js +0 -1
  213. package/dist/query/types/Operation.types.d.ts +0 -13
  214. package/dist/query/types/Operation.types.js +0 -1
  215. package/dist/query/types/Resource.types.d.ts +0 -129
  216. package/dist/query/types/Resource.types.js +0 -1
  217. package/dist/query/types/shared.types.d.ts +0 -26
  218. package/dist/query/types/shared.types.js +0 -1
  219. package/dist/query-v2/api/createApi.d.ts +0 -10
  220. package/dist/query-v2/api/createApi.js +0 -83
  221. package/dist/query-v2/core/common/CacheEntry.d.ts +0 -29
  222. package/dist/query-v2/core/common/CacheEntry.js +0 -71
  223. package/dist/query-v2/core/common/CacheMap.d.ts +0 -38
  224. package/dist/query-v2/core/common/CacheMap.js +0 -127
  225. package/dist/query-v2/core/common/LifecycleHooks.d.ts +0 -22
  226. package/dist/query-v2/core/common/LifecycleHooks.js +0 -104
  227. package/dist/query-v2/core/common/index.d.ts +0 -3
  228. package/dist/query-v2/core/common/index.js +0 -3
  229. package/dist/query-v2/core/index.d.ts +0 -3
  230. package/dist/query-v2/core/index.js +0 -3
  231. package/dist/query-v2/core/machines/Machine.d.ts +0 -14
  232. package/dist/query-v2/core/machines/Machine.js +0 -33
  233. package/dist/query-v2/core/machines/MachineError.d.ts +0 -11
  234. package/dist/query-v2/core/machines/MachineError.js +0 -26
  235. package/dist/query-v2/core/machines/MachineIdle.d.ts +0 -8
  236. package/dist/query-v2/core/machines/MachineIdle.js +0 -19
  237. package/dist/query-v2/core/machines/MachinePending.d.ts +0 -12
  238. package/dist/query-v2/core/machines/MachinePending.js +0 -29
  239. package/dist/query-v2/core/machines/MachineRefreshing.d.ts +0 -14
  240. package/dist/query-v2/core/machines/MachineRefreshing.js +0 -46
  241. package/dist/query-v2/core/machines/MachineSuccess.d.ts +0 -16
  242. package/dist/query-v2/core/machines/MachineSuccess.js +0 -42
  243. package/dist/query-v2/core/machines/MachineWithData.d.ts +0 -18
  244. package/dist/query-v2/core/machines/MachineWithData.js +0 -40
  245. package/dist/query-v2/core/machines/Patcher.d.ts +0 -20
  246. package/dist/query-v2/core/machines/Patcher.js +0 -104
  247. package/dist/query-v2/core/machines/index.d.ts +0 -8
  248. package/dist/query-v2/core/machines/index.js +0 -8
  249. package/dist/query-v2/core/resource/ResourceV2.d.ts +0 -120
  250. package/dist/query-v2/core/resource/ResourceV2.js +0 -464
  251. package/dist/query-v2/core/resource/ResourceV2Agent.d.ts +0 -26
  252. package/dist/query-v2/core/resource/ResourceV2Agent.js +0 -132
  253. package/dist/query-v2/core/resource/index.d.ts +0 -2
  254. package/dist/query-v2/core/resource/index.js +0 -2
  255. package/dist/query-v2/index.d.ts +0 -11
  256. package/dist/query-v2/index.js +0 -17
  257. package/dist/query-v2/lib/NO_VALUE.d.ts +0 -2
  258. package/dist/query-v2/lib/NO_VALUE.js +0 -1
  259. package/dist/query-v2/lib/SKIP_TOKEN.d.ts +0 -2
  260. package/dist/query-v2/lib/SKIP_TOKEN.js +0 -1
  261. package/dist/query-v2/lib/index.d.ts +0 -4
  262. package/dist/query-v2/lib/index.js +0 -3
  263. package/dist/query-v2/plugins/ReactHooksPlugin.d.ts +0 -25
  264. package/dist/query-v2/plugins/ReactHooksPlugin.js +0 -19
  265. package/dist/query-v2/plugins/types.d.ts +0 -1
  266. package/dist/query-v2/react/__tests__/helpers.d.ts +0 -12
  267. package/dist/query-v2/react/__tests__/helpers.js +0 -33
  268. package/dist/query-v2/react/index.d.ts +0 -2
  269. package/dist/query-v2/react/index.js +0 -2
  270. package/dist/query-v2/react/useResourceV2Agent.d.ts +0 -12
  271. package/dist/query-v2/react/useResourceV2Agent.js +0 -36
  272. package/dist/query-v2/react/useResourceV2Ref.d.ts +0 -12
  273. package/dist/query-v2/react/useResourceV2Ref.js +0 -57
  274. package/dist/query-v2/snapshot/Snapshot.d.ts +0 -13
  275. package/dist/query-v2/snapshot/Snapshot.js +0 -76
  276. package/dist/query-v2/types/agent.types.d.ts +0 -54
  277. package/dist/query-v2/types/api.types.d.ts +0 -22
  278. package/dist/query-v2/types/cache.types.d.ts +0 -37
  279. package/dist/query-v2/types/index.d.ts +0 -9
  280. package/dist/query-v2/types/index.js +0 -9
  281. package/dist/query-v2/types/lifecycle.types.d.ts +0 -25
  282. package/dist/query-v2/types/machine.types.d.ts +0 -67
  283. package/dist/query-v2/types/plugin.types.d.ts +0 -38
  284. package/dist/query-v2/types/resource.types.d.ts +0 -35
  285. package/dist/query-v2/types/resource.types.js +0 -1
  286. package/dist/query-v2/types/shared.types.d.ts +0 -20
  287. package/dist/query-v2/types/shared.types.js +0 -1
  288. package/dist/query-v2/types/snapshot.types.d.ts +0 -21
  289. package/dist/query-v2/types/snapshot.types.js +0 -1
  290. package/docs/contributing/query-v2/README.md +0 -379
  291. package/docs/migrations/query-v2.md +0 -171
  292. package/docs/query-v2/README.md +0 -280
  293. package/docs/query-v2/api-reference.md +0 -235
  294. package/docs/query-v2/optimistic-updates.md +0 -148
  295. package/docs/query-v2/ssr.md +0 -130
  296. /package/dist/{query-v2 → query}/lib/stableStringify.d.ts +0 -0
  297. /package/dist/{query-v2/plugins/types.js → query/types/api.js} +0 -0
  298. /package/dist/{query-v2/types/agent.types.js → query/types/cache.js} +0 -0
  299. /package/dist/{query-v2/types/api.types.js → query/types/command.js} +0 -0
  300. /package/dist/{query-v2/types/cache.types.js → query/types/common.js} +0 -0
  301. /package/dist/{query-v2/types/lifecycle.types.js → query/types/plugin-hkt.js} +0 -0
  302. /package/dist/{query-v2/types/machine.types.js → query/types/resource.js} +0 -0
  303. /package/dist/{query-v2/types/plugin.types.js → query/types/state.js} +0 -0
@@ -1,25 +0,0 @@
1
- import type { ResourceV2 } from "../../query-v2/core/resource/ResourceV2";
2
- import type { SKIP_TOKEN } from "../../query-v2/lib/SKIP_TOKEN";
3
- import type { IResourceV2AgentState, IResourceV2Ref } from "../../query-v2/types/agent.types";
4
- import type { IPlugin, IPluginContext } from "../../query-v2/types/plugin.types";
5
- import type { IResourceV2Options } from "../../query-v2/types/resource.types";
6
- /** Contributions added by ReactHooksPlugin to resources */
7
- export interface IReactHooksPluginContributions<TArgs, TData, TError = Error> {
8
- useResourceV2Agent(args: TArgs | SKIP_TOKEN): IResourceV2AgentState<TArgs, TData, TError>;
9
- useResourceV2Ref(args: TArgs | SKIP_TOKEN): IResourceV2Ref<TArgs, TData, TError>;
10
- }
11
- declare module "../../query-v2/types/plugin.types" {
12
- interface PluginContributionMap<TArgs, TData, TError> {
13
- ReactHooksPlugin: IReactHooksPluginContributions<TArgs, TData, TError>;
14
- }
15
- }
16
- /**
17
- * Plugin that attaches `useResourceV2Agent` and `useResourceV2Ref` as methods on resources via `augmentResource`.
18
- * Standalone imports from `@/query-v2/react/` are available as an alternative without requiring this plugin.
19
- */
20
- export declare class ReactHooksPlugin implements IPlugin {
21
- readonly name: "ReactHooksPlugin";
22
- private _context;
23
- install(context: IPluginContext): void;
24
- augmentResource<TArgs, TData, TError>(res: ResourceV2<TArgs, TData, TError>, _options: IResourceV2Options<TArgs, TData, TError>): Record<string, unknown>;
25
- }
@@ -1,19 +0,0 @@
1
- import { useResourceV2Agent } from "../../query-v2/react/useResourceV2Agent";
2
- import { useResourceV2Ref } from "../../query-v2/react/useResourceV2Ref";
3
- /**
4
- * Plugin that attaches `useResourceV2Agent` and `useResourceV2Ref` as methods on resources via `augmentResource`.
5
- * Standalone imports from `@/query-v2/react/` are available as an alternative without requiring this plugin.
6
- */
7
- export class ReactHooksPlugin {
8
- name = "ReactHooksPlugin";
9
- _context = null;
10
- install(context) {
11
- this._context = context;
12
- }
13
- augmentResource(res, _options) {
14
- return {
15
- useResourceV2Agent: (args) => useResourceV2Agent(res, args),
16
- useResourceV2Ref: (args) => useResourceV2Ref(res, args),
17
- };
18
- }
19
- }
@@ -1 +0,0 @@
1
- export type { IPlugin, IPluginContext, ExtractPluginContributions, PluginAugmentations, } from "../../query-v2/types/plugin.types";
@@ -1,12 +0,0 @@
1
- import { ResourceV2, type ResourceV2Config } from "../../../query-v2/core/resource/ResourceV2";
2
- export declare function controllableQueryFn<TArgs = unknown, TData = unknown>(): {
3
- fn: import("vitest").Mock<(args: TArgs, { abortSignal }: {
4
- abortSignal: AbortSignal;
5
- }) => Promise<TData>>;
6
- calls: {
7
- args: TArgs;
8
- resolve: (data: TData) => void;
9
- reject: (error: Error) => void;
10
- }[];
11
- };
12
- export declare function createTestResource<TArgs = unknown, TData = unknown, TError = Error>(config: Partial<ResourceV2Config<TArgs, TData, TError>> & Pick<ResourceV2Config<TArgs, TData, TError>, "queryFn">): ResourceV2<TArgs, TData, TError>;
@@ -1,33 +0,0 @@
1
- import { vi } from "vitest";
2
- import { ResourceV2 } from "../../../query-v2/core/resource/ResourceV2";
3
- export function controllableQueryFn() {
4
- const calls = [];
5
- const fn = vi.fn((args, { abortSignal }) => {
6
- return new Promise((resolve, reject) => {
7
- let settled = false;
8
- const wrappedResolve = (data) => {
9
- if (!settled) {
10
- settled = true;
11
- resolve(data);
12
- }
13
- };
14
- const wrappedReject = (error) => {
15
- if (!settled) {
16
- settled = true;
17
- reject(error);
18
- }
19
- };
20
- calls.push({ args, resolve: wrappedResolve, reject: wrappedReject });
21
- abortSignal.addEventListener("abort", () => {
22
- wrappedReject(new DOMException("Aborted", "AbortError"));
23
- });
24
- });
25
- });
26
- return { fn, calls };
27
- }
28
- export function createTestResource(config) {
29
- return new ResourceV2({
30
- key: "test-resource",
31
- ...config,
32
- });
33
- }
@@ -1,2 +0,0 @@
1
- export { useResourceV2Agent } from "./useResourceV2Agent";
2
- export { useResourceV2Ref } from "./useResourceV2Ref";
@@ -1,2 +0,0 @@
1
- export { useResourceV2Agent } from "./useResourceV2Agent";
2
- export { useResourceV2Ref } from "./useResourceV2Ref";
@@ -1,12 +0,0 @@
1
- import type { ResourceV2 } from "../../query-v2/core/resource/ResourceV2";
2
- import { type SKIP_TOKEN } from "../../query-v2/lib/SKIP_TOKEN";
3
- import type { IResourceV2AgentState } from "../../query-v2/types/agent.types";
4
- /**
5
- * React hook that creates a ResourceV2Agent and returns its reactive state (SWR).
6
- *
7
- * @param resource - The resource to observe.
8
- * @param args - Query arguments, or `SKIP_TOKEN` to skip the query.
9
- * @returns Reactive agent state with `data`, `error`, status flags, etc.
10
- * @see docs/query-v2/README.md
11
- */
12
- export declare function useResourceV2Agent<TArgs, TData, TError>(resource: ResourceV2<TArgs, TData, TError>, args: TArgs | SKIP_TOKEN): IResourceV2AgentState<TArgs, TData, TError>;
@@ -1,36 +0,0 @@
1
- import React from "react";
2
- import { useConstant } from "../../common/react/useConstant";
3
- import { SKIP } from "../../query-v2/lib/SKIP_TOKEN";
4
- import { useSignal } from "../../signals/react/useSignal";
5
- /**
6
- * React hook that creates a ResourceV2Agent and returns its reactive state (SWR).
7
- *
8
- * @param resource - The resource to observe.
9
- * @param args - Query arguments, or `SKIP_TOKEN` to skip the query.
10
- * @returns Reactive agent state with `data`, `error`, status flags, etc.
11
- * @see docs/query-v2/README.md
12
- */
13
- export function useResourceV2Agent(resource, args) {
14
- const prevArgsRef = React.useRef(SKIP);
15
- const agent = useConstant(() => {
16
- const agent = resource.createAgent();
17
- if (args !== SKIP) {
18
- agent.start(args);
19
- }
20
- return agent;
21
- });
22
- if (!compareArgs(args, prevArgsRef.current, resource)) {
23
- prevArgsRef.current = args;
24
- if (args !== SKIP) {
25
- agent.start(args);
26
- }
27
- }
28
- return useSignal(agent.state$);
29
- }
30
- function compareArgs(args, prevArgs, resource) {
31
- if (args === SKIP && prevArgs === SKIP)
32
- return true;
33
- if (args === SKIP || prevArgs === SKIP)
34
- return false;
35
- return resource.compareArgs(args, prevArgs);
36
- }
@@ -1,12 +0,0 @@
1
- import type { ResourceV2 } from "../../query-v2/core/resource/ResourceV2";
2
- import { type SKIP_TOKEN } from "../../query-v2/lib/SKIP_TOKEN";
3
- import type { IResourceV2Ref } from "../../query-v2/types/agent.types";
4
- /**
5
- * React hook that provides an imperative ref handle for a cache entry (lock, invalidate, patch, create).
6
- *
7
- * @param resource - The resource to access.
8
- * @param args - Query arguments, or `SKIP_TOKEN` to return a no-op ref.
9
- * @returns Imperative ref with `has`, `lock`, `invalidate`, `createPatch`, `create`.
10
- * @see docs/query-v2/optimistic-updates.md
11
- */
12
- export declare function useResourceV2Ref<TArgs, TData, TError>(resource: ResourceV2<TArgs, TData, TError>, args: TArgs | SKIP_TOKEN): IResourceV2Ref<TArgs, TData, TError>;
@@ -1,57 +0,0 @@
1
- import React from "react";
2
- import { shallowEqual } from "../../common/utils/shallowEqual";
3
- import { SKIP } from "../../query-v2/lib/SKIP_TOKEN";
4
- /**
5
- * React hook that provides an imperative ref handle for a cache entry (lock, invalidate, patch, create).
6
- *
7
- * @param resource - The resource to access.
8
- * @param args - Query arguments, or `SKIP_TOKEN` to return a no-op ref.
9
- * @returns Imperative ref with `has`, `lock`, `invalidate`, `createPatch`, `create`.
10
- * @see docs/query-v2/optimistic-updates.md
11
- */
12
- export function useResourceV2Ref(resource, args) {
13
- const stableArgsRef = React.useRef(args);
14
- if (!shallowEqual(stableArgsRef.current, args)) {
15
- stableArgsRef.current = args;
16
- }
17
- return React.useMemo(() => {
18
- if (stableArgsRef.current === SKIP) {
19
- return createSkippedRef();
20
- }
21
- return createRefHandle(resource, stableArgsRef.current);
22
- }, [stableArgsRef.current]);
23
- }
24
- function createRefHandle(resource, args) {
25
- return {
26
- get has() {
27
- return resource.hasEntry(args);
28
- },
29
- lock() {
30
- return resource.lockEntry(args);
31
- },
32
- invalidate() {
33
- resource.invalidate(args);
34
- },
35
- createPatch(patchFn) {
36
- return resource.createEntryPatch(args, patchFn);
37
- },
38
- create(data) {
39
- resource.populateEntry(args, data);
40
- },
41
- };
42
- }
43
- function createSkippedRef() {
44
- return {
45
- get has() {
46
- return false;
47
- },
48
- lock() {
49
- return { unlock: () => { } };
50
- },
51
- invalidate() { },
52
- createPatch() {
53
- return null;
54
- },
55
- create() { },
56
- };
57
- }
@@ -1,13 +0,0 @@
1
- import type { ResourceV2 } from "../../query-v2/core/resource/ResourceV2";
2
- import type { TApiSnapshot } from "../../query-v2/types/snapshot.types";
3
- export declare const CURRENT_SNAPSHOT_VERSION = 1;
4
- /**
5
- * Capture snapshot from all registered resources.
6
- * Only `MachineSuccess` entries are included (per design §5).
7
- */
8
- export declare function getSnapshot(resources: Map<string, ResourceV2<any, any, any>>, keyPrefix: string | null, keyStrategy: "serialize" | "compare"): TApiSnapshot;
9
- /**
10
- * Hydrate resources from a snapshot.
11
- * Validates version and keyPrefix before applying.
12
- */
13
- export declare function hydrateSnapshot(snapshot: TApiSnapshot, resources: Map<string, ResourceV2<any, any, any>>, apiKeyPrefix: string | null, maxSnapshotDataAge: number): void;
@@ -1,76 +0,0 @@
1
- import { Machine } from "../../query-v2/core/machines/Machine";
2
- import { MachineSuccess } from "../../query-v2/core/machines/MachineSuccess";
3
- export const CURRENT_SNAPSHOT_VERSION = 1;
4
- /**
5
- * Capture snapshot from all registered resources.
6
- * Only `MachineSuccess` entries are included (per design §5).
7
- */
8
- export function getSnapshot(resources, keyPrefix, keyStrategy) {
9
- if (keyStrategy === "compare") {
10
- throw new Error('getSnapshot() is not supported with keyStrategy "compare". ' +
11
- 'SSR snapshots require keyStrategy "serialize" so that cache keys are serializable strings.');
12
- }
13
- const resourceSnapshots = {};
14
- for (const [resourceKey, resource] of resources) {
15
- const entries = {};
16
- let hasEntries = false;
17
- for (const [key, cacheEntry] of resource.cacheEntries()) {
18
- const machine = cacheEntry.peek();
19
- if (!(machine instanceof MachineSuccess))
20
- continue;
21
- const state = machine.state;
22
- entries[key] = {
23
- status: "success",
24
- args: state.args,
25
- data: state.data,
26
- updatedAt: state.updatedAt,
27
- };
28
- hasEntries = true;
29
- }
30
- if (hasEntries) {
31
- resourceSnapshots[resourceKey] = { entries };
32
- }
33
- }
34
- return {
35
- version: CURRENT_SNAPSHOT_VERSION,
36
- keyPrefix,
37
- resources: resourceSnapshots,
38
- };
39
- }
40
- /**
41
- * Hydrate resources from a snapshot.
42
- * Validates version and keyPrefix before applying.
43
- */
44
- export function hydrateSnapshot(snapshot, resources, apiKeyPrefix, maxSnapshotDataAge) {
45
- // Fatal: snapshot format incompatibility — the serialization schema has changed between versions.
46
- // This cannot be recovered from; the snapshot must be regenerated.
47
- if (snapshot.version !== CURRENT_SNAPSHOT_VERSION) {
48
- throw new Error(`Snapshot version mismatch: expected ${CURRENT_SNAPSHOT_VERSION}, got ${snapshot.version}. ` +
49
- `The snapshot format is incompatible with the current version of query-v2.`);
50
- }
51
- // Fatal: wrong API instance — the snapshot was created by a different keyPrefix configuration.
52
- // Applying it would pollute the cache with data from an unrelated API.
53
- if (snapshot.keyPrefix !== apiKeyPrefix) {
54
- throw new Error(`Snapshot keyPrefix mismatch: expected "${apiKeyPrefix}", got "${snapshot.keyPrefix}". ` +
55
- `Ensure the snapshot was created by the same API instance configuration.`);
56
- }
57
- const now = Date.now();
58
- for (const [resourceKey, resourceSnapshot] of Object.entries(snapshot.resources)) {
59
- const resource = resources.get(resourceKey);
60
- if (!resource) {
61
- // Non-fatal: a resource may have been removed between versions — skip gracefully.
62
- console.warn(`[rx-toolkit] hydrateSnapshot: unknown resource key "${resourceKey}", skipping.`);
63
- continue;
64
- }
65
- for (const [, slice] of Object.entries(resourceSnapshot.entries)) {
66
- const machine = Machine.fromSnapshot(slice);
67
- // Reconstruct args from the slice
68
- const args = slice.args;
69
- resource.hydrateEntry(args, machine);
70
- // S3: stale entries trigger invalidation
71
- if (now - slice.updatedAt > maxSnapshotDataAge) {
72
- resource.invalidate(args);
73
- }
74
- }
75
- }
76
- }
@@ -1,54 +0,0 @@
1
- import type { TMachineStatus, TPatchFn } from "./machine.types";
2
- /** SKIP_TOKEN type alias for agent args */
3
- type SKIP_TOKEN = typeof import("../lib/SKIP_TOKEN").SKIP;
4
- /** Agent — observer with stale-while-revalidate */
5
- export interface IResourceV2Agent<TArgs, TData, TError = Error> {
6
- /** Reactive state (computed signal) */
7
- readonly state$: () => IResourceV2AgentState<TArgs, TData, TError>;
8
- /** Start query with new args (returns promise) */
9
- start(args: TArgs | SKIP_TOKEN): Promise<void>;
10
- /** Compare previous and new args */
11
- compareArgs(a: TArgs, b: TArgs): boolean;
12
- }
13
- /** Agent's computed state shape */
14
- export interface IResourceV2AgentState<TArgs, TData, TError = Error> {
15
- /** Current machine status */
16
- status: TMachineStatus;
17
- /** Current data (may be stale during loading) */
18
- data: TData | null;
19
- /** Current error */
20
- error: TError | null;
21
- /** Current args (fresh) */
22
- args: TArgs | null;
23
- /** Loading indicator */
24
- isLoading: boolean;
25
- /** True only on first load (no previous data) */
26
- isInitialLoading: boolean;
27
- /** True when refreshing existing data */
28
- isRefreshing: boolean;
29
- /** True when data is available */
30
- isSuccess: boolean;
31
- /** True when in error state */
32
- isError: boolean;
33
- /** Error from a failed background refresh (stale data preserved) */
34
- refreshError: TError | null;
35
- }
36
- /** Ref — imperative access to a specific cache entry by args */
37
- export interface IResourceV2Ref<_TArgs, TData, _TError = Error> {
38
- /** Check if cache entry exists */
39
- readonly has: boolean;
40
- /** Lock cache entry (prevent eviction) */
41
- lock(): {
42
- unlock: () => void;
43
- };
44
- /** Invalidate (force re-fetch) */
45
- invalidate(): void;
46
- /** Create optimistic patch */
47
- createPatch(patchFn: TPatchFn<TData>): {
48
- commit: () => void;
49
- abort: () => void;
50
- } | null;
51
- /** Pre-populate cache with data */
52
- create(data: TData): void;
53
- }
54
- export {};
@@ -1,22 +0,0 @@
1
- import type { IPlugin, PluginAugmentations } from "./plugin.types";
2
- import type { IResourceV2, IResourceV2Options } from "./resource.types";
3
- import type { TCompareArgsFn, TSerializeArgsFn } from "./shared.types";
4
- import type { TApiSnapshot } from "./snapshot.types";
5
- /** Options for createApi factory */
6
- export interface ICreateApiOptions<TPlugins extends IPlugin[] = []> {
7
- keyPrefix?: string | null;
8
- keyStrategy?: "serialize" | "compare";
9
- serializeArgs?: TSerializeArgsFn;
10
- compareArg?: TCompareArgsFn;
11
- initialSnapshot?: TApiSnapshot | null;
12
- cacheLifetime?: number;
13
- plugins?: TPlugins;
14
- maxSnapshotDataAge?: number;
15
- doCacheArgs?: boolean;
16
- }
17
- /** API instance returned by createApi */
18
- export interface IApi<TPlugins extends IPlugin[] = []> {
19
- createResource<TArgs, TData, TError = Error>(options: IResourceV2Options<TArgs, TData, TError>): IResourceV2<TArgs, TData, TError> & PluginAugmentations<TPlugins, TArgs, TData, TError>;
20
- resetAll(): void;
21
- getSnapshot(): TApiSnapshot;
22
- }
@@ -1,37 +0,0 @@
1
- import type { IMachineBox } from "./machine.types";
2
- import type { TCompareArgsFn, TSerializeArgsFn } from "./shared.types";
3
- /** Single reactive cache unit holding a Machine */
4
- export interface ICacheEntry<TData, TError = Error> {
5
- /** Reactive signal holding current machine state */
6
- readonly machine$: () => IMachineBox<TData, TError>;
7
- /** Synchronous peek at current machine */
8
- peek(): IMachineBox<TData, TError>;
9
- /** Update machine state */
10
- set(machine: IMachineBox<TData, TError>): void;
11
- /** Cleanup — complete and release */
12
- complete(): void;
13
- /** Observable for cache lifetime management */
14
- readonly onClean$: {
15
- subscribe(cb: () => void): {
16
- unsubscribe(): void;
17
- };
18
- };
19
- }
20
- /** Dual-strategy cache abstraction */
21
- export interface ICacheMap<TArgs, TData, TError = Error> {
22
- get(args: TArgs): ICacheEntry<TData, TError> | undefined;
23
- set(args: TArgs, entry: ICacheEntry<TData, TError>): void;
24
- delete(args: TArgs): boolean;
25
- has(args: TArgs): boolean;
26
- values(): Iterable<ICacheEntry<TData, TError>>;
27
- entries(): Iterable<[TArgs | string, ICacheEntry<TData, TError>]>;
28
- clear(): void;
29
- readonly size: number;
30
- }
31
- /** Factory options for creating appropriate cache map */
32
- export interface ICacheMapOptions<_TArgs> {
33
- keyStrategy: "serialize" | "compare";
34
- serializeArgs: TSerializeArgsFn;
35
- compareArg: TCompareArgsFn;
36
- doCacheArgs: boolean;
37
- }
@@ -1,9 +0,0 @@
1
- export * from "./shared.types";
2
- export * from "./machine.types";
3
- export * from "./cache.types";
4
- export * from "./resource.types";
5
- export * from "./agent.types";
6
- export * from "./api.types";
7
- export * from "./plugin.types";
8
- export * from "./snapshot.types";
9
- export * from "./lifecycle.types";
@@ -1,9 +0,0 @@
1
- export * from "./shared.types";
2
- export * from "./machine.types";
3
- export * from "./cache.types";
4
- export * from "./resource.types";
5
- export * from "./agent.types";
6
- export * from "./api.types";
7
- export * from "./plugin.types";
8
- export * from "./snapshot.types";
9
- export * from "./lifecycle.types";
@@ -1,25 +0,0 @@
1
- import type { ICacheEntry } from "./cache.types";
2
- import type { TMachine } from "./machine.types";
3
- /** Tools provided to onCacheEntryAdded */
4
- export interface TCacheEntryAddedTools<TData> {
5
- /** Resolves when first MachineSuccess is set */
6
- $cacheDataLoaded: Promise<TData>;
7
- /** Resolves when cache entry is removed */
8
- $cacheEntryRemoved: Promise<void>;
9
- /** Get current machine state */
10
- getCacheEntry(): TMachine<TData, any>;
11
- }
12
- /** onCacheEntryAdded callback type */
13
- export type TOnCacheEntryAdded<TArgs, TData> = (args: TArgs, tools: TCacheEntryAddedTools<TData>) => void | Promise<void>;
14
- /** Tools provided to onQueryStarted */
15
- export interface TQueryStartedTools<TData> {
16
- /** Resolves/rejects when query completes */
17
- $queryFulfilled: Promise<{
18
- data: TData;
19
- isError: false;
20
- }>;
21
- /** Get current cache entry for patching */
22
- getCacheEntry(): ICacheEntry<TData, any>;
23
- }
24
- /** onQueryStarted callback type */
25
- export type TOnQueryStarted<TArgs, TData> = (args: TArgs, tools: TQueryStartedTools<TData>) => void | Promise<void>;
@@ -1,67 +0,0 @@
1
- import type { NO_VALUE } from "./shared.types";
2
- /** Discriminated union of all machine statuses */
3
- export type TMachineStatus = "idle" | "pending" | "success" | "error" | "refreshing";
4
- /** Idle state — initial, no data */
5
- export interface TResourceV2IdleState {
6
- status: "idle";
7
- args: null;
8
- data: null;
9
- error: null;
10
- updatedAt: null;
11
- }
12
- /** Pending state — query in progress, no data yet */
13
- export interface TResourceV2PendingState<TData = unknown> {
14
- status: "pending";
15
- args: unknown;
16
- data: null;
17
- error: null;
18
- updatedAt: null;
19
- originalData: TData | NO_VALUE;
20
- }
21
- /** Success state — data loaded successfully */
22
- export interface TResourceV2SuccessState<TData = unknown> {
23
- status: "success";
24
- args: unknown;
25
- data: TData;
26
- error: null;
27
- updatedAt: number;
28
- originalData: TData | NO_VALUE;
29
- patches: TResourceV2Patch[] | null;
30
- }
31
- /** Error state — query failed */
32
- export interface TResourceV2ErrorState<TError = Error> {
33
- status: "error";
34
- args: unknown;
35
- data: null;
36
- error: TError;
37
- updatedAt: null;
38
- }
39
- /** Refreshing state — re-fetching while holding stale data */
40
- export interface TResourceV2RefreshingState<TData = unknown> {
41
- status: "refreshing";
42
- args: unknown;
43
- data: TData;
44
- error: null;
45
- updatedAt: number;
46
- originalData: TData | NO_VALUE;
47
- patches: TResourceV2Patch[] | null;
48
- }
49
- /** Patch record in the queue (Immer-based) */
50
- export interface TResourceV2Patch {
51
- patches: unknown[];
52
- inversePatches: unknown[];
53
- status: "pending" | "committed" | "aborted";
54
- }
55
- /** Patch function (Immer recipe) */
56
- export type TPatchFn<TData> = (draft: TData) => void;
57
- /**
58
- * Discriminated union of all machine states (flat state shapes).
59
- */
60
- export type TMachine<TData, TError = Error> = TResourceV2IdleState | TResourceV2PendingState<TData> | TResourceV2SuccessState<TData> | TResourceV2ErrorState<TError> | TResourceV2RefreshingState<TData>;
61
- /**
62
- * Boxed machine — structural type matching runtime machine class instances.
63
- * Each machine class wraps its flat state in a `readonly state` property.
64
- */
65
- export interface IMachineBox<TData = unknown, TError = Error> {
66
- readonly state: TMachine<TData, TError>;
67
- }
@@ -1,38 +0,0 @@
1
- import type { ResourceV2 } from "../../query-v2";
2
- import type { IApi } from "./api.types";
3
- import type { IResourceV2Options } from "./resource.types";
4
- import type { Prettify } from "./shared.types";
5
- /** Plugin interface — all plugins must implement this */
6
- export interface IPlugin {
7
- /** Unique plugin name */
8
- readonly name: string;
9
- /** Called once when createApi installs the plugin */
10
- install(context: IPluginContext): void;
11
- /** Called for each createResource — returns augmented resource */
12
- augmentResource<TArgs, TData, TError>(resource: ResourceV2<TArgs, TData, TError>, options: IResourceV2Options<TArgs, TData, TError>): Record<string, unknown>;
13
- }
14
- /** Context provided to plugins during install */
15
- export interface IPluginContext {
16
- /** The API instance */
17
- readonly api: IApi<any>;
18
- /** Key strategy for this API */
19
- readonly keyStrategy: "serialize" | "compare";
20
- }
21
- /** Helper: converts a union to an intersection */
22
- type UnionToIntersection<U> = (U extends any ? (x: U) => void : never) extends (x: infer I) => void ? I : never;
23
- /**
24
- * Extract plugin contributions from a single plugin.
25
- * Each plugin extends PluginContributionMap via declaration merging.
26
- * The name property is used as the key lookup.
27
- */
28
- export interface PluginContributionMap<TArgs, TData, TError> {
29
- }
30
- export type ExtractPluginContributions<P extends IPlugin, TArgs, TData, TError> = P extends {
31
- name: infer N;
32
- } ? N extends keyof PluginContributionMap<TArgs, TData, TError> ? PluginContributionMap<TArgs, TData, TError>[N] : object : object;
33
- /**
34
- * Type-level utility: extracts and merges augmentations from a plugin tuple.
35
- * Uses UnionToIntersection + Prettify as per ADR-1.
36
- */
37
- export type PluginAugmentations<TPlugins extends IPlugin[], TArgs, TData, TError> = TPlugins extends [] ? object : Prettify<UnionToIntersection<TPlugins[number] extends infer P ? P extends IPlugin ? ExtractPluginContributions<P, TArgs, TData, TError> : never : never>>;
38
- export {};
@@ -1,35 +0,0 @@
1
- import type { IResourceV2Agent } from "./agent.types";
2
- import type { ICacheEntry } from "./cache.types";
3
- import type { TOnCacheEntryAdded, TOnQueryStarted } from "./lifecycle.types";
4
- import type { TMachine } from "./machine.types";
5
- import type { TBeforeDevtoolsPushFn, TCompareArgsFn, TQueryFn, TSerializeArgsFn } from "./shared.types";
6
- /** Options for api.createResource */
7
- export interface IResourceV2Options<TArgs, TData, TError = Error> {
8
- key?: string;
9
- queryFn: TQueryFn<TArgs, TData>;
10
- onCacheEntryAdded?: TOnCacheEntryAdded<TArgs, TData>;
11
- onQueryStarted?: TOnQueryStarted<TArgs, TData>;
12
- serializeArgs?: TSerializeArgsFn;
13
- compareArg?: TCompareArgsFn;
14
- cacheLifetime?: number;
15
- beforeDevtoolsPush?: TBeforeDevtoolsPushFn<TMachine<TData, TError>>;
16
- maxSnapshotDataAge?: number;
17
- doCacheArgs?: boolean;
18
- }
19
- /** ResourceV2 instance (public API) */
20
- export interface IResourceV2<TArgs, TData, TError = Error> {
21
- /** Create an agent (observer with SWR) */
22
- createAgent(): IResourceV2Agent<TArgs, TData, TError>;
23
- /** Execute query, returns promise of cache entry */
24
- query(args: TArgs, doForce?: boolean): Promise<ICacheEntry<TData, TError>>;
25
- /** Reactive query — returns current machine state as signal read */
26
- query$(args: TArgs, doForce?: boolean): TMachine<TData, TError>;
27
- /** Get raw cache entry (non-reactive) */
28
- entry(args: TArgs, doInitiate?: boolean): ICacheEntry<TData, TError> | null;
29
- /** Get cache entry signal (reactive) */
30
- entry$(args: TArgs, doInitiate?: boolean): TMachine<TData, TError>;
31
- /** Force re-fetch for given args */
32
- invalidate(args: TArgs): void;
33
- /** Compare two args values */
34
- compareArgs(a: TArgs, b: TArgs): boolean;
35
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,20 +0,0 @@
1
- export type Prettify<T> = {
2
- [KeyType in keyof T]: T[KeyType];
3
- } & {};
4
- /** Serialize args to string cache key */
5
- export type TSerializeArgsFn = (args: unknown) => string;
6
- /** Compare two args for equality (used in 'compare' strategy) */
7
- export type TCompareArgsFn = (a: unknown, b: unknown) => boolean;
8
- /**
9
- * Intercepts machine state before pushing to Redux DevTools.
10
- * Default behavior: push machine.state (plain object).
11
- * User can transform or filter.
12
- */
13
- export type TBeforeDevtoolsPushFn<TMachineState> = (newValue: TMachineState, push: (value: TMachineState) => void) => void;
14
- /** Query function signature */
15
- export type TQueryFn<TArgs, TData> = (args: TArgs, tools: TQueryFnTools) => Promise<TData>;
16
- export interface TQueryFnTools {
17
- abortSignal: AbortSignal;
18
- }
19
- /** NO_VALUE type alias — the runtime value lives in lib/NO_VALUE.ts */
20
- export type NO_VALUE = typeof import("../lib/NO_VALUE").NO_VALUE;
@@ -1 +0,0 @@
1
- export {};