@kubb/plugin-vue-query 5.0.0-beta.42 → 5.0.0-beta.64

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.
Files changed (43) hide show
  1. package/dist/{components-Bxe1EuWf.js → components-CAlEf7Oh.js} +273 -388
  2. package/dist/components-CAlEf7Oh.js.map +1 -0
  3. package/dist/{components-BwFPMwK7.cjs → components-CfU59l8V.cjs} +274 -389
  4. package/dist/components-CfU59l8V.cjs.map +1 -0
  5. package/dist/components.cjs +1 -1
  6. package/dist/components.d.ts +1 -1
  7. package/dist/components.js +1 -1
  8. package/dist/{generators-BSN6A0ED.cjs → generators-DpMLVmyi.cjs} +91 -137
  9. package/dist/generators-DpMLVmyi.cjs.map +1 -0
  10. package/dist/{generators-D9TUvYRN.js → generators-fWBjs0CN.js} +93 -139
  11. package/dist/generators-fWBjs0CN.js.map +1 -0
  12. package/dist/generators.cjs +1 -1
  13. package/dist/generators.d.ts +1 -1
  14. package/dist/generators.js +1 -1
  15. package/dist/index.cjs +41 -18
  16. package/dist/index.cjs.map +1 -1
  17. package/dist/index.d.ts +1 -1
  18. package/dist/index.js +42 -19
  19. package/dist/index.js.map +1 -1
  20. package/dist/{types-HHnnlEhK.d.ts → types-C6a_58nb.d.ts} +12 -16
  21. package/package.json +10 -18
  22. package/dist/components-BwFPMwK7.cjs.map +0 -1
  23. package/dist/components-Bxe1EuWf.js.map +0 -1
  24. package/dist/generators-BSN6A0ED.cjs.map +0 -1
  25. package/dist/generators-D9TUvYRN.js.map +0 -1
  26. package/extension.yaml +0 -1248
  27. package/src/components/InfiniteQuery.tsx +0 -127
  28. package/src/components/InfiniteQueryOptions.tsx +0 -194
  29. package/src/components/Mutation.tsx +0 -150
  30. package/src/components/MutationKey.tsx +0 -1
  31. package/src/components/Query.tsx +0 -126
  32. package/src/components/QueryKey.tsx +0 -52
  33. package/src/components/QueryOptions.tsx +0 -137
  34. package/src/components/index.ts +0 -7
  35. package/src/generators/index.ts +0 -3
  36. package/src/generators/infiniteQueryGenerator.tsx +0 -200
  37. package/src/generators/mutationGenerator.tsx +0 -158
  38. package/src/generators/queryGenerator.tsx +0 -184
  39. package/src/index.ts +0 -2
  40. package/src/plugin.ts +0 -183
  41. package/src/resolvers/resolverVueQuery.ts +0 -76
  42. package/src/types.ts +0 -272
  43. package/src/utils.ts +0 -56
