@spoosh/plugin-optimistic 0.3.0 → 0.4.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.
package/dist/index.d.mts CHANGED
@@ -1,8 +1,5 @@
1
- import { FindMatchingKey, HasParams, ExtractParamNames, ExtractData, SpooshPlugin } from '@spoosh/core';
1
+ import { FindMatchingKey, HasParams, ExtractParamNames, Simplify, ExtractData, SpooshPlugin } from '@spoosh/core';
2
2
 
3
- type Simplify<T> = {
4
- [K in keyof T]: T[K];
5
- } & {};
6
3
  /**
7
4
  * Check if query exists in the method config.
8
5
  */
@@ -225,9 +222,9 @@ declare const OPTIMISTIC_SNAPSHOTS_KEY = "optimistic:snapshots";
225
222
  * Immediately updates cached data before the mutation completes,
226
223
  * with automatic rollback on error.
227
224
  *
228
- * When using optimistic updates, `autoInvalidate` defaults to `"none"` to prevent
225
+ * When using optimistic updates, invalidation mode defaults to `"none"` to prevent
229
226
  * unnecessary refetches that would override the optimistic data. You can override
230
- * this by explicitly setting `autoInvalidate` or using the `invalidate` option.
227
+ * this by explicitly setting the `invalidate` option with a mode string or array.
231
228
  *
232
229
  * @see {@link https://spoosh.dev/docs/plugins/optimistic | Optimistic Plugin Documentation}
233
230
  *
package/dist/index.d.ts CHANGED
@@ -1,8 +1,5 @@
1
- import { FindMatchingKey, HasParams, ExtractParamNames, ExtractData, SpooshPlugin } from '@spoosh/core';
1
+ import { FindMatchingKey, HasParams, ExtractParamNames, Simplify, ExtractData, SpooshPlugin } from '@spoosh/core';
2
2
 
3
- type Simplify<T> = {
4
- [K in keyof T]: T[K];
5
- } & {};
6
3
  /**
7
4
  * Check if query exists in the method config.
8
5
  */
@@ -225,9 +222,9 @@ declare const OPTIMISTIC_SNAPSHOTS_KEY = "optimistic:snapshots";
225
222
  * Immediately updates cached data before the mutation completes,
226
223
  * with automatic rollback on error.
227
224
  *
228
- * When using optimistic updates, `autoInvalidate` defaults to `"none"` to prevent
225
+ * When using optimistic updates, invalidation mode defaults to `"none"` to prevent
229
226
  * unnecessary refetches that would override the optimistic data. You can override
230
- * this by explicitly setting `autoInvalidate` or using the `invalidate` option.
227
+ * this by explicitly setting the `invalidate` option with a mode string or array.
231
228
  *
232
229
  * @see {@link https://spoosh.dev/docs/plugins/optimistic | Optimistic Plugin Documentation}
233
230
  *
package/dist/index.js CHANGED
@@ -162,7 +162,7 @@ function optimisticPlugin() {
162
162
  const { stateManager } = context;
163
163
  const targets = resolveOptimisticTargets(context);
164
164
  if (targets.length > 0) {
165
- context.plugins.get("spoosh:invalidation")?.setAutoInvalidateDefault("none");
165
+ context.plugins.get("spoosh:invalidation")?.setDefaultMode("none");
166
166
  }
167
167
  const immediateTargets = targets.filter((t) => t.timing !== "onSuccess");
168
168
  const allSnapshots = [];
package/dist/index.mjs CHANGED
@@ -135,7 +135,7 @@ function optimisticPlugin() {
135
135
  const { stateManager } = context;
136
136
  const targets = resolveOptimisticTargets(context);
137
137
  if (targets.length > 0) {
138
- context.plugins.get("spoosh:invalidation")?.setAutoInvalidateDefault("none");
138
+ context.plugins.get("spoosh:invalidation")?.setDefaultMode("none");
139
139
  }
140
140
  const immediateTargets = targets.filter((t) => t.timing !== "onSuccess");
141
141
  const allSnapshots = [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spoosh/plugin-optimistic",
3
- "version": "0.3.0",
3
+ "version": "0.4.1",
4
4
  "description": "Optimistic updates plugin for Spoosh - instant UI updates with automatic rollback",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -33,13 +33,13 @@
33
33
  }
34
34
  },
35
35
  "peerDependencies": {
36
- "@spoosh/core": ">=0.6.0",
37
- "@spoosh/plugin-invalidation": ">=0.1.0"
36
+ "@spoosh/core": ">=0.9.0",
37
+ "@spoosh/plugin-invalidation": ">=0.4.0"
38
38
  },
39
39
  "devDependencies": {
40
- "@spoosh/core": "0.6.0",
41
- "@spoosh/plugin-invalidation": "0.3.0",
42
- "@spoosh/test-utils": "0.1.5"
40
+ "@spoosh/core": "0.9.0",
41
+ "@spoosh/test-utils": "0.1.5",
42
+ "@spoosh/plugin-invalidation": "0.5.0"
43
43
  },
44
44
  "scripts": {
45
45
  "dev": "tsup --watch",