@kubb/plugin-swr 3.0.0-alpha.0
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/LICENSE +21 -0
- package/README.md +44 -0
- package/dist/chunk-ECJ346AA.js +542 -0
- package/dist/chunk-ECJ346AA.js.map +1 -0
- package/dist/chunk-H4LHXYRJ.cjs +542 -0
- package/dist/chunk-H4LHXYRJ.cjs.map +1 -0
- package/dist/components.cjs +11 -0
- package/dist/components.cjs.map +1 -0
- package/dist/components.d.cts +7 -0
- package/dist/components.d.ts +7 -0
- package/dist/components.js +11 -0
- package/dist/components.js.map +1 -0
- package/dist/index-Ca8KyrCA.d.cts +304 -0
- package/dist/index-Ca8KyrCA.d.ts +304 -0
- package/dist/index.cjs +180 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +21 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +180 -0
- package/dist/index.js.map +1 -0
- package/package.json +98 -0
- package/src/OperationGenerator.tsx +75 -0
- package/src/components/Mutation.tsx +252 -0
- package/src/components/Query.tsx +290 -0
- package/src/components/QueryOptions.tsx +197 -0
- package/src/components/SchemaType.tsx +59 -0
- package/src/components/__snapshots__/Mutation/Pets.ts +42 -0
- package/src/components/__snapshots__/Query/showPetById.ts +55 -0
- package/src/components/index.ts +3 -0
- package/src/index.ts +15 -0
- package/src/plugin.ts +139 -0
- package/src/types.ts +125 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/components/Mutation.tsx","../src/components/SchemaType.tsx","../src/components/Query.tsx","../src/components/QueryOptions.tsx"],"sourcesContent":["import transformers from '@kubb/core/transformers'\nimport { FunctionParams, URLPath } from '@kubb/core/utils'\nimport { Parser, File, Function, useApp } from '@kubb/react'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { useOperation, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getASTParams, getComments } from '@kubb/plugin-oas/utils'\n\nimport { SchemaType } from './SchemaType.tsx'\n\nimport type { HttpMethod } from '@kubb/oas'\nimport type { ReactNode } from 'react'\nimport type { FileMeta, PluginSwr } from '../types.ts'\n\ntype TemplateProps = {\n /**\n * Name of the function\n */\n name: string\n /**\n * Parameters/options/props that need to be used\n */\n params: string\n /**\n * Generics that needs to be added for TypeScript\n */\n generics?: string\n /**\n * ReturnType(see async for adding Promise type)\n */\n returnType?: string\n /**\n * Options for JSdocs\n */\n JSDoc?: {\n comments: string[]\n }\n hook: {\n name: string\n generics?: string\n }\n client: {\n method: HttpMethod\n generics: string\n withQueryParams: boolean\n withPathParams: boolean\n withData: boolean\n withHeaders: boolean\n path: URLPath\n }\n dataReturnType: NonNullable<PluginSwr['options']['dataReturnType']>\n}\n\nfunction Template({ name, generics, returnType, params, JSDoc, client, hook, dataReturnType }: TemplateProps): ReactNode {\n const clientOptions = [\n `method: \"${client.method}\"`,\n 'url',\n client.withQueryParams ? 'params' : undefined,\n client.withData ? 'data' : undefined,\n client.withHeaders ? 'headers: { ...headers, ...clientOptions.headers }' : undefined,\n '...clientOptions',\n ].filter(Boolean)\n\n const resolvedClientOptions = `${transformers.createIndent(4)}${clientOptions.join(`,\\n${transformers.createIndent(4)}`)}`\n if (client.withQueryParams) {\n return (\n <Function export name={name} generics={generics} returnType={returnType} params={params} JSDoc={JSDoc}>\n {`\n const { mutation: mutationOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {}\n\n const url = ${client.path.template} as const\n return ${hook.name}<${hook.generics}>(\n shouldFetch ? [url, params]: null,\n async (_url${client.withData ? ', { arg: data }' : ''}) => {\n const res = await client<${client.generics}>({\n ${resolvedClientOptions}\n })\n\n return ${dataReturnType === 'data' ? 'res.data' : 'res'}\n },\n mutationOptions\n )\n `}\n </Function>\n )\n }\n return (\n <Function export name={name} generics={generics} returnType={returnType} params={params} JSDoc={JSDoc}>\n {`\n const { mutation: mutationOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {}\n\n const url = ${client.path.template} as const\n return ${hook.name}<${hook.generics}>(\n shouldFetch ? url : null,\n async (_url${client.withData ? ', { arg: data }' : ''}) => {\n const res = await client<${client.generics}>({\n ${resolvedClientOptions}\n })\n\n return ${dataReturnType === 'data' ? 'res.data' : 'res'}\n },\n mutationOptions\n )\n `}\n </Function>\n )\n}\n\nconst defaultTemplates = {\n default: Template,\n} as const\n\ntype Props = {\n factory: {\n name: string\n }\n /**\n * This will make it possible to override the default behaviour.\n */\n Template?: React.ComponentType<TemplateProps>\n}\n\nexport function Mutation({ factory, Template = defaultTemplates.default }: Props): ReactNode {\n const {\n plugin: {\n options: { dataReturnType },\n },\n } = useApp<PluginSwr>()\n const { getSchemas, getName } = useOperationManager()\n const operation = useOperation()\n\n const name = getName(operation, { type: 'function' })\n const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' })\n\n const params = new FunctionParams()\n const client = {\n method: operation.method,\n path: new URLPath(operation.path),\n generics: [`${factory.name}[\"data\"]`, `${factory.name}[\"error\"]`, schemas.request?.name ? `${factory.name}[\"request\"]` : ''].filter(Boolean).join(', '),\n withQueryParams: !!schemas.queryParams?.name,\n withData: !!schemas.request?.name,\n withPathParams: !!schemas.pathParams?.name,\n withHeaders: !!schemas.headerParams?.name,\n }\n\n const resultGenerics = [`${factory.name}[\"response\"]`, `${factory.name}[\"error\"]`]\n\n params.add([\n ...getASTParams(schemas.pathParams, { typed: true }),\n {\n name: 'params',\n type: `${factory.name}['queryParams']`,\n enabled: client.withQueryParams,\n required: false,\n },\n {\n name: 'headers',\n type: `${factory.name}['headerParams']`,\n enabled: client.withHeaders,\n required: false,\n },\n {\n name: 'options',\n required: false,\n type: `{\n mutation?: SWRMutationConfiguration<${resultGenerics.join(', ')}>,\n client?: ${factory.name}['client']['parameters'],\n shouldFetch?: boolean,\n }`,\n default: '{}',\n },\n ])\n\n const hook = {\n name: 'useSWRMutation',\n generics: [...resultGenerics, client.withQueryParams ? '[typeof url, typeof params] | null' : 'typeof url | null'].join(', '),\n }\n\n return (\n <Template\n name={name}\n JSDoc={{ comments: getComments(operation) }}\n client={client}\n hook={hook}\n params={params.toString()}\n returnType={`SWRMutationResponse<${resultGenerics.join(', ')}>`}\n dataReturnType={dataReturnType}\n />\n )\n}\n\ntype FileProps = {\n /**\n * This will make it possible to override the default behaviour.\n */\n templates?: typeof defaultTemplates\n}\n\nMutation.File = function ({ templates = defaultTemplates }: FileProps): ReactNode {\n const {\n plugin: {\n options: {\n extName,\n client: { importPath },\n },\n },\n } = useApp<PluginSwr>()\n\n const { getSchemas, getFile, getName } = useOperationManager()\n const operation = useOperation()\n\n const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' })\n const file = getFile(operation)\n const fileType = getFile(operation, { pluginKey: [pluginTsName] })\n const factoryName = getName(operation, { type: 'type' })\n\n const Template = templates.default\n const factory = {\n name: factoryName,\n }\n\n return (\n <Parser language=\"typescript\">\n <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>\n <File.Import name=\"useSWRMutation\" path=\"swr/mutation\" />\n <File.Import name={['SWRMutationConfiguration', 'SWRMutationResponse']} path=\"swr/mutation\" isTypeOnly />\n <File.Import name={'client'} path={importPath} />\n <File.Import name={['ResponseConfig']} path={importPath} isTypeOnly />\n <File.Import\n extName={extName}\n name={[\n schemas.request?.name,\n schemas.response.name,\n schemas.pathParams?.name,\n schemas.queryParams?.name,\n schemas.headerParams?.name,\n ...(schemas.errors?.map((error) => error.name) || []),\n ].filter(Boolean)}\n root={file.path}\n path={fileType.path}\n isTypeOnly\n />\n\n <File.Source>\n <SchemaType factory={factory} />\n <Mutation Template={Template} factory={factory} />\n </File.Source>\n </File>\n </Parser>\n )\n}\n\nMutation.templates = defaultTemplates\n","import { Type, useApp } from '@kubb/react'\n\nimport { useOperation, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport type { ReactNode } from 'react'\nimport type { PluginSwr } from '../types.ts'\nimport { pluginTsName } from '@kubb/plugin-ts'\n\ntype Props = {\n factory: {\n name: string\n }\n}\n\nexport function SchemaType({ factory }: Props): ReactNode {\n const {\n plugin: {\n options: { dataReturnType },\n },\n } = useApp<PluginSwr>()\n const { getSchemas } = useOperationManager()\n const operation = useOperation()\n\n const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' })\n\n const [TData, TError, TRequest, TPathParams, TQueryParams, THeaderParams, TResponse] = [\n schemas.response.name,\n schemas.errors?.map((item) => item.name).join(' | ') || 'never',\n schemas.request?.name || 'never',\n schemas.pathParams?.name || 'never',\n schemas.queryParams?.name || 'never',\n schemas.headerParams?.name || 'never',\n schemas.response.name,\n ]\n\n const clientType = `${factory.name}Client`\n\n return (\n <>\n <Type name={clientType}>{`typeof client<${TResponse}, ${TError}, ${TRequest}>`}</Type>\n <Type name={factory.name}>\n {`\n {\n data: ${TData}\n error: ${TError}\n request: ${TRequest}\n pathParams: ${TPathParams}\n queryParams: ${TQueryParams}\n headerParams: ${THeaderParams}\n response: ${dataReturnType === 'data' ? TData : `Awaited<ReturnType<${clientType}>>`}\n client: {\n parameters: Partial<Parameters<${clientType}>[0]>\n return: Awaited<ReturnType<${clientType}>>\n }\n }\n `}\n </Type>\n </>\n )\n}\n","import { FunctionParams, URLPath } from '@kubb/core/utils'\nimport { Parser, File, Function, useApp } from '@kubb/react'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { useOperation, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getASTParams, getComments } from '@kubb/plugin-oas/utils'\nimport { pluginZodName } from '@kubb/plugin-zod'\n\nimport { QueryOptions } from './QueryOptions.tsx'\nimport { SchemaType } from './SchemaType.tsx'\n\nimport type { ReactNode } from 'react'\nimport type { FileMeta, PluginSwr } from '../types.ts'\n\ntype TemplateProps = {\n /**\n * Name of the function\n */\n name: string\n /**\n * Parameters/options/props that need to be used\n */\n params: string\n /**\n * Generics that needs to be added for TypeScript\n */\n generics?: string\n /**\n * ReturnType(see async for adding Promise type)\n */\n returnType?: string\n /**\n * Options for JSdocs\n */\n JSDoc?: {\n comments: string[]\n }\n hook: {\n name: string\n generics?: string\n queryOptions: string\n }\n client: {\n path: URLPath\n withQueryParams: boolean\n }\n}\n\nfunction Template({ name, generics, returnType, params, JSDoc, hook, client }: TemplateProps): ReactNode {\n if (client.withQueryParams) {\n return (\n <>\n <Function name={name} export generics={generics} returnType={returnType} params={params} JSDoc={JSDoc}>\n {`\n const { query: queryOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {}\n\n const url = ${client.path.template}\n const query = ${hook.name}<${hook.generics}>(\n shouldFetch ? [url, params]: null,\n {\n ...${hook.queryOptions},\n ...queryOptions\n }\n )\n\n return query\n `}\n </Function>\n </>\n )\n }\n\n return (\n <>\n <Function name={name} export generics={generics} returnType={returnType} params={params} JSDoc={JSDoc}>\n {`\n const { query: queryOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {}\n\n const url = ${client.path.template}\n const query = ${hook.name}<${hook.generics}>(\n shouldFetch ? url : null,\n {\n ...${hook.queryOptions},\n ...queryOptions\n }\n )\n\n return query\n `}\n </Function>\n </>\n )\n}\n\nconst defaultTemplates = {\n default: Template,\n} as const\n\ntype Props = {\n factory: {\n name: string\n }\n /**\n * This will make it possible to override the default behaviour.\n */\n Template?: React.ComponentType<TemplateProps>\n /**\n * This will make it possible to override the default behaviour.\n */\n QueryOptionsTemplate?: React.ComponentType<React.ComponentProps<typeof QueryOptions.templates.default>>\n}\n\nexport function Query({ factory, Template = defaultTemplates.default, QueryOptionsTemplate = QueryOptions.templates.default }: Props): ReactNode {\n const {\n pluginManager,\n plugin: {\n key: pluginKey,\n options: { dataReturnType },\n },\n } = useApp<PluginSwr>()\n\n const operation = useOperation()\n const { getSchemas, getName } = useOperationManager()\n\n const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' })\n const zodSchemas = getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' })\n\n const name = getName(operation, { type: 'function' })\n\n const queryOptionsName = pluginManager.resolveName({\n name: `${factory.name}QueryOptions`,\n pluginKey,\n })\n const generics = new FunctionParams()\n const params = new FunctionParams()\n const queryParams = new FunctionParams()\n const client = {\n method: operation.method,\n path: new URLPath(operation.path),\n withQueryParams: !!schemas.queryParams?.name,\n withData: !!schemas.request?.name,\n withPathParams: !!schemas.pathParams?.name,\n withHeaders: !!schemas.headerParams?.name,\n }\n\n const resultGenerics = ['TData', `${factory.name}[\"error\"]`]\n\n generics.add([{ type: 'TData', default: `${factory.name}[\"response\"]` }])\n\n const queryOptionsGenerics = ['TData']\n\n params.add([\n ...getASTParams(schemas.pathParams, { typed: true }),\n {\n name: 'params',\n type: `${factory.name}['queryParams']`,\n enabled: client.withQueryParams,\n required: false,\n },\n {\n name: 'headers',\n type: `${factory.name}['headerParams']`,\n enabled: client.withHeaders,\n required: false,\n },\n {\n name: 'options',\n required: false,\n type: `{\n query?: SWRConfiguration<${resultGenerics.join(', ')}>,\n client?: ${factory.name}['client']['parameters'],\n shouldFetch?: boolean,\n }`,\n default: '{}',\n },\n ])\n\n queryParams.add([\n ...getASTParams(schemas.pathParams, { typed: false }),\n {\n name: 'params',\n enabled: client.withQueryParams,\n required: false,\n },\n {\n name: 'headers',\n enabled: client.withHeaders,\n required: false,\n },\n {\n name: 'clientOptions',\n required: false,\n },\n ])\n\n const hook = {\n name: 'useSWR',\n generics: [...resultGenerics, client.withQueryParams ? '[typeof url, typeof params] | null' : 'typeof url | null'].join(', '),\n queryOptions: `${queryOptionsName}<${queryOptionsGenerics.join(', ')}>(${queryParams.toString()})`,\n }\n\n return (\n <>\n <QueryOptions factory={factory} Template={QueryOptionsTemplate} dataReturnType={dataReturnType} />\n\n <Template\n name={name}\n generics={generics.toString()}\n JSDoc={{ comments: getComments(operation) }}\n client={client}\n hook={hook}\n params={params.toString()}\n returnType={`SWRResponse<${resultGenerics.join(', ')}>`}\n />\n </>\n )\n}\n\ntype FileProps = {\n /**\n * This will make it possible to override the default behaviour.\n */\n templates?: {\n query: typeof defaultTemplates\n queryOptions: typeof QueryOptions.templates\n }\n}\n\nQuery.File = function ({ templates }: FileProps): ReactNode {\n const {\n pluginManager,\n plugin: {\n options: {\n extName,\n client: { importPath },\n parser,\n },\n },\n } = useApp<PluginSwr>()\n const { getSchemas, getFile, getName } = useOperationManager()\n const operation = useOperation()\n\n const file = getFile(operation)\n const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' })\n const zodSchemas = getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' })\n const fileType = getFile(operation, { pluginKey: [pluginTsName] })\n const fileZodSchemas = getFile(operation, {\n pluginKey: [pluginZodName],\n })\n\n const factoryName = getName(operation, { type: 'type' })\n\n const Template = templates?.query.default || defaultTemplates.default\n const QueryOptionsTemplate = templates?.queryOptions.default || QueryOptions.templates.default\n const factory = {\n name: factoryName,\n }\n\n return (\n <Parser language=\"typescript\">\n <File<FileMeta> baseName={file.baseName} path={file.path} meta={file.meta}>\n {parser === 'zod' && <File.Import extName={extName} name={[zodSchemas.response.name]} root={file.path} path={fileZodSchemas.path} />}\n <File.Import name=\"useSWR\" path=\"swr\" />\n <File.Import name={['SWRConfiguration', 'SWRResponse']} path=\"swr\" isTypeOnly />\n <File.Import name={'client'} path={importPath} />\n <File.Import name={['ResponseConfig']} path={importPath} isTypeOnly />\n <File.Import\n extName={extName}\n name={[\n schemas.request?.name,\n schemas.response.name,\n schemas.pathParams?.name,\n schemas.queryParams?.name,\n schemas.headerParams?.name,\n ...(schemas.statusCodes?.map((item) => item.name) || []),\n ].filter(Boolean)}\n root={file.path}\n path={fileType.path}\n isTypeOnly\n />\n\n <File.Source>\n <SchemaType factory={factory} />\n <Query factory={factory} Template={Template} QueryOptionsTemplate={QueryOptionsTemplate} />\n </File.Source>\n </File>\n </Parser>\n )\n}\n\nQuery.templates = defaultTemplates\n","import transformers from '@kubb/core/transformers'\nimport { FunctionParams, URLPath } from '@kubb/core/utils'\nimport { useOperation, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getASTParams } from '@kubb/plugin-oas/utils'\nimport { Function, useApp } from '@kubb/react'\nimport { pluginZodName } from '@kubb/plugin-zod'\n\nimport type { HttpMethod } from '@kubb/oas'\nimport type { ReactNode } from 'react'\nimport type { PluginSwr } from '../types.ts'\nimport { pluginTsName } from '@kubb/plugin-ts'\n\ntype TemplateProps = {\n /**\n * Name of the function\n */\n name: string\n /**\n * Parameters/options/props that need to be used\n */\n params: string\n /**\n * Generics that needs to be added for TypeScript\n */\n generics?: string\n /**\n * ReturnType(see async for adding Promise type)\n */\n returnType?: string\n /**\n * Options for JSdocs\n */\n JSDoc?: {\n comments: string[]\n }\n client: {\n generics: string\n method: HttpMethod\n path: URLPath\n withQueryParams: boolean\n withPathParams: boolean\n withData: boolean\n withHeaders: boolean\n contentType: string\n }\n dataReturnType: NonNullable<PluginSwr['options']['dataReturnType']>\n parser: string | undefined\n}\n\nfunction Template({ name, params, generics, returnType, JSDoc, client, dataReturnType, parser }: TemplateProps): ReactNode {\n const isFormData = client.contentType === 'multipart/form-data'\n const headers = [\n client.contentType !== 'application/json' ? `'Content-Type': '${client.contentType}'` : undefined,\n client.withHeaders ? '...headers' : undefined,\n ]\n .filter(Boolean)\n .join(', ')\n\n const clientOptions = [\n `method: \"${client.method}\"`,\n `url: ${client.path.template}`,\n client.withQueryParams ? 'params' : undefined,\n client.withData && !isFormData ? 'data' : undefined,\n client.withData && isFormData ? 'data: formData' : undefined,\n headers.length ? `headers: { ${headers}, ...options.headers }` : undefined,\n '...options',\n ].filter(Boolean)\n\n const resolvedClientOptions = `${transformers.createIndent(4)}${clientOptions.join(`,\\n${transformers.createIndent(4)}`)}`\n\n let returnRes = parser ? `return ${parser}(res.data)` : 'return res.data'\n\n if (dataReturnType === 'full') {\n returnRes = parser ? `return {...res, data: ${parser}(res.data)}` : 'return res'\n }\n\n const formData = isFormData\n ? `\n const formData = new FormData()\n if(data) {\n Object.keys(data).forEach((key) => {\n const value = data[key];\n if (typeof key === \"string\" && (typeof value === \"string\" || value instanceof Blob)) {\n formData.append(key, value);\n }\n })\n }\n `\n : undefined\n\n return (\n <Function name={name} export generics={generics} returnType={returnType} params={params} JSDoc={JSDoc}>\n {`\n return {\n fetcher: async () => {\n ${formData || ''}\n const res = await client<${client.generics}>({\n ${resolvedClientOptions}\n })\n\n ${returnRes}\n },\n }\n\n `}\n </Function>\n )\n}\n\nconst defaultTemplates = {\n default: Template,\n} as const\n\ntype Props = {\n factory: {\n name: string\n }\n dataReturnType: NonNullable<PluginSwr['options']['dataReturnType']>\n /**\n * This will make it possible to override the default behaviour.\n */\n Template?: React.ComponentType<TemplateProps>\n}\n\nexport function QueryOptions({ factory, dataReturnType, Template = defaultTemplates.default }: Props): ReactNode {\n const {\n pluginManager,\n plugin: {\n key: pluginKey,\n options: { parser },\n },\n } = useApp<PluginSwr>()\n const { getSchemas } = useOperationManager()\n const operation = useOperation()\n\n const schemas = getSchemas(operation, { pluginKey: [pluginTsName], type: 'type' })\n const zodSchemas = getSchemas(operation, { pluginKey: [pluginZodName], type: 'function' })\n const name = pluginManager.resolveName({\n name: `${factory.name}QueryOptions`,\n pluginKey,\n })\n const contentType = operation.getContentType()\n\n const generics = new FunctionParams()\n const params = new FunctionParams()\n\n const clientGenerics = ['TData', `${factory.name}['error']`]\n const resultGenerics = ['TData', `${factory.name}['error']`]\n\n generics.add([{ type: 'TData', default: `${factory.name}['response']` }])\n\n params.add([\n ...getASTParams(schemas.pathParams, { typed: true }),\n {\n name: 'params',\n type: `${factory.name}['queryParams']`,\n enabled: !!schemas.queryParams?.name,\n required: false,\n },\n {\n name: 'headers',\n type: `${factory.name}['headerParams']`,\n enabled: !!schemas.headerParams?.name,\n required: false,\n },\n {\n name: 'options',\n type: `${factory.name}['client']['parameters']`,\n default: '{}',\n },\n ])\n\n const client = {\n withQueryParams: !!schemas.queryParams?.name,\n withData: !!schemas.request?.name,\n withPathParams: !!schemas.pathParams?.name,\n withHeaders: !!schemas.headerParams?.name,\n method: operation.method,\n path: new URLPath(operation.path),\n generics: clientGenerics.join(', '),\n contentType,\n }\n\n return (\n <Template\n name={name}\n params={params.toString()}\n generics={generics.toString()}\n returnType={`SWRConfiguration<${resultGenerics.join(', ')}>`}\n client={client}\n dataReturnType={dataReturnType}\n parser={parser === 'zod' ? `${zodSchemas.response.name}.parse` : undefined}\n />\n )\n}\n\nQueryOptions.templates = defaultTemplates\n"],"mappings":";AAAA,OAAO,kBAAkB;AACzB,SAAS,gBAAgB,eAAe;AACxC,SAAS,QAAQ,MAAM,UAAU,UAAAA,eAAc;AAC/C,SAAS,gBAAAC,qBAAoB;AAC7B,SAAS,gBAAAC,eAAc,uBAAAC,4BAA2B;AAClD,SAAS,cAAc,mBAAmB;;;ACL1C,SAAS,MAAM,cAAc;AAE7B,SAAS,cAAc,2BAA2B;AAGlD,SAAS,oBAAoB;AAgCzB,mBACE,KADF;AAxBG,SAAS,WAAW,EAAE,QAAQ,GAAqB;AACxD,QAAM;AAAA,IACJ,QAAQ;AAAA,MACN,SAAS,EAAE,eAAe;AAAA,IAC5B;AAAA,EACF,IAAI,OAAkB;AACtB,QAAM,EAAE,WAAW,IAAI,oBAAoB;AAC3C,QAAM,YAAY,aAAa;AAE/B,QAAM,UAAU,WAAW,WAAW,EAAE,WAAW,CAAC,YAAY,GAAG,MAAM,OAAO,CAAC;AAEjF,QAAM,CAAC,OAAO,QAAQ,UAAU,aAAa,cAAc,eAAe,SAAS,IAAI;AAAA,IACrF,QAAQ,SAAS;AAAA,IACjB,QAAQ,QAAQ,IAAI,CAAC,SAAS,KAAK,IAAI,EAAE,KAAK,KAAK,KAAK;AAAA,IACxD,QAAQ,SAAS,QAAQ;AAAA,IACzB,QAAQ,YAAY,QAAQ;AAAA,IAC5B,QAAQ,aAAa,QAAQ;AAAA,IAC7B,QAAQ,cAAc,QAAQ;AAAA,IAC9B,QAAQ,SAAS;AAAA,EACnB;AAEA,QAAM,aAAa,GAAG,QAAQ,IAAI;AAElC,SACE,iCACE;AAAA,wBAAC,QAAK,MAAM,YAAa,2BAAiB,SAAS,KAAK,MAAM,KAAK,QAAQ,KAAI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AAC,SAAS,KAAK,IAAI,KAAK,CAAC;AAAA,QACxD,EAAE,OAAO,OAAO;AAAA,QAChB,MAAM,KAAK;AAAA,QACX,MAAM,SAAS;AAAA,QACf,YAAU;AAAA;AAAA,IACZ;AAAA,IAEA,gBAAAd,MAACc,MAAK,QAAL,EACC;AAAA,sBAAAf,KAAC,cAAW,SAAkB;AAAA,MAC9B,gBAAAA,KAAC,SAAM,SAAkB,UAAUE,WAAU,sBAA4C;AAAA,OAC3F;AAAA,KACF,GACF;AAEJ;AAEA,MAAM,YAAYE;","names":["useApp","pluginTsName","useOperation","useOperationManager","jsx","jsxs","Template","useApp","useOperationManager","useOperation","pluginTsName","FunctionParams","URLPath","Parser","File","Function","useApp","pluginTsName","useOperation","useOperationManager","getASTParams","getComments","pluginZodName","transformers","FunctionParams","URLPath","useOperation","useOperationManager","getASTParams","Function","useApp","pluginTsName","jsx","Template","defaultTemplates","Fragment","jsx","jsxs","Template","Function","defaultTemplates","useApp","useOperation","useOperationManager","pluginTsName","pluginZodName","FunctionParams","URLPath","getASTParams","getComments","Parser","File"]}
|
|
@@ -0,0 +1,542 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }// src/components/Mutation.tsx
|
|
2
|
+
var _transformers = require('@kubb/core/transformers'); var _transformers2 = _interopRequireDefault(_transformers);
|
|
3
|
+
var _utils = require('@kubb/core/utils');
|
|
4
|
+
var _react = require('@kubb/react');
|
|
5
|
+
var _plugints = require('@kubb/plugin-ts');
|
|
6
|
+
var _hooks = require('@kubb/plugin-oas/hooks');
|
|
7
|
+
var _utils3 = require('@kubb/plugin-oas/utils');
|
|
8
|
+
|
|
9
|
+
// src/components/SchemaType.tsx
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
var _jsxruntime = require('@kubb/react/jsx-runtime');
|
|
14
|
+
function SchemaType({ factory }) {
|
|
15
|
+
const {
|
|
16
|
+
plugin: {
|
|
17
|
+
options: { dataReturnType }
|
|
18
|
+
}
|
|
19
|
+
} = _react.useApp.call(void 0, );
|
|
20
|
+
const { getSchemas } = _hooks.useOperationManager.call(void 0, );
|
|
21
|
+
const operation = _hooks.useOperation.call(void 0, );
|
|
22
|
+
const schemas = getSchemas(operation, { pluginKey: [_plugints.pluginTsName], type: "type" });
|
|
23
|
+
const [TData, TError, TRequest, TPathParams, TQueryParams, THeaderParams, TResponse] = [
|
|
24
|
+
schemas.response.name,
|
|
25
|
+
_optionalChain([schemas, 'access', _ => _.errors, 'optionalAccess', _2 => _2.map, 'call', _3 => _3((item) => item.name), 'access', _4 => _4.join, 'call', _5 => _5(" | ")]) || "never",
|
|
26
|
+
_optionalChain([schemas, 'access', _6 => _6.request, 'optionalAccess', _7 => _7.name]) || "never",
|
|
27
|
+
_optionalChain([schemas, 'access', _8 => _8.pathParams, 'optionalAccess', _9 => _9.name]) || "never",
|
|
28
|
+
_optionalChain([schemas, 'access', _10 => _10.queryParams, 'optionalAccess', _11 => _11.name]) || "never",
|
|
29
|
+
_optionalChain([schemas, 'access', _12 => _12.headerParams, 'optionalAccess', _13 => _13.name]) || "never",
|
|
30
|
+
schemas.response.name
|
|
31
|
+
];
|
|
32
|
+
const clientType = `${factory.name}Client`;
|
|
33
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
34
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Type, { name: clientType, children: `typeof client<${TResponse}, ${TError}, ${TRequest}>` }),
|
|
35
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Type, { name: factory.name, children: `
|
|
36
|
+
{
|
|
37
|
+
data: ${TData}
|
|
38
|
+
error: ${TError}
|
|
39
|
+
request: ${TRequest}
|
|
40
|
+
pathParams: ${TPathParams}
|
|
41
|
+
queryParams: ${TQueryParams}
|
|
42
|
+
headerParams: ${THeaderParams}
|
|
43
|
+
response: ${dataReturnType === "data" ? TData : `Awaited<ReturnType<${clientType}>>`}
|
|
44
|
+
client: {
|
|
45
|
+
parameters: Partial<Parameters<${clientType}>[0]>
|
|
46
|
+
return: Awaited<ReturnType<${clientType}>>
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
` })
|
|
50
|
+
] });
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// src/components/Mutation.tsx
|
|
54
|
+
|
|
55
|
+
function Template({ name, generics, returnType, params, JSDoc, client, hook, dataReturnType }) {
|
|
56
|
+
const clientOptions = [
|
|
57
|
+
`method: "${client.method}"`,
|
|
58
|
+
"url",
|
|
59
|
+
client.withQueryParams ? "params" : void 0,
|
|
60
|
+
client.withData ? "data" : void 0,
|
|
61
|
+
client.withHeaders ? "headers: { ...headers, ...clientOptions.headers }" : void 0,
|
|
62
|
+
"...clientOptions"
|
|
63
|
+
].filter(Boolean);
|
|
64
|
+
const resolvedClientOptions = `${_transformers2.default.createIndent(4)}${clientOptions.join(`,
|
|
65
|
+
${_transformers2.default.createIndent(4)}`)}`;
|
|
66
|
+
if (client.withQueryParams) {
|
|
67
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Function, { export: true, name, generics, returnType, params, JSDoc, children: `
|
|
68
|
+
const { mutation: mutationOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {}
|
|
69
|
+
|
|
70
|
+
const url = ${client.path.template} as const
|
|
71
|
+
return ${hook.name}<${hook.generics}>(
|
|
72
|
+
shouldFetch ? [url, params]: null,
|
|
73
|
+
async (_url${client.withData ? ", { arg: data }" : ""}) => {
|
|
74
|
+
const res = await client<${client.generics}>({
|
|
75
|
+
${resolvedClientOptions}
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
return ${dataReturnType === "data" ? "res.data" : "res"}
|
|
79
|
+
},
|
|
80
|
+
mutationOptions
|
|
81
|
+
)
|
|
82
|
+
` });
|
|
83
|
+
}
|
|
84
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Function, { export: true, name, generics, returnType, params, JSDoc, children: `
|
|
85
|
+
const { mutation: mutationOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {}
|
|
86
|
+
|
|
87
|
+
const url = ${client.path.template} as const
|
|
88
|
+
return ${hook.name}<${hook.generics}>(
|
|
89
|
+
shouldFetch ? url : null,
|
|
90
|
+
async (_url${client.withData ? ", { arg: data }" : ""}) => {
|
|
91
|
+
const res = await client<${client.generics}>({
|
|
92
|
+
${resolvedClientOptions}
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
return ${dataReturnType === "data" ? "res.data" : "res"}
|
|
96
|
+
},
|
|
97
|
+
mutationOptions
|
|
98
|
+
)
|
|
99
|
+
` });
|
|
100
|
+
}
|
|
101
|
+
var defaultTemplates = {
|
|
102
|
+
default: Template
|
|
103
|
+
};
|
|
104
|
+
function Mutation({ factory, Template: Template4 = defaultTemplates.default }) {
|
|
105
|
+
const {
|
|
106
|
+
plugin: {
|
|
107
|
+
options: { dataReturnType }
|
|
108
|
+
}
|
|
109
|
+
} = _react.useApp.call(void 0, );
|
|
110
|
+
const { getSchemas, getName } = _hooks.useOperationManager.call(void 0, );
|
|
111
|
+
const operation = _hooks.useOperation.call(void 0, );
|
|
112
|
+
const name = getName(operation, { type: "function" });
|
|
113
|
+
const schemas = getSchemas(operation, { pluginKey: [_plugints.pluginTsName], type: "type" });
|
|
114
|
+
const params = new (0, _utils.FunctionParams)();
|
|
115
|
+
const client = {
|
|
116
|
+
method: operation.method,
|
|
117
|
+
path: new (0, _utils.URLPath)(operation.path),
|
|
118
|
+
generics: [`${factory.name}["data"]`, `${factory.name}["error"]`, _optionalChain([schemas, 'access', _14 => _14.request, 'optionalAccess', _15 => _15.name]) ? `${factory.name}["request"]` : ""].filter(Boolean).join(", "),
|
|
119
|
+
withQueryParams: !!_optionalChain([schemas, 'access', _16 => _16.queryParams, 'optionalAccess', _17 => _17.name]),
|
|
120
|
+
withData: !!_optionalChain([schemas, 'access', _18 => _18.request, 'optionalAccess', _19 => _19.name]),
|
|
121
|
+
withPathParams: !!_optionalChain([schemas, 'access', _20 => _20.pathParams, 'optionalAccess', _21 => _21.name]),
|
|
122
|
+
withHeaders: !!_optionalChain([schemas, 'access', _22 => _22.headerParams, 'optionalAccess', _23 => _23.name])
|
|
123
|
+
};
|
|
124
|
+
const resultGenerics = [`${factory.name}["response"]`, `${factory.name}["error"]`];
|
|
125
|
+
params.add([
|
|
126
|
+
..._utils3.getASTParams.call(void 0, schemas.pathParams, { typed: true }),
|
|
127
|
+
{
|
|
128
|
+
name: "params",
|
|
129
|
+
type: `${factory.name}['queryParams']`,
|
|
130
|
+
enabled: client.withQueryParams,
|
|
131
|
+
required: false
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
name: "headers",
|
|
135
|
+
type: `${factory.name}['headerParams']`,
|
|
136
|
+
enabled: client.withHeaders,
|
|
137
|
+
required: false
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
name: "options",
|
|
141
|
+
required: false,
|
|
142
|
+
type: `{
|
|
143
|
+
mutation?: SWRMutationConfiguration<${resultGenerics.join(", ")}>,
|
|
144
|
+
client?: ${factory.name}['client']['parameters'],
|
|
145
|
+
shouldFetch?: boolean,
|
|
146
|
+
}`,
|
|
147
|
+
default: "{}"
|
|
148
|
+
}
|
|
149
|
+
]);
|
|
150
|
+
const hook = {
|
|
151
|
+
name: "useSWRMutation",
|
|
152
|
+
generics: [...resultGenerics, client.withQueryParams ? "[typeof url, typeof params] | null" : "typeof url | null"].join(", ")
|
|
153
|
+
};
|
|
154
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
155
|
+
Template4,
|
|
156
|
+
{
|
|
157
|
+
name,
|
|
158
|
+
JSDoc: { comments: _utils3.getComments.call(void 0, operation) },
|
|
159
|
+
client,
|
|
160
|
+
hook,
|
|
161
|
+
params: params.toString(),
|
|
162
|
+
returnType: `SWRMutationResponse<${resultGenerics.join(", ")}>`,
|
|
163
|
+
dataReturnType
|
|
164
|
+
}
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
Mutation.File = function({ templates = defaultTemplates }) {
|
|
168
|
+
const {
|
|
169
|
+
plugin: {
|
|
170
|
+
options: {
|
|
171
|
+
extName,
|
|
172
|
+
client: { importPath }
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
} = _react.useApp.call(void 0, );
|
|
176
|
+
const { getSchemas, getFile, getName } = _hooks.useOperationManager.call(void 0, );
|
|
177
|
+
const operation = _hooks.useOperation.call(void 0, );
|
|
178
|
+
const schemas = getSchemas(operation, { pluginKey: [_plugints.pluginTsName], type: "type" });
|
|
179
|
+
const file = getFile(operation);
|
|
180
|
+
const fileType = getFile(operation, { pluginKey: [_plugints.pluginTsName] });
|
|
181
|
+
const factoryName = getName(operation, { type: "type" });
|
|
182
|
+
const Template4 = templates.default;
|
|
183
|
+
const factory = {
|
|
184
|
+
name: factoryName
|
|
185
|
+
};
|
|
186
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Parser, { language: "typescript", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react.File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
|
|
187
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: "useSWRMutation", path: "swr/mutation" }),
|
|
188
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: ["SWRMutationConfiguration", "SWRMutationResponse"], path: "swr/mutation", isTypeOnly: true }),
|
|
189
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: "client", path: importPath }),
|
|
190
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: ["ResponseConfig"], path: importPath, isTypeOnly: true }),
|
|
191
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
192
|
+
_react.File.Import,
|
|
193
|
+
{
|
|
194
|
+
extName,
|
|
195
|
+
name: [
|
|
196
|
+
_optionalChain([schemas, 'access', _24 => _24.request, 'optionalAccess', _25 => _25.name]),
|
|
197
|
+
schemas.response.name,
|
|
198
|
+
_optionalChain([schemas, 'access', _26 => _26.pathParams, 'optionalAccess', _27 => _27.name]),
|
|
199
|
+
_optionalChain([schemas, 'access', _28 => _28.queryParams, 'optionalAccess', _29 => _29.name]),
|
|
200
|
+
_optionalChain([schemas, 'access', _30 => _30.headerParams, 'optionalAccess', _31 => _31.name]),
|
|
201
|
+
..._optionalChain([schemas, 'access', _32 => _32.errors, 'optionalAccess', _33 => _33.map, 'call', _34 => _34((error) => error.name)]) || []
|
|
202
|
+
].filter(Boolean),
|
|
203
|
+
root: file.path,
|
|
204
|
+
path: fileType.path,
|
|
205
|
+
isTypeOnly: true
|
|
206
|
+
}
|
|
207
|
+
),
|
|
208
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react.File.Source, { children: [
|
|
209
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, SchemaType, { factory }),
|
|
210
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Mutation, { Template: Template4, factory })
|
|
211
|
+
] })
|
|
212
|
+
] }) });
|
|
213
|
+
};
|
|
214
|
+
Mutation.templates = defaultTemplates;
|
|
215
|
+
|
|
216
|
+
// src/components/Query.tsx
|
|
217
|
+
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
var _pluginzod = require('@kubb/plugin-zod');
|
|
223
|
+
|
|
224
|
+
// src/components/QueryOptions.tsx
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
function Template2({ name, params, generics, returnType, JSDoc, client, dataReturnType, parser }) {
|
|
234
|
+
const isFormData = client.contentType === "multipart/form-data";
|
|
235
|
+
const headers = [
|
|
236
|
+
client.contentType !== "application/json" ? `'Content-Type': '${client.contentType}'` : void 0,
|
|
237
|
+
client.withHeaders ? "...headers" : void 0
|
|
238
|
+
].filter(Boolean).join(", ");
|
|
239
|
+
const clientOptions = [
|
|
240
|
+
`method: "${client.method}"`,
|
|
241
|
+
`url: ${client.path.template}`,
|
|
242
|
+
client.withQueryParams ? "params" : void 0,
|
|
243
|
+
client.withData && !isFormData ? "data" : void 0,
|
|
244
|
+
client.withData && isFormData ? "data: formData" : void 0,
|
|
245
|
+
headers.length ? `headers: { ${headers}, ...options.headers }` : void 0,
|
|
246
|
+
"...options"
|
|
247
|
+
].filter(Boolean);
|
|
248
|
+
const resolvedClientOptions = `${_transformers2.default.createIndent(4)}${clientOptions.join(`,
|
|
249
|
+
${_transformers2.default.createIndent(4)}`)}`;
|
|
250
|
+
let returnRes = parser ? `return ${parser}(res.data)` : "return res.data";
|
|
251
|
+
if (dataReturnType === "full") {
|
|
252
|
+
returnRes = parser ? `return {...res, data: ${parser}(res.data)}` : "return res";
|
|
253
|
+
}
|
|
254
|
+
const formData = isFormData ? `
|
|
255
|
+
const formData = new FormData()
|
|
256
|
+
if(data) {
|
|
257
|
+
Object.keys(data).forEach((key) => {
|
|
258
|
+
const value = data[key];
|
|
259
|
+
if (typeof key === "string" && (typeof value === "string" || value instanceof Blob)) {
|
|
260
|
+
formData.append(key, value);
|
|
261
|
+
}
|
|
262
|
+
})
|
|
263
|
+
}
|
|
264
|
+
` : void 0;
|
|
265
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Function, { name, export: true, generics, returnType, params, JSDoc, children: `
|
|
266
|
+
return {
|
|
267
|
+
fetcher: async () => {
|
|
268
|
+
${formData || ""}
|
|
269
|
+
const res = await client<${client.generics}>({
|
|
270
|
+
${resolvedClientOptions}
|
|
271
|
+
})
|
|
272
|
+
|
|
273
|
+
${returnRes}
|
|
274
|
+
},
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
` });
|
|
278
|
+
}
|
|
279
|
+
var defaultTemplates2 = {
|
|
280
|
+
default: Template2
|
|
281
|
+
};
|
|
282
|
+
function QueryOptions({ factory, dataReturnType, Template: Template4 = defaultTemplates2.default }) {
|
|
283
|
+
const {
|
|
284
|
+
pluginManager,
|
|
285
|
+
plugin: {
|
|
286
|
+
key: pluginKey,
|
|
287
|
+
options: { parser }
|
|
288
|
+
}
|
|
289
|
+
} = _react.useApp.call(void 0, );
|
|
290
|
+
const { getSchemas } = _hooks.useOperationManager.call(void 0, );
|
|
291
|
+
const operation = _hooks.useOperation.call(void 0, );
|
|
292
|
+
const schemas = getSchemas(operation, { pluginKey: [_plugints.pluginTsName], type: "type" });
|
|
293
|
+
const zodSchemas = getSchemas(operation, { pluginKey: [_pluginzod.pluginZodName], type: "function" });
|
|
294
|
+
const name = pluginManager.resolveName({
|
|
295
|
+
name: `${factory.name}QueryOptions`,
|
|
296
|
+
pluginKey
|
|
297
|
+
});
|
|
298
|
+
const contentType = operation.getContentType();
|
|
299
|
+
const generics = new (0, _utils.FunctionParams)();
|
|
300
|
+
const params = new (0, _utils.FunctionParams)();
|
|
301
|
+
const clientGenerics = ["TData", `${factory.name}['error']`];
|
|
302
|
+
const resultGenerics = ["TData", `${factory.name}['error']`];
|
|
303
|
+
generics.add([{ type: "TData", default: `${factory.name}['response']` }]);
|
|
304
|
+
params.add([
|
|
305
|
+
..._utils3.getASTParams.call(void 0, schemas.pathParams, { typed: true }),
|
|
306
|
+
{
|
|
307
|
+
name: "params",
|
|
308
|
+
type: `${factory.name}['queryParams']`,
|
|
309
|
+
enabled: !!_optionalChain([schemas, 'access', _35 => _35.queryParams, 'optionalAccess', _36 => _36.name]),
|
|
310
|
+
required: false
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
name: "headers",
|
|
314
|
+
type: `${factory.name}['headerParams']`,
|
|
315
|
+
enabled: !!_optionalChain([schemas, 'access', _37 => _37.headerParams, 'optionalAccess', _38 => _38.name]),
|
|
316
|
+
required: false
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
name: "options",
|
|
320
|
+
type: `${factory.name}['client']['parameters']`,
|
|
321
|
+
default: "{}"
|
|
322
|
+
}
|
|
323
|
+
]);
|
|
324
|
+
const client = {
|
|
325
|
+
withQueryParams: !!_optionalChain([schemas, 'access', _39 => _39.queryParams, 'optionalAccess', _40 => _40.name]),
|
|
326
|
+
withData: !!_optionalChain([schemas, 'access', _41 => _41.request, 'optionalAccess', _42 => _42.name]),
|
|
327
|
+
withPathParams: !!_optionalChain([schemas, 'access', _43 => _43.pathParams, 'optionalAccess', _44 => _44.name]),
|
|
328
|
+
withHeaders: !!_optionalChain([schemas, 'access', _45 => _45.headerParams, 'optionalAccess', _46 => _46.name]),
|
|
329
|
+
method: operation.method,
|
|
330
|
+
path: new (0, _utils.URLPath)(operation.path),
|
|
331
|
+
generics: clientGenerics.join(", "),
|
|
332
|
+
contentType
|
|
333
|
+
};
|
|
334
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
335
|
+
Template4,
|
|
336
|
+
{
|
|
337
|
+
name,
|
|
338
|
+
params: params.toString(),
|
|
339
|
+
generics: generics.toString(),
|
|
340
|
+
returnType: `SWRConfiguration<${resultGenerics.join(", ")}>`,
|
|
341
|
+
client,
|
|
342
|
+
dataReturnType,
|
|
343
|
+
parser: parser === "zod" ? `${zodSchemas.response.name}.parse` : void 0
|
|
344
|
+
}
|
|
345
|
+
);
|
|
346
|
+
}
|
|
347
|
+
QueryOptions.templates = defaultTemplates2;
|
|
348
|
+
|
|
349
|
+
// src/components/Query.tsx
|
|
350
|
+
|
|
351
|
+
function Template3({ name, generics, returnType, params, JSDoc, hook, client }) {
|
|
352
|
+
if (client.withQueryParams) {
|
|
353
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Function, { name, export: true, generics, returnType, params, JSDoc, children: `
|
|
354
|
+
const { query: queryOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {}
|
|
355
|
+
|
|
356
|
+
const url = ${client.path.template}
|
|
357
|
+
const query = ${hook.name}<${hook.generics}>(
|
|
358
|
+
shouldFetch ? [url, params]: null,
|
|
359
|
+
{
|
|
360
|
+
...${hook.queryOptions},
|
|
361
|
+
...queryOptions
|
|
362
|
+
}
|
|
363
|
+
)
|
|
364
|
+
|
|
365
|
+
return query
|
|
366
|
+
` }) });
|
|
367
|
+
}
|
|
368
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _jsxruntime.Fragment, { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Function, { name, export: true, generics, returnType, params, JSDoc, children: `
|
|
369
|
+
const { query: queryOptions, client: clientOptions = {}, shouldFetch = true } = options ?? {}
|
|
370
|
+
|
|
371
|
+
const url = ${client.path.template}
|
|
372
|
+
const query = ${hook.name}<${hook.generics}>(
|
|
373
|
+
shouldFetch ? url : null,
|
|
374
|
+
{
|
|
375
|
+
...${hook.queryOptions},
|
|
376
|
+
...queryOptions
|
|
377
|
+
}
|
|
378
|
+
)
|
|
379
|
+
|
|
380
|
+
return query
|
|
381
|
+
` }) });
|
|
382
|
+
}
|
|
383
|
+
var defaultTemplates3 = {
|
|
384
|
+
default: Template3
|
|
385
|
+
};
|
|
386
|
+
function Query({ factory, Template: Template4 = defaultTemplates3.default, QueryOptionsTemplate = QueryOptions.templates.default }) {
|
|
387
|
+
const {
|
|
388
|
+
pluginManager,
|
|
389
|
+
plugin: {
|
|
390
|
+
key: pluginKey,
|
|
391
|
+
options: { dataReturnType }
|
|
392
|
+
}
|
|
393
|
+
} = _react.useApp.call(void 0, );
|
|
394
|
+
const operation = _hooks.useOperation.call(void 0, );
|
|
395
|
+
const { getSchemas, getName } = _hooks.useOperationManager.call(void 0, );
|
|
396
|
+
const schemas = getSchemas(operation, { pluginKey: [_plugints.pluginTsName], type: "type" });
|
|
397
|
+
const zodSchemas = getSchemas(operation, { pluginKey: [_pluginzod.pluginZodName], type: "function" });
|
|
398
|
+
const name = getName(operation, { type: "function" });
|
|
399
|
+
const queryOptionsName = pluginManager.resolveName({
|
|
400
|
+
name: `${factory.name}QueryOptions`,
|
|
401
|
+
pluginKey
|
|
402
|
+
});
|
|
403
|
+
const generics = new (0, _utils.FunctionParams)();
|
|
404
|
+
const params = new (0, _utils.FunctionParams)();
|
|
405
|
+
const queryParams = new (0, _utils.FunctionParams)();
|
|
406
|
+
const client = {
|
|
407
|
+
method: operation.method,
|
|
408
|
+
path: new (0, _utils.URLPath)(operation.path),
|
|
409
|
+
withQueryParams: !!_optionalChain([schemas, 'access', _47 => _47.queryParams, 'optionalAccess', _48 => _48.name]),
|
|
410
|
+
withData: !!_optionalChain([schemas, 'access', _49 => _49.request, 'optionalAccess', _50 => _50.name]),
|
|
411
|
+
withPathParams: !!_optionalChain([schemas, 'access', _51 => _51.pathParams, 'optionalAccess', _52 => _52.name]),
|
|
412
|
+
withHeaders: !!_optionalChain([schemas, 'access', _53 => _53.headerParams, 'optionalAccess', _54 => _54.name])
|
|
413
|
+
};
|
|
414
|
+
const resultGenerics = ["TData", `${factory.name}["error"]`];
|
|
415
|
+
generics.add([{ type: "TData", default: `${factory.name}["response"]` }]);
|
|
416
|
+
const queryOptionsGenerics = ["TData"];
|
|
417
|
+
params.add([
|
|
418
|
+
..._utils3.getASTParams.call(void 0, schemas.pathParams, { typed: true }),
|
|
419
|
+
{
|
|
420
|
+
name: "params",
|
|
421
|
+
type: `${factory.name}['queryParams']`,
|
|
422
|
+
enabled: client.withQueryParams,
|
|
423
|
+
required: false
|
|
424
|
+
},
|
|
425
|
+
{
|
|
426
|
+
name: "headers",
|
|
427
|
+
type: `${factory.name}['headerParams']`,
|
|
428
|
+
enabled: client.withHeaders,
|
|
429
|
+
required: false
|
|
430
|
+
},
|
|
431
|
+
{
|
|
432
|
+
name: "options",
|
|
433
|
+
required: false,
|
|
434
|
+
type: `{
|
|
435
|
+
query?: SWRConfiguration<${resultGenerics.join(", ")}>,
|
|
436
|
+
client?: ${factory.name}['client']['parameters'],
|
|
437
|
+
shouldFetch?: boolean,
|
|
438
|
+
}`,
|
|
439
|
+
default: "{}"
|
|
440
|
+
}
|
|
441
|
+
]);
|
|
442
|
+
queryParams.add([
|
|
443
|
+
..._utils3.getASTParams.call(void 0, schemas.pathParams, { typed: false }),
|
|
444
|
+
{
|
|
445
|
+
name: "params",
|
|
446
|
+
enabled: client.withQueryParams,
|
|
447
|
+
required: false
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
name: "headers",
|
|
451
|
+
enabled: client.withHeaders,
|
|
452
|
+
required: false
|
|
453
|
+
},
|
|
454
|
+
{
|
|
455
|
+
name: "clientOptions",
|
|
456
|
+
required: false
|
|
457
|
+
}
|
|
458
|
+
]);
|
|
459
|
+
const hook = {
|
|
460
|
+
name: "useSWR",
|
|
461
|
+
generics: [...resultGenerics, client.withQueryParams ? "[typeof url, typeof params] | null" : "typeof url | null"].join(", "),
|
|
462
|
+
queryOptions: `${queryOptionsName}<${queryOptionsGenerics.join(", ")}>(${queryParams.toString()})`
|
|
463
|
+
};
|
|
464
|
+
return /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _jsxruntime.Fragment, { children: [
|
|
465
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, QueryOptions, { factory, Template: QueryOptionsTemplate, dataReturnType }),
|
|
466
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
467
|
+
Template4,
|
|
468
|
+
{
|
|
469
|
+
name,
|
|
470
|
+
generics: generics.toString(),
|
|
471
|
+
JSDoc: { comments: _utils3.getComments.call(void 0, operation) },
|
|
472
|
+
client,
|
|
473
|
+
hook,
|
|
474
|
+
params: params.toString(),
|
|
475
|
+
returnType: `SWRResponse<${resultGenerics.join(", ")}>`
|
|
476
|
+
}
|
|
477
|
+
)
|
|
478
|
+
] });
|
|
479
|
+
}
|
|
480
|
+
Query.File = function({ templates }) {
|
|
481
|
+
const {
|
|
482
|
+
pluginManager,
|
|
483
|
+
plugin: {
|
|
484
|
+
options: {
|
|
485
|
+
extName,
|
|
486
|
+
client: { importPath },
|
|
487
|
+
parser
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
} = _react.useApp.call(void 0, );
|
|
491
|
+
const { getSchemas, getFile, getName } = _hooks.useOperationManager.call(void 0, );
|
|
492
|
+
const operation = _hooks.useOperation.call(void 0, );
|
|
493
|
+
const file = getFile(operation);
|
|
494
|
+
const schemas = getSchemas(operation, { pluginKey: [_plugints.pluginTsName], type: "type" });
|
|
495
|
+
const zodSchemas = getSchemas(operation, { pluginKey: [_pluginzod.pluginZodName], type: "function" });
|
|
496
|
+
const fileType = getFile(operation, { pluginKey: [_plugints.pluginTsName] });
|
|
497
|
+
const fileZodSchemas = getFile(operation, {
|
|
498
|
+
pluginKey: [_pluginzod.pluginZodName]
|
|
499
|
+
});
|
|
500
|
+
const factoryName = getName(operation, { type: "type" });
|
|
501
|
+
const Template4 = _optionalChain([templates, 'optionalAccess', _55 => _55.query, 'access', _56 => _56.default]) || defaultTemplates3.default;
|
|
502
|
+
const QueryOptionsTemplate = _optionalChain([templates, 'optionalAccess', _57 => _57.queryOptions, 'access', _58 => _58.default]) || QueryOptions.templates.default;
|
|
503
|
+
const factory = {
|
|
504
|
+
name: factoryName
|
|
505
|
+
};
|
|
506
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.Parser, { language: "typescript", children: /* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react.File, { baseName: file.baseName, path: file.path, meta: file.meta, children: [
|
|
507
|
+
parser === "zod" && /* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { extName, name: [zodSchemas.response.name], root: file.path, path: fileZodSchemas.path }),
|
|
508
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: "useSWR", path: "swr" }),
|
|
509
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: ["SWRConfiguration", "SWRResponse"], path: "swr", isTypeOnly: true }),
|
|
510
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: "client", path: importPath }),
|
|
511
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, _react.File.Import, { name: ["ResponseConfig"], path: importPath, isTypeOnly: true }),
|
|
512
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
513
|
+
_react.File.Import,
|
|
514
|
+
{
|
|
515
|
+
extName,
|
|
516
|
+
name: [
|
|
517
|
+
_optionalChain([schemas, 'access', _59 => _59.request, 'optionalAccess', _60 => _60.name]),
|
|
518
|
+
schemas.response.name,
|
|
519
|
+
_optionalChain([schemas, 'access', _61 => _61.pathParams, 'optionalAccess', _62 => _62.name]),
|
|
520
|
+
_optionalChain([schemas, 'access', _63 => _63.queryParams, 'optionalAccess', _64 => _64.name]),
|
|
521
|
+
_optionalChain([schemas, 'access', _65 => _65.headerParams, 'optionalAccess', _66 => _66.name]),
|
|
522
|
+
..._optionalChain([schemas, 'access', _67 => _67.statusCodes, 'optionalAccess', _68 => _68.map, 'call', _69 => _69((item) => item.name)]) || []
|
|
523
|
+
].filter(Boolean),
|
|
524
|
+
root: file.path,
|
|
525
|
+
path: fileType.path,
|
|
526
|
+
isTypeOnly: true
|
|
527
|
+
}
|
|
528
|
+
),
|
|
529
|
+
/* @__PURE__ */ _jsxruntime.jsxs.call(void 0, _react.File.Source, { children: [
|
|
530
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, SchemaType, { factory }),
|
|
531
|
+
/* @__PURE__ */ _jsxruntime.jsx.call(void 0, Query, { factory, Template: Template4, QueryOptionsTemplate })
|
|
532
|
+
] })
|
|
533
|
+
] }) });
|
|
534
|
+
};
|
|
535
|
+
Query.templates = defaultTemplates3;
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
|
|
540
|
+
|
|
541
|
+
exports.Mutation = Mutation; exports.QueryOptions = QueryOptions; exports.Query = Query;
|
|
542
|
+
//# sourceMappingURL=chunk-H4LHXYRJ.cjs.map
|