enlace 0.0.1-beta.20 → 0.0.1-beta.21

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
@@ -561,6 +561,26 @@ trigger({
561
561
  | Both | `['custom']` | `['extra']` | `['custom', 'extra']` |
562
562
  | Neither | - | - | `['posts']` (auto) |
563
563
 
564
+ ### Manual Tag Invalidation
565
+
566
+ Use `invalidateTags` to manually trigger cache invalidation and refetch queries:
567
+
568
+ ```typescript
569
+ import { invalidateTags } from "enlace/hook";
570
+
571
+ // Invalidate all queries tagged with 'posts'
572
+ invalidateTags(["posts"]);
573
+
574
+ // Invalidate multiple tags
575
+ invalidateTags(["posts", "users"]);
576
+ ```
577
+
578
+ This is useful when you need to refresh data outside of the normal mutation flow, such as:
579
+
580
+ - After receiving a WebSocket message
581
+ - After a background sync
582
+ - After external state changes
583
+
564
584
  ### Disable Auto-Revalidation
565
585
 
566
586
  ```typescript
@@ -217,4 +217,22 @@ type NextEnlaceHook<TSchema, TDefaultError = unknown> = {
217
217
  */
218
218
  declare function enlaceHookNext<TSchema = unknown, TDefaultError = unknown>(baseUrl: string, defaultOptions?: EnlaceOptions, hookOptions?: NextHookOptions): NextEnlaceHook<TSchema, TDefaultError>;
219
219
 
220
- export { type AnyReactRequestOptions, type ApiClient, type EnlaceHook, type EnlaceHookOptions, HTTP_METHODS, type HookState, type NextEnlaceHook, type NextHookOptions, type PollingInterval, type PollingIntervalFn, type PollingIntervalValue, type QueryFn, type ReactRequestOptionsBase, type SelectorFn, type TrackedCall, type UseEnlaceQueryOptions, type UseEnlaceQueryResult, type UseEnlaceSelectorResult, enlaceHookNext, enlaceHookReact };
220
+ /**
221
+ * Manually invalidate cache entries and trigger refetch for queries matching the specified tags.
222
+ *
223
+ * @param tags - Array of cache tags to invalidate
224
+ *
225
+ * @example
226
+ * ```ts
227
+ * import { invalidateTags } from 'enlace/hook';
228
+ *
229
+ * // Invalidate all queries tagged with 'posts'
230
+ * invalidateTags(['posts']);
231
+ *
232
+ * // Invalidate multiple tags
233
+ * invalidateTags(['posts', 'users']);
234
+ * ```
235
+ */
236
+ declare function invalidateTags(tags: string[]): void;
237
+
238
+ export { type AnyReactRequestOptions, type ApiClient, type EnlaceHook, type EnlaceHookOptions, HTTP_METHODS, type HookState, type NextEnlaceHook, type NextHookOptions, type PollingInterval, type PollingIntervalFn, type PollingIntervalValue, type QueryFn, type ReactRequestOptionsBase, type SelectorFn, type TrackedCall, type UseEnlaceQueryOptions, type UseEnlaceQueryResult, type UseEnlaceSelectorResult, enlaceHookNext, enlaceHookReact, invalidateTags };
@@ -217,4 +217,22 @@ type NextEnlaceHook<TSchema, TDefaultError = unknown> = {
217
217
  */
218
218
  declare function enlaceHookNext<TSchema = unknown, TDefaultError = unknown>(baseUrl: string, defaultOptions?: EnlaceOptions, hookOptions?: NextHookOptions): NextEnlaceHook<TSchema, TDefaultError>;
219
219
 
220
- export { type AnyReactRequestOptions, type ApiClient, type EnlaceHook, type EnlaceHookOptions, HTTP_METHODS, type HookState, type NextEnlaceHook, type NextHookOptions, type PollingInterval, type PollingIntervalFn, type PollingIntervalValue, type QueryFn, type ReactRequestOptionsBase, type SelectorFn, type TrackedCall, type UseEnlaceQueryOptions, type UseEnlaceQueryResult, type UseEnlaceSelectorResult, enlaceHookNext, enlaceHookReact };
220
+ /**
221
+ * Manually invalidate cache entries and trigger refetch for queries matching the specified tags.
222
+ *
223
+ * @param tags - Array of cache tags to invalidate
224
+ *
225
+ * @example
226
+ * ```ts
227
+ * import { invalidateTags } from 'enlace/hook';
228
+ *
229
+ * // Invalidate all queries tagged with 'posts'
230
+ * invalidateTags(['posts']);
231
+ *
232
+ * // Invalidate multiple tags
233
+ * invalidateTags(['posts', 'users']);
234
+ * ```
235
+ */
236
+ declare function invalidateTags(tags: string[]): void;
237
+
238
+ export { type AnyReactRequestOptions, type ApiClient, type EnlaceHook, type EnlaceHookOptions, HTTP_METHODS, type HookState, type NextEnlaceHook, type NextHookOptions, type PollingInterval, type PollingIntervalFn, type PollingIntervalValue, type QueryFn, type ReactRequestOptionsBase, type SelectorFn, type TrackedCall, type UseEnlaceQueryOptions, type UseEnlaceQueryResult, type UseEnlaceSelectorResult, enlaceHookNext, enlaceHookReact, invalidateTags };
@@ -24,7 +24,8 @@ var hook_exports = {};
24
24
  __export(hook_exports, {
25
25
  HTTP_METHODS: () => HTTP_METHODS,
26
26
  enlaceHookNext: () => enlaceHookNext,
27
- enlaceHookReact: () => enlaceHookReact
27
+ enlaceHookReact: () => enlaceHookReact,
28
+ invalidateTags: () => invalidateTags
28
29
  });
29
30
  module.exports = __toCommonJS(hook_exports);
30
31
 
@@ -586,5 +586,6 @@ function enlaceHookNext(baseUrl, defaultOptions = {}, hookOptions = {}) {
586
586
  export {
587
587
  HTTP_METHODS,
588
588
  enlaceHookNext,
589
- enlaceHookReact
589
+ enlaceHookReact,
590
+ invalidateTags
590
591
  };
package/dist/index.d.mts CHANGED
@@ -97,6 +97,4 @@ type NextRequestOptionsBase = ReactRequestOptionsBase & {
97
97
 
98
98
  declare function enlaceNext<TSchema = unknown, TDefaultError = unknown>(baseUrl: string, defaultOptions?: EnlaceOptions | null, nextOptions?: NextOptions): unknown extends TSchema ? WildcardClient<NextRequestOptionsBase> : EnlaceClient<TSchema, TDefaultError, NextRequestOptionsBase>;
99
99
 
100
- declare function invalidateTags(tags: string[]): void;
101
-
102
- export { type NextOptions, type NextRequestOptionsBase, enlaceNext, invalidateTags };
100
+ export { type NextOptions, type NextRequestOptionsBase, enlaceNext };
package/dist/index.d.ts CHANGED
@@ -97,6 +97,4 @@ type NextRequestOptionsBase = ReactRequestOptionsBase & {
97
97
 
98
98
  declare function enlaceNext<TSchema = unknown, TDefaultError = unknown>(baseUrl: string, defaultOptions?: EnlaceOptions | null, nextOptions?: NextOptions): unknown extends TSchema ? WildcardClient<NextRequestOptionsBase> : EnlaceClient<TSchema, TDefaultError, NextRequestOptionsBase>;
99
99
 
100
- declare function invalidateTags(tags: string[]): void;
101
-
102
- export { type NextOptions, type NextRequestOptionsBase, enlaceNext, invalidateTags };
100
+ export { type NextOptions, type NextRequestOptionsBase, enlaceNext };
package/dist/index.js CHANGED
@@ -21,8 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  // src/index.ts
22
22
  var src_exports = {};
23
23
  __export(src_exports, {
24
- enlaceNext: () => enlaceNext,
25
- invalidateTags: () => invalidateTags
24
+ enlaceNext: () => enlaceNext
26
25
  });
27
26
  module.exports = __toCommonJS(src_exports);
28
27
  __reExport(src_exports, require("enlace-core"), module.exports);
@@ -98,23 +97,3 @@ function enlaceNext(baseUrl, defaultOptions = {}, nextOptions = {}) {
98
97
  executeNextFetch
99
98
  );
100
99
  }
101
-
102
- // src/react/cache.ts
103
- var cache = /* @__PURE__ */ new Map();
104
- function clearCacheByTags(tags) {
105
- cache.forEach((entry) => {
106
- const hasMatch = entry.tags.some((tag) => tags.includes(tag));
107
- if (hasMatch) {
108
- entry.timestamp = 0;
109
- delete entry.promise;
110
- entry.subscribers.forEach((cb) => cb());
111
- }
112
- });
113
- }
114
-
115
- // src/react/revalidator.ts
116
- var listeners = /* @__PURE__ */ new Set();
117
- function invalidateTags(tags) {
118
- clearCacheByTags(tags);
119
- listeners.forEach((listener) => listener(tags));
120
- }
package/dist/index.mjs CHANGED
@@ -76,27 +76,6 @@ function enlaceNext(baseUrl, defaultOptions = {}, nextOptions = {}) {
76
76
  executeNextFetch
77
77
  );
78
78
  }
79
-
80
- // src/react/cache.ts
81
- var cache = /* @__PURE__ */ new Map();
82
- function clearCacheByTags(tags) {
83
- cache.forEach((entry) => {
84
- const hasMatch = entry.tags.some((tag) => tags.includes(tag));
85
- if (hasMatch) {
86
- entry.timestamp = 0;
87
- delete entry.promise;
88
- entry.subscribers.forEach((cb) => cb());
89
- }
90
- });
91
- }
92
-
93
- // src/react/revalidator.ts
94
- var listeners = /* @__PURE__ */ new Set();
95
- function invalidateTags(tags) {
96
- clearCacheByTags(tags);
97
- listeners.forEach((listener) => listener(tags));
98
- }
99
79
  export {
100
- enlaceNext,
101
- invalidateTags
80
+ enlaceNext
102
81
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "enlace",
3
- "version": "0.0.1-beta.20",
3
+ "version": "0.0.1-beta.21",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",