@spoosh/plugin-invalidation 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -30,7 +30,7 @@ When a mutation succeeds, related queries are automatically invalidated:
30
30
 
31
31
  ```typescript
32
32
  // Creating a post at users/123/posts invalidates:
33
- const { trigger } = useWrite((api) => api("users/:id/posts").POST);
33
+ const { trigger } = useWrite((api) => api("users/:id/posts").POST());
34
34
  await trigger({ params: { id: 123 }, body: { title: "New Post" } });
35
35
 
36
36
  // ✓ Invalidates: "users", "users/123", "users/123/posts"
@@ -45,7 +45,7 @@ import { invalidationPlugin } from "@spoosh/plugin-invalidation";
45
45
 
46
46
  const spoosh = new Spoosh<ApiSchema, Error>("/api").use([invalidationPlugin()]);
47
47
 
48
- const { trigger } = useWrite((api) => api("posts").POST);
48
+ const { trigger } = useWrite((api) => api("posts").POST());
49
49
  await trigger({ body: { title: "New Post" } });
50
50
  ```
51
51
 
@@ -205,7 +205,7 @@ socket.on("full-sync", () => {
205
205
  For scenarios like logout or user switching, combine `invalidate: "*"` with `clearCache` from `@spoosh/plugin-cache`:
206
206
 
207
207
  ```typescript
208
- const { trigger } = useWrite((api) => api("auth/logout").POST);
208
+ const { trigger } = useWrite((api) => api("auth/logout").POST());
209
209
 
210
210
  // Clear cache + trigger all queries to refetch
211
211
  await trigger({
package/dist/index.d.mts CHANGED
@@ -23,7 +23,8 @@ interface InvalidationPluginConfig {
23
23
  */
24
24
  defaultMode?: InvalidationMode;
25
25
  }
26
- interface InvalidationWriteOptions<TSchema = unknown> {
26
+ type InvalidationWriteOptions = object;
27
+ interface InvalidationWriteTriggerOptions<TSchema = unknown> {
27
28
  /** Unified invalidation configuration */
28
29
  invalidate?: InvalidateOption<TSchema>;
29
30
  }
@@ -103,10 +104,11 @@ declare module "@spoosh/core" {
103
104
  declare function invalidationPlugin(config?: InvalidationPluginConfig): SpooshPlugin<{
104
105
  readOptions: InvalidationReadOptions;
105
106
  writeOptions: InvalidationWriteOptions;
107
+ writeTriggerOptions: InvalidationWriteTriggerOptions;
106
108
  infiniteReadOptions: InvalidationInfiniteReadOptions;
107
109
  readResult: InvalidationReadResult;
108
110
  writeResult: InvalidationWriteResult;
109
111
  instanceApi: InvalidationInstanceApi;
110
112
  }>;
111
113
 
112
- export { type InvalidateOption, type InvalidationInfiniteReadOptions, type InvalidationMode, type InvalidationPluginConfig, type InvalidationPluginExports, type InvalidationReadOptions, type InvalidationReadResult, type InvalidationWriteOptions, type InvalidationWriteResult, invalidationPlugin };
114
+ export { type InvalidateOption, type InvalidationInfiniteReadOptions, type InvalidationMode, type InvalidationPluginConfig, type InvalidationPluginExports, type InvalidationReadOptions, type InvalidationReadResult, type InvalidationWriteOptions, type InvalidationWriteResult, type InvalidationWriteTriggerOptions, invalidationPlugin };
package/dist/index.d.ts CHANGED
@@ -23,7 +23,8 @@ interface InvalidationPluginConfig {
23
23
  */
24
24
  defaultMode?: InvalidationMode;
25
25
  }
26
- interface InvalidationWriteOptions<TSchema = unknown> {
26
+ type InvalidationWriteOptions = object;
27
+ interface InvalidationWriteTriggerOptions<TSchema = unknown> {
27
28
  /** Unified invalidation configuration */
28
29
  invalidate?: InvalidateOption<TSchema>;
29
30
  }
@@ -103,10 +104,11 @@ declare module "@spoosh/core" {
103
104
  declare function invalidationPlugin(config?: InvalidationPluginConfig): SpooshPlugin<{
104
105
  readOptions: InvalidationReadOptions;
105
106
  writeOptions: InvalidationWriteOptions;
107
+ writeTriggerOptions: InvalidationWriteTriggerOptions;
106
108
  infiniteReadOptions: InvalidationInfiniteReadOptions;
107
109
  readResult: InvalidationReadResult;
108
110
  writeResult: InvalidationWriteResult;
109
111
  instanceApi: InvalidationInstanceApi;
110
112
  }>;
111
113
 
112
- export { type InvalidateOption, type InvalidationInfiniteReadOptions, type InvalidationMode, type InvalidationPluginConfig, type InvalidationPluginExports, type InvalidationReadOptions, type InvalidationReadResult, type InvalidationWriteOptions, type InvalidationWriteResult, invalidationPlugin };
114
+ export { type InvalidateOption, type InvalidationInfiniteReadOptions, type InvalidationMode, type InvalidationPluginConfig, type InvalidationPluginExports, type InvalidationReadOptions, type InvalidationReadResult, type InvalidationWriteOptions, type InvalidationWriteResult, type InvalidationWriteTriggerOptions, invalidationPlugin };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spoosh/plugin-invalidation",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "Cache invalidation plugin for Spoosh - auto-invalidates after mutations",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -33,10 +33,10 @@
33
33
  }
34
34
  },
35
35
  "peerDependencies": {
36
- "@spoosh/core": ">=0.13.0"
36
+ "@spoosh/core": ">=0.13.1"
37
37
  },
38
38
  "devDependencies": {
39
- "@spoosh/core": "0.13.0",
39
+ "@spoosh/core": "0.13.1",
40
40
  "@spoosh/test-utils": "0.2.0"
41
41
  },
42
42
  "scripts": {