package/src/types.ts DELETED
@@ -1,272 +0,0 @@
1
- import type { ast, Exclude, Generator, Group, Include, Output, Override, PluginFactoryOptions, Resolver } from '@kubb/core'
2
- import type { ClientImportPath, PluginClient } from '@kubb/plugin-client'
3
-
4
- export type Transformer = (props: { node: ast.OperationNode; casing: 'camelcase' | undefined }) => Array<unknown>
5
-
6
- /**
7
- * Resolver for Vue Query that provides naming methods for hook functions.
8
- */
9
- export type ResolverVueQuery = Resolver & {
10
- /**
11
- * Resolves the base function name for an operation.
12
- */
13
- resolveName(this: ResolverVueQuery, name: string): string
14
- /**
15
- * Resolves the output file name for a hook module.
16
- */
17
- resolvePathName(this: ResolverVueQuery, name: string, type?: 'file' | 'function' | 'type' | 'const'): string
18
- /**
19
- * Resolves a query hook function name.
20
- */
21
- resolveQueryName(this: ResolverVueQuery, node: ast.OperationNode): string
22
- /**
23
- * Resolves an infinite query hook function name.
24
- */
25
- resolveInfiniteQueryName(this: ResolverVueQuery, node: ast.OperationNode): string
26
- /**
27
- * Resolves a mutation hook function name.
28
- */
29
- resolveMutationName(this: ResolverVueQuery, node: ast.OperationNode): string
30
- /**
31
- * Resolves the query options helper name.
32
- */
33
- resolveQueryOptionsName(this: ResolverVueQuery, node: ast.OperationNode): string
34
- /**
35
- * Resolves the infinite query options helper name.
36
- */
37
- resolveInfiniteQueryOptionsName(this: ResolverVueQuery, node: ast.OperationNode): string
38
- /**
39
- * Resolves the query key helper name.
40
- */
41
- resolveQueryKeyName(this: ResolverVueQuery, node: ast.OperationNode): string
42
- /**
43
- * Resolves the infinite query key helper name.
44
- */
45
- resolveInfiniteQueryKeyName(this: ResolverVueQuery, node: ast.OperationNode): string
46
- /**
47
- * Resolves the mutation key helper name.
48
- */
49
- resolveMutationKeyName(this: ResolverVueQuery, node: ast.OperationNode): string
50
- /**
51
- * Resolves the query key type name.
52
- */
53
- resolveQueryKeyTypeName(this: ResolverVueQuery, node: ast.OperationNode): string
54
- /**
55
- * Resolves the infinite query key type name.
56
- */
57
- resolveInfiniteQueryKeyTypeName(this: ResolverVueQuery, node: ast.OperationNode): string
58
- /**
59
- * Resolves the mutation type name.
60
- */
61
- resolveMutationTypeName(this: ResolverVueQuery, node: ast.OperationNode): string
62
- /**
63
- * Resolves the client function name generated inline by query hooks.
64
- */
65
- resolveClientName(this: ResolverVueQuery, node: ast.OperationNode): string
66
- /**
67
- * Resolves the client function name generated inline by infinite query hooks.
68
- */
69
- resolveInfiniteClientName(this: ResolverVueQuery, node: ast.OperationNode): string
70
- }
71
-
72
- /**
73
- * Builds the `queryKey` used by each generated query composable.
74
- *
75
- * @note String values are inlined verbatim into generated code. Wrap literal
76
- * strings in `JSON.stringify(...)`.
77
- */
78
- type QueryKey = Transformer
79
-
80
- /**
81
- * Builds the `mutationKey` used by each generated mutation composable.
82
- *
83
- * @note String values are inlined verbatim into generated code. Wrap literal
84
- * strings in `JSON.stringify(...)`.
85
- */
86
- type MutationKey = Transformer
87
-
88
- type Query = {
89
- /**
90
- * HTTP methods treated as queries.
91
- *
92
- * @default ['get']
93
- */
94
- methods?: Array<string>
95
- /**
96
- * Module specifier used in the `import { useQuery } from '...'` statement at
97
- * the top of every generated composable file.
98
- *
99
- * @default '@tanstack/vue-query'
100
- */
101
- importPath?: string
102
- }
103
-
104
- type Mutation = {
105
- /**
106
- * HTTP methods treated as mutations.
107
- *
108
- * @default ['post', 'put', 'delete']
109
- */
110
- methods?: Array<string>
111
- /**
112
- * Module specifier used in the `import { useMutation } from '...'` statement
113
- * at the top of every generated composable file.
114
- *
115
- * @default '@tanstack/vue-query'
116
- */
117
- importPath?: string
118
- }
119
-
120
- export type Infinite = {
121
- /**
122
- * Name of the query parameter that holds the page cursor.
123
- *
124
- * @default 'id'
125
- */
126
- queryParam?: string
127
- /**
128
- * Path to the cursor field on the response. Leave undefined when the cursor
129
- * is not known.
130
- *
131
- * @deprecated Use `nextParam` and `previousParam` for richer pagination control.
132
- */
133
- cursorParam?: string | null
134
- /**
135
- * Path to the next-page cursor on the response. Supports dot notation
136
- * (`'pagination.next.id'`) or array form.
137
- */
138
- nextParam?: string | Array<string> | null
139
- /**
140
- * Path to the previous-page cursor on the response. Supports dot notation
141
- * or array form.
142
- */
143
- previousParam?: string | Array<string> | null
144
- /**
145
- * Initial value for `pageParam` on the first fetch.
146
- *
147
- * @default 0
148
- */
149
- initialPageParam?: unknown
150
- }
151
-
152
- export type Options = {
153
- /**
154
- * Where the generated composables are written and how they are exported.
155
- *
156
- * @default { path: 'hooks', barrel: { type: 'named' } }
157
- */
158
- output?: Output
159
- /**
160
- * Split generated files into subfolders based on the operation's tag.
161
- */
162
- group?: Group
163
- /**
164
- * HTTP client used inside every generated composable. Mirrors a subset of
165
- * `pluginClient` options.
166
- */
167
- client?: ClientImportPath & Pick<PluginClient['options'], 'clientType' | 'dataReturnType' | 'baseURL' | 'bundle' | 'paramsCasing'>
168
- /**
169
- * Skip operations matching at least one entry in the list.
170
- */
171
- exclude?: Array<Exclude>
172
- /**
173
- * Restrict generation to operations matching at least one entry in the list.
174
- */
175
- include?: Array<Include>
176
- /**
177
- * Apply a different options object to operations matching a pattern.
178
- */
179
- override?: Array<Override<ResolvedOptions>>
180
- /**
181
- * Rename parameter properties in the generated composables.
182
- *
183
- * @note Must match the value of `paramsCasing` on `@kubb/plugin-ts`.
184
- */
185
- paramsCasing?: 'camelcase'
186
- /**
187
- * How operation parameters appear in the generated composable signature.
188
- *
189
- * @default 'inline'
190
- */
191
- paramsType?: 'object' | 'inline'
192
- /**
193
- * How URL path parameters are arranged inside the inline argument list.
194
- *
195
- * @default 'inline'
196
- */
197
- pathParamsType?: PluginClient['options']['pathParamsType']
198
- /**
199
- * Enables `useInfiniteQuery` composables for cursor- or page-based pagination.
200
- * Pass an object to configure how the cursor is read; pass `false` to skip.
201
- *
202
- * @default false
203
- */
204
- infinite?: Partial<Infinite> | false
205
- /**
206
- * Custom `queryKey` builder.
207
- */
208
- queryKey?: QueryKey
209
- /**
210
- * Configures query composables. Set to `false` to skip composable generation
211
- * and emit only `queryOptions(...)` helpers.
212
- */
213
- query?: Partial<Query> | false
214
- /**
215
- * Custom `mutationKey` builder.
216
- */
217
- mutationKey?: MutationKey
218
- /**
219
- * Configures mutation composables. Set to `false` to skip mutation generation.
220
- */
221
- mutation?: Partial<Mutation> | false
222
- /**
223
- * Validator applied to response bodies before they reach the caller.
224
- * - `'client'` — no validation.
225
- * - `'zod'` — pipes responses through schemas from `@kubb/plugin-zod`.
226
- */
227
- parser?: PluginClient['options']['parser']
228
- /**
229
- * Override how composable names and file paths are built.
230
- */
231
- resolver?: Partial<ResolverVueQuery> & ThisType<ResolverVueQuery>
232
- /**
233
- * AST visitor applied to each operation node before printing.
234
- */
235
- transformer?: ast.Visitor
236
- /**
237
- * Custom generators that run alongside the built-in Vue Query generators.
238
- */
239
- generators?: Array<Generator<PluginVueQuery>>
240
- }
241
-
242
- type ResolvedOptions = {
243
- output: Output
244
- group: Group | null
245
- exclude: NonNullable<Options['exclude']>
246
- include: Options['include']
247
- override: NonNullable<Options['override']>
248
- client: Pick<PluginClient['options'], 'client' | 'clientType' | 'dataReturnType' | 'importPath' | 'baseURL' | 'bundle' | 'paramsCasing'>
249
- parser: Required<NonNullable<Options['parser']>>
250
- pathParamsType: NonNullable<Options['pathParamsType']>
251
- paramsCasing: Options['paramsCasing']
252
- paramsType: NonNullable<Options['paramsType']>
253
- /**
254
- * Only used for infinite
255
- */
256
- infinite: NonNullable<Infinite> | false
257
- queryKey: QueryKey | null
258
- query: NonNullable<Required<Query>> | false
259
- mutationKey: MutationKey | null
260
- mutation: NonNullable<Required<Mutation>> | false
261
- resolver: ResolverVueQuery
262
- }
263
-
264
- export type PluginVueQuery = PluginFactoryOptions<'plugin-vue-query', Options, ResolvedOptions, ResolverVueQuery>
265
-
266
- declare global {
267
- namespace Kubb {
268
- interface PluginRegistry {
269
- 'plugin-vue-query': PluginVueQuery
270
- }
271
- }
272
- }
package/src/utils.ts DELETED
@@ -1,56 +0,0 @@
1
- export {
2
- buildGroupParam,
3
- buildQueryKeyParams,
4
- resolveHeaderGroupType,
5
- resolveOperationOverrides,
6
- resolvePathParamType,
7
- resolveQueryGroupType,
8
- resolveZodSchemaNames,
9
- } from '@internals/tanstack-query'
10
- export {
11
- buildOperationComments as getComments,
12
- buildRequestConfigType,
13
- getContentTypeInfo,
14
- resolveErrorNames,
15
- resolveStatusCodeNames,
16
- resolveSuccessNames,
17
- } from '@internals/shared'
18
-
19
- import { ast } from '@kubb/core'
20
-
21
- export function printType(typeNode: ast.ParamsTypeNode | undefined): string {
22
- if (!typeNode) return 'unknown'
23
- if (typeNode.variant === 'reference') return typeNode.name
24
- if (typeNode.variant === 'member') return `${typeNode.base}['${typeNode.key}']`
25
- if (typeNode.variant === 'struct') {
26
- const parts = typeNode.properties.map((p) => {
27
- const typeStr = printType(p.type)
28
- const key = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(p.name) ? p.name : JSON.stringify(p.name)
29
- return p.optional ? `${key}?: ${typeStr}` : `${key}: ${typeStr}`
30
- })
31
- return `{ ${parts.join('; ')} }`
32
- }
33
- return 'unknown'
34
- }
35
-
36
- export function wrapWithMaybeRefOrGetter(paramsNode: ast.FunctionParametersNode, skip?: (name: string) => boolean): ast.FunctionParametersNode {
37
- const wrappedParams = paramsNode.params.map((param) => {
38
- if ('kind' in param && (param as ast.ParameterGroupNode).kind === 'ParameterGroup') {
39
- const group = param as ast.ParameterGroupNode
40
- return {
41
- ...group,
42
- properties: group.properties.map((p) => ({
43
- ...p,
44
- type: p.type ? ast.createParamsType({ variant: 'reference', name: `MaybeRefOrGetter<${printType(p.type)}>` }) : p.type,
45
- })),
46
- }
47
- }
48
- const fp = param as ast.FunctionParameterNode
49
- if (skip?.(fp.name)) return fp
50
- return {
51
- ...fp,
52
- type: fp.type ? ast.createParamsType({ variant: 'reference', name: `MaybeRefOrGetter<${printType(fp.type)}>` }) : fp.type,
53
- }
54
- })
55
- return ast.createFunctionParameters({ params: wrappedParams })
56
- }