@spoosh/plugin-invalidation 0.9.0 → 0.10.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/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { SpooshPlugin } from '@spoosh/core';
1
+ import * as _spoosh_core from '@spoosh/core';
2
2
 
3
3
  type InvalidationMode = "all" | "self" | "none";
4
4
  /**
@@ -54,13 +54,13 @@ interface InvalidationPluginExports {
54
54
  setDefaultMode: (value: InvalidationMode) => void;
55
55
  }
56
56
  declare module "@spoosh/core" {
57
- interface PluginExportsRegistry {
57
+ interface PluginInternalRegistry {
58
58
  "spoosh:invalidation": InvalidationPluginExports;
59
59
  }
60
60
  interface PluginResolvers<TContext> {
61
61
  invalidate: InvalidateOption<TContext["schema"]> | undefined;
62
62
  }
63
- interface InstanceApiResolvers<TSchema> {
63
+ interface ApiResolvers<TSchema> {
64
64
  invalidate: InvalidateFn<TSchema>;
65
65
  }
66
66
  }
@@ -106,7 +106,7 @@ declare module "@spoosh/core" {
106
106
  * });
107
107
  * ```
108
108
  */
109
- declare function invalidationPlugin(config?: InvalidationPluginConfig): SpooshPlugin<{
109
+ declare function invalidationPlugin(config?: InvalidationPluginConfig): _spoosh_core.SpooshPlugin<{
110
110
  readOptions: InvalidationReadOptions;
111
111
  writeOptions: InvalidationWriteOptions;
112
112
  writeTriggerOptions: InvalidationWriteTriggerOptions;
@@ -115,7 +115,7 @@ declare function invalidationPlugin(config?: InvalidationPluginConfig): SpooshPl
115
115
  readResult: InvalidationReadResult;
116
116
  writeResult: InvalidationWriteResult;
117
117
  queueResult: InvalidationQueueResult;
118
- instanceApi: InvalidationInstanceApi;
118
+ api: InvalidationInstanceApi;
119
119
  }>;
120
120
 
121
121
  export { type InvalidateOption, type InvalidationMode, type InvalidationPagesOptions, type InvalidationPluginConfig, type InvalidationPluginExports, type InvalidationQueueResult, type InvalidationQueueTriggerOptions, type InvalidationReadOptions, type InvalidationReadResult, type InvalidationWriteOptions, type InvalidationWriteResult, type InvalidationWriteTriggerOptions, invalidationPlugin };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { SpooshPlugin } from '@spoosh/core';
1
+ import * as _spoosh_core from '@spoosh/core';
2
2
 
3
3
  type InvalidationMode = "all" | "self" | "none";
4
4
  /**
@@ -54,13 +54,13 @@ interface InvalidationPluginExports {
54
54
  setDefaultMode: (value: InvalidationMode) => void;
55
55
  }
56
56
  declare module "@spoosh/core" {
57
- interface PluginExportsRegistry {
57
+ interface PluginInternalRegistry {
58
58
  "spoosh:invalidation": InvalidationPluginExports;
59
59
  }
60
60
  interface PluginResolvers<TContext> {
61
61
  invalidate: InvalidateOption<TContext["schema"]> | undefined;
62
62
  }
63
- interface InstanceApiResolvers<TSchema> {
63
+ interface ApiResolvers<TSchema> {
64
64
  invalidate: InvalidateFn<TSchema>;
65
65
  }
66
66
  }
@@ -106,7 +106,7 @@ declare module "@spoosh/core" {
106
106
  * });
107
107
  * ```
108
108
  */
109
- declare function invalidationPlugin(config?: InvalidationPluginConfig): SpooshPlugin<{
109
+ declare function invalidationPlugin(config?: InvalidationPluginConfig): _spoosh_core.SpooshPlugin<{
110
110
  readOptions: InvalidationReadOptions;
111
111
  writeOptions: InvalidationWriteOptions;
112
112
  writeTriggerOptions: InvalidationWriteTriggerOptions;
@@ -115,7 +115,7 @@ declare function invalidationPlugin(config?: InvalidationPluginConfig): SpooshPl
115
115
  readResult: InvalidationReadResult;
116
116
  writeResult: InvalidationWriteResult;
117
117
  queueResult: InvalidationQueueResult;
118
- instanceApi: InvalidationInstanceApi;
118
+ api: InvalidationInstanceApi;
119
119
  }>;
120
120
 
121
121
  export { type InvalidateOption, type InvalidationMode, type InvalidationPagesOptions, type InvalidationPluginConfig, type InvalidationPluginExports, type InvalidationQueueResult, type InvalidationQueueTriggerOptions, type InvalidationReadOptions, type InvalidationReadResult, type InvalidationWriteOptions, type InvalidationWriteResult, type InvalidationWriteTriggerOptions, invalidationPlugin };
package/dist/index.js CHANGED
@@ -40,8 +40,7 @@ function resolveModeTags(context, mode) {
40
40
  }
41
41
  }
42
42
  function resolveInvalidateTags(context, defaultMode) {
43
- const pluginOptions = context.pluginOptions;
44
- const invalidateOption = pluginOptions?.invalidate;
43
+ const invalidateOption = context.pluginOptions?.invalidate;
45
44
  if (!invalidateOption) {
46
45
  const overrideDefault = context.temp.get(INVALIDATION_DEFAULT_KEY);
47
46
  const effectiveDefault = overrideDefault ?? defaultMode;
@@ -70,10 +69,10 @@ function resolveInvalidateTags(context, defaultMode) {
70
69
  }
71
70
  function invalidationPlugin(config = {}) {
72
71
  const { defaultMode = "all" } = config;
73
- return {
72
+ return (0, import_core.createSpooshPlugin)({
74
73
  name: PLUGIN_NAME,
75
74
  operations: ["write", "queue"],
76
- exports(context) {
75
+ internal(context) {
77
76
  return {
78
77
  setDefaultMode(value) {
79
78
  context.temp.set(INVALIDATION_DEFAULT_KEY, value);
@@ -101,7 +100,7 @@ function invalidationPlugin(config = {}) {
101
100
  }
102
101
  }
103
102
  },
104
- instanceApi(context) {
103
+ api(context) {
105
104
  const { stateManager, eventEmitter } = context;
106
105
  const et = context.eventTracer?.(PLUGIN_NAME);
107
106
  const invalidate = (input) => {
@@ -119,5 +118,5 @@ function invalidationPlugin(config = {}) {
119
118
  };
120
119
  return { invalidate };
121
120
  }
122
- };
121
+ });
123
122
  }
package/dist/index.mjs CHANGED
@@ -1,5 +1,8 @@
1
1
  // src/plugin.ts
2
- import { resolvePathString } from "@spoosh/core";
2
+ import {
3
+ resolvePathString,
4
+ createSpooshPlugin
5
+ } from "@spoosh/core";
3
6
  var PLUGIN_NAME = "spoosh:invalidation";
4
7
  var INVALIDATION_DEFAULT_KEY = "invalidation:defaultMode";
5
8
  function resolveModeTags(context, mode) {
@@ -14,8 +17,7 @@ function resolveModeTags(context, mode) {
14
17
  }
15
18
  }
16
19
  function resolveInvalidateTags(context, defaultMode) {
17
- const pluginOptions = context.pluginOptions;
18
- const invalidateOption = pluginOptions?.invalidate;
20
+ const invalidateOption = context.pluginOptions?.invalidate;
19
21
  if (!invalidateOption) {
20
22
  const overrideDefault = context.temp.get(INVALIDATION_DEFAULT_KEY);
21
23
  const effectiveDefault = overrideDefault ?? defaultMode;
@@ -44,10 +46,10 @@ function resolveInvalidateTags(context, defaultMode) {
44
46
  }
45
47
  function invalidationPlugin(config = {}) {
46
48
  const { defaultMode = "all" } = config;
47
- return {
49
+ return createSpooshPlugin({
48
50
  name: PLUGIN_NAME,
49
51
  operations: ["write", "queue"],
50
- exports(context) {
52
+ internal(context) {
51
53
  return {
52
54
  setDefaultMode(value) {
53
55
  context.temp.set(INVALIDATION_DEFAULT_KEY, value);
@@ -75,7 +77,7 @@ function invalidationPlugin(config = {}) {
75
77
  }
76
78
  }
77
79
  },
78
- instanceApi(context) {
80
+ api(context) {
79
81
  const { stateManager, eventEmitter } = context;
80
82
  const et = context.eventTracer?.(PLUGIN_NAME);
81
83
  const invalidate = (input) => {
@@ -93,7 +95,7 @@ function invalidationPlugin(config = {}) {
93
95
  };
94
96
  return { invalidate };
95
97
  }
96
- };
98
+ });
97
99
  }
98
100
  export {
99
101
  invalidationPlugin
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spoosh/plugin-invalidation",
3
- "version": "0.9.0",
3
+ "version": "0.10.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.15.0"
36
+ "@spoosh/core": ">=0.17.0"
37
37
  },
38
38
  "devDependencies": {
39
- "@spoosh/core": "0.15.0",
39
+ "@spoosh/core": "0.17.0",
40
40
  "@spoosh/test-utils": "0.3.0"
41
41
  },
42
42
  "scripts": {
@@ -44,6 +44,6 @@
44
44
  "build": "tsup",
45
45
  "typecheck": "tsc --noEmit",
46
46
  "lint": "eslint src --max-warnings 0",
47
- "format": "prettier --write 'src/**/*.ts'"
47
+ "format": "prettier --write 'src/**/*.ts' '*.md'"
48
48
  }
49
49
  }