@kubb/plugin-swr 5.4.3 → 5.4.5

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/docs/options.md CHANGED
@@ -10,9 +10,9 @@ Pass these options to `pluginSwr()`, all of them optional. Shared options link t
10
10
  | [`group`](https://kubb.dev/docs/5.x/reference/plugin-options#group) | Split output by tag or path: `type`, `name`. | None |
11
11
  | [`client`](#client) | Which registered client plugin the hooks call. | Auto-detected |
12
12
  | [`query`](#query) | Configure the `useSWR` hooks, or turn them off. | `{ methods: ['GET', 'QUERY'], importPath: 'swr' }` |
13
- | [`queryKey`](#querykey) | Build the SWR key for each query hook. | Built-in `queryKeyTransformer` |
13
+ | [`queryKey`](#querykey) | Build the SWR key for each query hook. | Exported `queryKeyTransformer` |
14
14
  | [`mutation`](#mutation) | Configure the `useSWRMutation` hooks, or turn them off. | `{ methods: ['POST', 'PUT', 'PATCH', 'DELETE'], importPath: 'swr/mutation' }` |
15
- | [`mutationKey`](#mutationkey) | Build the SWR key for each mutation hook. | Built-in `mutationKeyTransformer` |
15
+ | [`mutationKey`](#mutationkey) | Build the SWR key for each mutation hook. | Exported `mutationKeyTransformer` |
16
16
  | [`include`](https://kubb.dev/docs/5.x/reference/plugin-options#include) | Keep only operations that match. | None |
17
17
  | [`exclude`](https://kubb.dev/docs/5.x/reference/plugin-options#exclude) | Skip operations that match. | `[]` |
18
18
  | [`override`](https://kubb.dev/docs/5.x/reference/plugin-options#override) | Apply different options per pattern. | `[]` |
@@ -86,12 +86,20 @@ Builds the SWR key for each query hook. The callback receives the operation `nod
86
86
  | -------- | ------------------------------------------------------ |
87
87
  | Type | `(props: { node, casing, variant }) => Array<unknown>` |
88
88
  | Required | `false` |
89
- | Default | Built-in `queryKeyTransformer` |
89
+ | Default | Exported `queryKeyTransformer` |
90
90
 
91
91
  ```typescript
92
92
  queryKey: ({ node, variant }) => [JSON.stringify({ variant, operationId: node.operationId })]
93
93
  ```
94
94
 
95
+ To extend the default key instead of replacing it, import `queryKeyTransformer` and spread its result. The default segments can change between releases, so spread them instead of reading single entries.
96
+
97
+ ```typescript
98
+ import { queryKeyTransformer } from '@kubb/plugin-swr'
99
+
100
+ queryKey: (props) => [JSON.stringify(props.node.operationId), ...queryKeyTransformer(props)]
101
+ ```
102
+
95
103
  ### mutation
96
104
 
97
105
  Configures the generated `useSWRMutation` hooks. Pass an object to change the HTTP methods or import path, or `false` to skip mutation hook generation.
@@ -130,7 +138,15 @@ Builds the SWR key for each mutation hook. Like `queryKey`, the callback receive
130
138
  | -------- | ------------------------------------------------------ |
131
139
  | Type | `(props: { node, casing, variant }) => Array<unknown>` |
132
140
  | Required | `false` |
133
- | Default | Built-in `mutationKeyTransformer` |
141
+ | Default | Exported `mutationKeyTransformer` |
142
+
143
+ Extend the default the same way with `mutationKeyTransformer`:
144
+
145
+ ```typescript
146
+ import { mutationKeyTransformer } from '@kubb/plugin-swr'
147
+
148
+ mutationKey: (props) => [JSON.stringify(props.node.operationId), ...mutationKeyTransformer(props)]
149
+ ```
134
150
 
135
151
  ### resolver
136
152
 
@@ -195,6 +195,20 @@
195
195
  "description": "Module specifier the generated mutation hook imports from",
196
196
  "type": "text",
197
197
  "default": "swr/mutation"
198
+ },
199
+ {
200
+ "key": "banner",
201
+ "path": ["output", "banner"],
202
+ "label": "Banner",
203
+ "description": "Text added at the top of every generated file",
204
+ "type": "text"
205
+ },
206
+ {
207
+ "key": "footer",
208
+ "path": ["output", "footer"],
209
+ "label": "Footer",
210
+ "description": "Text added at the end of every generated file",
211
+ "type": "text"
198
212
  }
199
213
  ]
200
214
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kubb/plugin-swr",
3
- "version": "5.4.3",
3
+ "version": "5.4.5",
4
4
  "description": "Generate type-safe SWR hooks with Kubb. Covers useSWR and useSWRMutation with full TypeScript support.",
5
5
  "keywords": [
6
6
  "code-generation",
@@ -79,18 +79,18 @@
79
79
  "registry": "https://registry.npmjs.org/"
80
80
  },
81
81
  "dependencies": {
82
- "@kubb/plugin-ts": "^5.0.14"
82
+ "@kubb/plugin-ts": "^5.0.15"
83
83
  },
84
84
  "devDependencies": {
85
85
  "@internals/client": "0.0.0",
86
86
  "@internals/shared": "0.0.0",
87
87
  "@internals/tanstack-query": "0.0.0",
88
88
  "@internals/utils": "0.0.0",
89
- "kubb": "^5.10.3",
89
+ "kubb": "^5.12.5",
90
90
  "swr": "^2.5.1"
91
91
  },
92
92
  "peerDependencies": {
93
- "kubb": "^5.10.3",
93
+ "kubb": "^5.12.5",
94
94
  "swr": "^2.2.0"
95
95
  },
96
96
  "peerDependenciesMeta": {