@spoosh/plugin-prefetch 0.3.0 → 0.3.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/README.md +12 -12
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -64,39 +64,39 @@ await prefetch(
|
|
|
64
64
|
|
|
65
65
|
The second argument to `prefetch()` accepts any plugin options (staleTime, retries, dedupe, etc.) plus:
|
|
66
66
|
|
|
67
|
-
| Option | Type | Description
|
|
68
|
-
| ------ | --------------------------------------- |
|
|
67
|
+
| Option | Type | Description |
|
|
68
|
+
| ------ | --------------------------------------- | --------------------------------------------------- |
|
|
69
69
|
| `tags` | `'all' \| 'self' \| 'none' \| string[]` | Tag mode or custom tags (replaces `additionalTags`) |
|
|
70
70
|
|
|
71
71
|
**Examples:**
|
|
72
72
|
|
|
73
73
|
```typescript
|
|
74
74
|
// Mode only - 'all' generates full hierarchy
|
|
75
|
-
await prefetch((api) => api("users/:id/posts").GET({ params: { id:
|
|
76
|
-
tags:
|
|
75
|
+
await prefetch((api) => api("users/:id/posts").GET({ params: { id: "123" } }), {
|
|
76
|
+
tags: "all", // ['users', 'users/123', 'users/123/posts']
|
|
77
77
|
});
|
|
78
78
|
|
|
79
79
|
// Mode only - 'self' generates only exact path
|
|
80
|
-
await prefetch((api) => api("users/:id/posts").GET({ params: { id:
|
|
81
|
-
tags:
|
|
80
|
+
await prefetch((api) => api("users/:id/posts").GET({ params: { id: "123" } }), {
|
|
81
|
+
tags: "self", // ['users/123/posts']
|
|
82
82
|
});
|
|
83
83
|
|
|
84
84
|
// Mode only - 'none' generates no tags
|
|
85
|
-
await prefetch((api) => api("posts").GET(), { tags:
|
|
85
|
+
await prefetch((api) => api("posts").GET(), { tags: "none" }); // []
|
|
86
86
|
|
|
87
87
|
// Custom tags only - replaces auto-generated tags
|
|
88
88
|
await prefetch((api) => api("posts").GET(), {
|
|
89
|
-
tags: [
|
|
89
|
+
tags: ["custom", "dashboard"], // ['custom', 'dashboard']
|
|
90
90
|
});
|
|
91
91
|
|
|
92
92
|
// Mode + custom tags - 'all' mode combined with custom tags
|
|
93
|
-
await prefetch((api) => api("users/:id/posts").GET({ params: { id:
|
|
94
|
-
tags: [
|
|
93
|
+
await prefetch((api) => api("users/:id/posts").GET({ params: { id: "123" } }), {
|
|
94
|
+
tags: ["all", "dashboard"], // ['users', 'users/123', 'users/123/posts', 'dashboard']
|
|
95
95
|
});
|
|
96
96
|
|
|
97
97
|
// Mode + custom tags - 'self' mode combined with custom tags
|
|
98
|
-
await prefetch((api) => api("users/:id/posts").GET({ params: { id:
|
|
99
|
-
tags: [
|
|
98
|
+
await prefetch((api) => api("users/:id/posts").GET({ params: { id: "123" } }), {
|
|
99
|
+
tags: ["self", "dashboard"], // ['users/123/posts', 'dashboard']
|
|
100
100
|
});
|
|
101
101
|
```
|
|
102
102
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReadSchemaHelper, SpooshResponse, TagOptions, SpooshPlugin } from '@spoosh/core';
|
|
2
2
|
|
|
3
3
|
interface PrefetchPluginConfig {
|
|
4
4
|
/** Default stale time for prefetched data in milliseconds */
|
|
@@ -14,7 +14,7 @@ interface PrefetchOptions extends TagOptions {
|
|
|
14
14
|
/** Additional plugin options (staleTime, retries, dedupe, etc.) */
|
|
15
15
|
[key: string]: unknown;
|
|
16
16
|
}
|
|
17
|
-
type PrefetchCallbackFn<TSchema> = (api:
|
|
17
|
+
type PrefetchCallbackFn<TSchema> = (api: ReadSchemaHelper<TSchema>) => Promise<SpooshResponse<unknown, unknown>>;
|
|
18
18
|
type PrefetchFn<TSchema, TPluginOptions = object> = <TData = unknown, TError = unknown>(selector: PrefetchCallbackFn<TSchema>, options?: PrefetchOptions & TPluginOptions) => Promise<SpooshResponse<TData, TError>>;
|
|
19
19
|
interface PrefetchInstanceApi {
|
|
20
20
|
prefetch: PrefetchFn<unknown>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ReadSchemaHelper, SpooshResponse, TagOptions, SpooshPlugin } from '@spoosh/core';
|
|
2
2
|
|
|
3
3
|
interface PrefetchPluginConfig {
|
|
4
4
|
/** Default stale time for prefetched data in milliseconds */
|
|
@@ -14,7 +14,7 @@ interface PrefetchOptions extends TagOptions {
|
|
|
14
14
|
/** Additional plugin options (staleTime, retries, dedupe, etc.) */
|
|
15
15
|
[key: string]: unknown;
|
|
16
16
|
}
|
|
17
|
-
type PrefetchCallbackFn<TSchema> = (api:
|
|
17
|
+
type PrefetchCallbackFn<TSchema> = (api: ReadSchemaHelper<TSchema>) => Promise<SpooshResponse<unknown, unknown>>;
|
|
18
18
|
type PrefetchFn<TSchema, TPluginOptions = object> = <TData = unknown, TError = unknown>(selector: PrefetchCallbackFn<TSchema>, options?: PrefetchOptions & TPluginOptions) => Promise<SpooshResponse<TData, TError>>;
|
|
19
19
|
interface PrefetchInstanceApi {
|
|
20
20
|
prefetch: PrefetchFn<unknown>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spoosh/plugin-prefetch",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Prefetch plugin for Spoosh - preload data before it's needed",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@spoosh/core": ">=0.
|
|
36
|
+
"@spoosh/core": ">=0.9.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@spoosh/
|
|
40
|
-
"@spoosh/
|
|
39
|
+
"@spoosh/core": "0.9.0",
|
|
40
|
+
"@spoosh/test-utils": "0.1.5"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
43
|
"dev": "tsup --watch",
|