@kubb/plugin-swr 5.0.0-beta.56 → 5.0.0-beta.73

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/src/types.ts DELETED
@@ -1,194 +0,0 @@
1
- import type { Transformer } from '@internals/tanstack-query'
2
- import type { ast, Exclude, Generator, Group, Include, Output, OutputOptions, Override, PluginFactoryOptions, Resolver } from '@kubb/core'
3
- import type { ClientImportPath, PluginClient } from '@kubb/plugin-client'
4
-
5
- export type { Transformer } from '@internals/tanstack-query'
6
-
7
- /**
8
- * Resolver for SWR that provides naming methods for hook functions.
9
- */
10
- export type ResolverSwr = Resolver & {
11
- /**
12
- * Resolves the base function name for an operation.
13
- *
14
- * @example Resolving base operation names
15
- * `resolver.resolveName('show pet by id') // -> 'showPetById'`
16
- */
17
- resolveName(this: ResolverSwr, name: string): string
18
- /**
19
- * Resolves the output file name for a hook module.
20
- */
21
- resolvePathName(this: ResolverSwr, name: string, type?: 'file' | 'function' | 'type' | 'const'): string
22
- /**
23
- * Resolves a query hook function name.
24
- */
25
- resolveQueryName(this: ResolverSwr, node: ast.OperationNode): string
26
- /**
27
- * Resolves a mutation hook function name.
28
- */
29
- resolveMutationName(this: ResolverSwr, node: ast.OperationNode): string
30
- /**
31
- * Resolves the query options helper name.
32
- */
33
- resolveQueryOptionsName(this: ResolverSwr, node: ast.OperationNode): string
34
- /**
35
- * Resolves the query key helper name.
36
- */
37
- resolveQueryKeyName(this: ResolverSwr, node: ast.OperationNode): string
38
- /**
39
- * Resolves the mutation key helper name.
40
- */
41
- resolveMutationKeyName(this: ResolverSwr, node: ast.OperationNode): string
42
- /**
43
- * Resolves the query key type name.
44
- */
45
- resolveQueryKeyTypeName(this: ResolverSwr, node: ast.OperationNode): string
46
- /**
47
- * Resolves the mutation key type name.
48
- */
49
- resolveMutationKeyTypeName(this: ResolverSwr, node: ast.OperationNode): string
50
- /**
51
- * Resolves the mutation argument type name emitted alongside the mutation hook.
52
- */
53
- resolveMutationArgTypeName(this: ResolverSwr, node: ast.OperationNode): string
54
- /**
55
- * Resolves the client function name generated inline by query hooks.
56
- */
57
- resolveClientName(this: ResolverSwr, node: ast.OperationNode): string
58
- }
59
-
60
- /**
61
- * Customize the queryKey.
62
- */
63
- type QueryKey = Transformer
64
-
65
- /**
66
- * Customize the mutationKey.
67
- */
68
- type MutationKey = Transformer
69
-
70
- type Query = {
71
- /**
72
- * HTTP methods to use for queries.
73
- *
74
- * @default ['get']
75
- */
76
- methods?: Array<string>
77
- /**
78
- * Path to the useSWR hook for useSWR functionality.
79
- * Used as `import useSWR from '${importPath}'`.
80
- * Accepts relative and absolute paths.
81
- * Path is used as-is; relative paths are based on the generated file location.
82
- * @default 'swr'
83
- */
84
- importPath?: string
85
- }
86
-
87
- type Mutation = {
88
- /**
89
- * HTTP methods to use for mutations.
90
- *
91
- * @default ['post', 'put', 'delete', 'patch']
92
- */
93
- methods?: Array<string>
94
- /**
95
- * Path to the useSWRMutation hook for useSWRMutation functionality.
96
- * Used as `import useSWRMutation from '${importPath}'`.
97
- * Accepts relative and absolute paths.
98
- * Path is used as-is; relative paths are based on the generated file location.
99
- * @default 'swr/mutation'
100
- */
101
- importPath?: string
102
- }
103
-
104
- /**
105
- * Where the generated SWR hooks are written and how they are exported, plus the optional `group`
106
- * strategy. The `group` option organizes `output.mode: 'directory'` output into per-tag or per-path subdirectories.
107
- *
108
- * @default { path: 'hooks', barrel: { type: 'named' } }
109
- */
110
- export type Options = OutputOptions & {
111
- client?: ClientImportPath & Pick<PluginClient['options'], 'clientType' | 'dataReturnType' | 'baseURL' | 'bundle' | 'paramsCasing'>
112
- /**
113
- * Tags, operations, or paths to exclude from generation.
114
- */
115
- exclude?: Array<Exclude>
116
- /**
117
- * Tags, operations, or paths to include in generation.
118
- */
119
- include?: Array<Include>
120
- /**
121
- * Override options for specific tags, operations, or paths.
122
- */
123
- override?: Array<Override<ResolvedOptions>>
124
- /**
125
- * Apply casing to parameter names.
126
- */
127
- paramsCasing?: 'camelcase'
128
- /**
129
- * How parameters are passed: grouped in an object or spread inline.
130
- *
131
- * @default 'inline'
132
- */
133
- paramsType?: 'object' | 'inline'
134
- /**
135
- * How path parameters are passed: grouped in an object or spread inline.
136
- *
137
- * @default 'inline'
138
- */
139
- pathParamsType?: PluginClient['options']['pathParamsType']
140
- queryKey?: QueryKey
141
- /**
142
- * Configure useSWR behavior.
143
- */
144
- query?: Partial<Query> | false
145
- mutationKey?: MutationKey
146
- /**
147
- * Configure useSWRMutation behavior.
148
- */
149
- mutation?: Partial<Mutation> | false
150
- /**
151
- * Parser to use for validating response data.
152
- */
153
- parser?: PluginClient['options']['parser']
154
- /**
155
- * Override naming conventions for function names and types.
156
- */
157
- resolver?: Partial<ResolverSwr> & ThisType<ResolverSwr>
158
- /**
159
- * AST visitor to transform generated nodes.
160
- */
161
- transformer?: ast.Visitor
162
- /**
163
- * Additional generators alongside the default generators.
164
- */
165
- generators?: Array<Generator<PluginSwr>>
166
- }
167
-
168
- type ResolvedOptions = {
169
- output: Output
170
- group: Group | undefined
171
- exclude: NonNullable<Options['exclude']>
172
- include: Options['include']
173
- override: NonNullable<Options['override']>
174
- client: Pick<PluginClient['options'], 'client' | 'clientType' | 'dataReturnType' | 'importPath' | 'baseURL' | 'bundle' | 'paramsCasing'>
175
- parser: NonNullable<Options['parser']>
176
- pathParamsType: NonNullable<Options['pathParamsType']>
177
- paramsCasing: Options['paramsCasing']
178
- paramsType: NonNullable<Options['paramsType']>
179
- queryKey: QueryKey | undefined
180
- query: NonNullable<Required<Query>> | false
181
- mutationKey: MutationKey | undefined
182
- mutation: NonNullable<Required<Mutation>> | false
183
- resolver: ResolverSwr
184
- }
185
-
186
- export type PluginSwr = PluginFactoryOptions<'plugin-swr', Options, ResolvedOptions, ResolverSwr>
187
-
188
- declare global {
189
- namespace Kubb {
190
- interface PluginRegistry {
191
- 'plugin-swr': PluginSwr
192
- }
193
- }
194
- }
package/src/utils.ts DELETED
@@ -1,17 +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
- buildStatusUnionType,
14
- getContentTypeInfo,
15
- resolveErrorNames,
16
- resolveStatusCodeNames,
17
- } from '@internals/shared'