import type { Transformer } from '@internals/tanstack-query' import type { Group, Output, PluginFactoryOptions, ResolveNameParams } from '@kubb/core' import type { contentType, HttpMethod, Oas } from '@kubb/oas' import type { ClientImportPath, PluginClient } from '@kubb/plugin-client' import type { Exclude, Include, Override, ResolvePathOptions } from '@kubb/plugin-oas' import type { Generator } from '@kubb/plugin-oas/generators' export type { Transformer } from '@internals/tanstack-query' /** * Customize the queryKey */ type QueryKey = Transformer /** * Customize the mutationKey */ type MutationKey = Transformer type Query = { /** * Define which HttpMethods can be used for queries * @default ['get'] */ methods: Array /** * Path to the useQuery hook for useQuery functionality. * Used as `import { useQuery } from '${importPath}'`. * Accepts relative and absolute paths. * Path is used as-is; relative paths are based on the generated file location. * @default '@tanstack/svelte-query' */ importPath?: string } type Mutation = { /** * Define which HttpMethods can be used for mutations * @default ['post', 'put', 'delete'] */ methods: Array /** * Path to the useQuery hook for useQuery functionality. * Used as `import { useQuery } from '${importPath}'`. * Accepts relative and absolute paths. * Path is used as-is; relative paths are based on the generated file location. * @default '@tanstack/solid-query' */ importPath?: string } /** * @deprecated `@kubb/plugin-solid-query` has no v5 equivalent and is removed in v5. See https://kubb.dev/docs/5.x/migration-guide */ export type Options = { /** * Specify the export location for the files and define the behavior of the output * @default { path: 'hooks', barrelType: 'named' } */ output?: Output /** * Define which contentType should be used. * By default, the first JSON valid mediaType is used */ contentType?: contentType /** * Group the @tanstack/query hooks based on the provided name. */ group?: Group client?: ClientImportPath & Pick /** * Array containing exclude parameters to exclude/skip tags/operations/methods/paths. */ exclude?: Array /** * Array containing include parameters to include tags/operations/methods/paths. */ include?: Array /** * Array containing override parameters to override `options` based on tags/operations/methods/paths. */ override?: Array> /** * How to style your params, by default no casing is applied * - 'camelcase' uses camelcase for the params names */ paramsCasing?: 'camelcase' /** * How to pass your params * - 'object' returns the params and pathParams as an object. * - 'inline' returns the params as comma separated params. * @default 'inline' */ paramsType?: 'object' | 'inline' /** * How to pass your pathParams. * - 'object' returns the pathParams as an object. * - 'inline': returns the pathParams as comma separated params. * @default 'inline' */ pathParamsType?: PluginClient['options']['pathParamsType'] queryKey?: QueryKey /** * Override some useQuery behaviors. */ query?: Partial | false /** * Which parser should be used before returning the data to `@tanstack/query`. * `'zod'` uses `@kubb/plugin-zod` to parse the data. */ mutationKey?: MutationKey /** * Override some useMutation behaviors. */ mutation?: Partial | false parser?: PluginClient['options']['parser'] transformers?: { /** * Customize the names based on the type that is provided by the plugin. */ name?: (name: ResolveNameParams['name'], type?: ResolveNameParams['type']) => string } /** * Define some generators next to the solid-query generators */ generators?: Array> } type ResolvedOptions = { output: Output group: Options['group'] client: Pick parser: Required> paramsCasing: Options['paramsCasing'] paramsType: NonNullable pathParamsType: NonNullable queryKey: QueryKey | undefined query: NonNullable> | false mutationKey: MutationKey | undefined mutation: NonNullable> | false } export type PluginSolidQuery = PluginFactoryOptions<'plugin-solid-query', Options, ResolvedOptions, never, ResolvePathOptions>