(
self: { id: string; options?: ClientForOptions; disableQueryInvalidation?: boolean },
queryInvalidation: MutationOptionsBase["queryInvalidation"] | undefined,
queryInvalidator: QueryInvalidator<RInvalidator>
)
| 263 | }) |
| 264 | ) |
| 265 | ) |
| 266 | ) |
| 267 | ) |
| 268 | |
| 269 | const act = (...args: Args) => runStream(handler(...args)) |
| 270 | |
| 271 | return tuple(computed(() => state.value), act) |
| 272 | } |
| 273 | |
| 274 | const buildInvalidateCache = <RInvalidator>( |
| 275 | self: { id: string; options?: ClientForOptions; disableQueryInvalidation?: boolean }, |
| 276 | queryInvalidation: MutationOptionsBase["queryInvalidation"] | undefined, |
| 277 | queryInvalidator: QueryInvalidator<RInvalidator> |
| 278 | ) => { |
| 279 | // Concrete reactivity keys to invalidate: a raw query key, one derived from an `{ id }` |
| 280 | // entry, or a compatibility `{ filters: { queryKey } }` entry. |
| 281 | // Predicate-only `{ filters }` entries have no exact-key reactivity equivalent and throw. |
| 282 | const getClientInvalidationKeys = ( |
| 283 | input: unknown, |
| 284 | output: Exit.Exit<unknown, unknown> |
| 285 | ): ReadonlyArray<ReadonlyArray<unknown>> => { |
| 286 | const queryKey = getQueryKey(self) |
| 287 | |
| 288 | if (queryInvalidation) { |
| 289 | const keys: Array<ReadonlyArray<unknown>> = [] |
| 290 | for (const entry of queryInvalidation(queryKey, self.id, input, output)) { |
| 291 | if (isQueryKey(entry)) { |
| 292 | keys.push(entry) |
| 293 | continue |
| 294 | } |
| 295 | if ("id" in entry) { |
| 296 | keys.push(makeQueryKey(entry.options ? { id: entry.id, options: entry.options } : { id: entry.id })) |
| 297 | continue |
| 298 | } |
| 299 | const filterQueryKey = queryKeyFromFilters(entry) |
| 300 | if (filterQueryKey !== undefined) { |
| 301 | keys.push(filterQueryKey) |
| 302 | continue |
| 303 | } |
| 304 | throw new Error("Unsupported query invalidation filter: only filters.queryKey is supported") |
| 305 | } |
| 306 | return keys |
| 307 | } |
| 308 | |
| 309 | // No manual `invalidatesQueries`: contribute nothing. Invalidation rides entirely on the |
| 310 | // repository-derived write-dependencies (plus any server-provided keys) — there is no default |
| 311 | // namespace invalidation of the command's own resource. |
| 312 | return [] |
| 313 | } |
| 314 | |
| 315 | const invalidateCache = ( |
| 316 | input: unknown, |
| 317 | output: Exit.Exit<unknown, unknown>, |
| 318 | serverKeys: ReadonlyArray<InvalidationKey>, |
| 319 | writeDependencies: DataDependencies.DataDependencies = DataDependencies.empty() |
| 320 | ) => |
| 321 | Effect.suspend(() => { |
| 322 | if (self.disableQueryInvalidation) return Effect.void |
no outgoing calls
no test coverage detected
searching dependent graphs…