@spoosh/plugin-optimistic 0.6.1 → 0.7.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,4 +1,5 @@
1
- import { ReadPaths, FindMatchingKey, HasParams, ExtractParamNames, Simplify, ExtractData, SpooshPlugin } from '@spoosh/core';
1
+ import * as _spoosh_core from '@spoosh/core';
2
+ import { ReadPaths, FindMatchingKey, HasParams, ExtractParamNames, Simplify, ExtractData } from '@spoosh/core';
2
3
 
3
4
  /**
4
5
  * Check if query exists in the method config.
@@ -203,7 +204,7 @@ interface OptimisticWriteTriggerOptions<TSchema = unknown, TResponse = unknown>
203
204
  optimistic?: OptimisticCallbackFn<TSchema, TResponse>;
204
205
  }
205
206
  type OptimisticReadOptions = object;
206
- type OptimisticInfiniteReadOptions = object;
207
+ type OptimisticPagesOptions = object;
207
208
  interface OptimisticReadResult {
208
209
  isOptimistic: boolean;
209
210
  }
@@ -214,13 +215,13 @@ declare module "@spoosh/core" {
214
215
  }
215
216
  }
216
217
 
217
- declare function optimisticPlugin(): SpooshPlugin<{
218
+ declare function optimisticPlugin(): _spoosh_core.SpooshPlugin<{
218
219
  readOptions: OptimisticReadOptions;
219
220
  writeOptions: OptimisticWriteOptions;
220
221
  writeTriggerOptions: OptimisticWriteTriggerOptions;
221
- infiniteReadOptions: OptimisticInfiniteReadOptions;
222
+ pagesOptions: OptimisticPagesOptions;
222
223
  readResult: OptimisticReadResult;
223
224
  writeResult: OptimisticWriteResult;
224
225
  }>;
225
226
 
226
- export { type AnyOptimisticTarget, type OptimisticApiHelper, type OptimisticBuilder, type OptimisticCallbackFn, type OptimisticInfiniteReadOptions, type OptimisticPluginConfig, type OptimisticReadOptions, type OptimisticReadResult, type OptimisticTarget, type OptimisticWriteOptions, type OptimisticWriteResult, type OptimisticWriteTriggerOptions, optimisticPlugin };
227
+ export { type AnyOptimisticTarget, type OptimisticApiHelper, type OptimisticBuilder, type OptimisticCallbackFn, type OptimisticPagesOptions, type OptimisticPluginConfig, type OptimisticReadOptions, type OptimisticReadResult, type OptimisticTarget, type OptimisticWriteOptions, type OptimisticWriteResult, type OptimisticWriteTriggerOptions, optimisticPlugin };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { ReadPaths, FindMatchingKey, HasParams, ExtractParamNames, Simplify, ExtractData, SpooshPlugin } from '@spoosh/core';
1
+ import * as _spoosh_core from '@spoosh/core';
2
+ import { ReadPaths, FindMatchingKey, HasParams, ExtractParamNames, Simplify, ExtractData } from '@spoosh/core';
2
3
 
3
4
  /**
4
5
  * Check if query exists in the method config.
@@ -203,7 +204,7 @@ interface OptimisticWriteTriggerOptions<TSchema = unknown, TResponse = unknown>
203
204
  optimistic?: OptimisticCallbackFn<TSchema, TResponse>;
204
205
  }
205
206
  type OptimisticReadOptions = object;
206
- type OptimisticInfiniteReadOptions = object;
207
+ type OptimisticPagesOptions = object;
207
208
  interface OptimisticReadResult {
208
209
  isOptimistic: boolean;
209
210
  }
@@ -214,13 +215,13 @@ declare module "@spoosh/core" {
214
215
  }
215
216
  }
216
217
 
217
- declare function optimisticPlugin(): SpooshPlugin<{
218
+ declare function optimisticPlugin(): _spoosh_core.SpooshPlugin<{
218
219
  readOptions: OptimisticReadOptions;
219
220
  writeOptions: OptimisticWriteOptions;
220
221
  writeTriggerOptions: OptimisticWriteTriggerOptions;
221
- infiniteReadOptions: OptimisticInfiniteReadOptions;
222
+ pagesOptions: OptimisticPagesOptions;
222
223
  readResult: OptimisticReadResult;
223
224
  writeResult: OptimisticWriteResult;
224
225
  }>;
225
226
 
226
- export { type AnyOptimisticTarget, type OptimisticApiHelper, type OptimisticBuilder, type OptimisticCallbackFn, type OptimisticInfiniteReadOptions, type OptimisticPluginConfig, type OptimisticReadOptions, type OptimisticReadResult, type OptimisticTarget, type OptimisticWriteOptions, type OptimisticWriteResult, type OptimisticWriteTriggerOptions, optimisticPlugin };
227
+ export { type AnyOptimisticTarget, type OptimisticApiHelper, type OptimisticBuilder, type OptimisticCallbackFn, type OptimisticPagesOptions, type OptimisticPluginConfig, type OptimisticReadOptions, type OptimisticReadResult, type OptimisticTarget, type OptimisticWriteOptions, type OptimisticWriteResult, type OptimisticWriteTriggerOptions, optimisticPlugin };
package/dist/index.js CHANGED
@@ -25,6 +25,7 @@ __export(src_exports, {
25
25
  module.exports = __toCommonJS(src_exports);
26
26
 
27
27
  // src/plugin.ts
28
+ var import_core = require("@spoosh/core");
28
29
  var import_plugin_invalidation = require("@spoosh/plugin-invalidation");
29
30
  function createBuilder(state) {
30
31
  return {
@@ -147,7 +148,6 @@ function getMatchingEntries(stateManager, targetPath, targetMethod) {
147
148
  if (hasPatternParams(targetPath)) {
148
149
  const allEntries = stateManager.getAllCacheEntries();
149
150
  for (const { key, entry } of allEntries) {
150
- if (key.includes('"type":"infinite-tracker"')) continue;
151
151
  if (!key.includes(`"method":"${targetMethod}"`)) continue;
152
152
  const actualPath = extractPathFromKey(key);
153
153
  if (!actualPath) continue;
@@ -162,7 +162,6 @@ function getMatchingEntries(stateManager, targetPath, targetMethod) {
162
162
  } else {
163
163
  const allEntries = stateManager.getAllCacheEntries();
164
164
  for (const { key, entry } of allEntries) {
165
- if (key.includes('"type":"infinite-tracker"')) continue;
166
165
  if (!key.includes(`"method":"${targetMethod}"`)) continue;
167
166
  const actualPath = extractPathFromKey(key);
168
167
  if (!actualPath) continue;
@@ -279,7 +278,7 @@ function buildSnapshotDiff(snapshots, mode = "apply") {
279
278
  }
280
279
  var PLUGIN_NAME = "spoosh:optimistic";
281
280
  function optimisticPlugin() {
282
- return {
281
+ return (0, import_core.createSpooshPlugin)({
283
282
  name: PLUGIN_NAME,
284
283
  operations: ["write"],
285
284
  dependencies: ["spoosh:invalidation"],
@@ -384,5 +383,5 @@ function optimisticPlugin() {
384
383
  }
385
384
  return response;
386
385
  }
387
- };
386
+ });
388
387
  }
package/dist/index.mjs CHANGED
@@ -1,4 +1,7 @@
1
1
  // src/plugin.ts
2
+ import {
3
+ createSpooshPlugin
4
+ } from "@spoosh/core";
2
5
  import "@spoosh/plugin-invalidation";
3
6
  function createBuilder(state) {
4
7
  return {
@@ -121,7 +124,6 @@ function getMatchingEntries(stateManager, targetPath, targetMethod) {
121
124
  if (hasPatternParams(targetPath)) {
122
125
  const allEntries = stateManager.getAllCacheEntries();
123
126
  for (const { key, entry } of allEntries) {
124
- if (key.includes('"type":"infinite-tracker"')) continue;
125
127
  if (!key.includes(`"method":"${targetMethod}"`)) continue;
126
128
  const actualPath = extractPathFromKey(key);
127
129
  if (!actualPath) continue;
@@ -136,7 +138,6 @@ function getMatchingEntries(stateManager, targetPath, targetMethod) {
136
138
  } else {
137
139
  const allEntries = stateManager.getAllCacheEntries();
138
140
  for (const { key, entry } of allEntries) {
139
- if (key.includes('"type":"infinite-tracker"')) continue;
140
141
  if (!key.includes(`"method":"${targetMethod}"`)) continue;
141
142
  const actualPath = extractPathFromKey(key);
142
143
  if (!actualPath) continue;
@@ -253,7 +254,7 @@ function buildSnapshotDiff(snapshots, mode = "apply") {
253
254
  }
254
255
  var PLUGIN_NAME = "spoosh:optimistic";
255
256
  function optimisticPlugin() {
256
- return {
257
+ return createSpooshPlugin({
257
258
  name: PLUGIN_NAME,
258
259
  operations: ["write"],
259
260
  dependencies: ["spoosh:invalidation"],
@@ -358,7 +359,7 @@ function optimisticPlugin() {
358
359
  }
359
360
  return response;
360
361
  }
361
- };
362
+ });
362
363
  }
363
364
  export {
364
365
  optimisticPlugin
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spoosh/plugin-optimistic",
3
- "version": "0.6.1",
3
+ "version": "0.7.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.13.1",
36
+ "@spoosh/core": ">=0.15.0",
37
37
  "@spoosh/plugin-invalidation": ">=0.7.0"
38
38
  },
39
39
  "devDependencies": {
40
- "@spoosh/core": "0.14.1",
41
- "@spoosh/plugin-invalidation": "0.8.0",
42
- "@spoosh/test-utils": "0.2.0"
40
+ "@spoosh/core": "0.15.1",
41
+ "@spoosh/plugin-invalidation": "0.9.1",
42
+ "@spoosh/test-utils": "0.3.0"
43
43
  },
44
44
  "scripts": {
45
45
  "dev": "tsup --watch",