diff --git a/packages/custom-client/src/plugin.ts b/packages/custom-client/src/plugin.ts index a69653309..07967bd22 100644 --- a/packages/custom-client/src/plugin.ts +++ b/packages/custom-client/src/plugin.ts @@ -1,4 +1,3 @@ -import type { Selector } from '@hey-api/codegen-core'; import { type Client, clientDefaultConfig, @@ -8,25 +7,9 @@ import { definePluginConfig, } from '@hey-api/openapi-ts'; -type SelectorType = 'client'; +export type IApi = any; -export type IApi = { - /** - * @param type Selector type. - * @param value Depends on `type`: - * - `client`: never - * @returns Selector array - */ - selector: (type: SelectorType, value?: string) => Selector; -}; - -export class Api implements IApi { - constructor(public meta: Pick) {} - - selector(...args: ReadonlyArray): Selector { - return [this.meta.name, ...(args as Selector)]; - } -} +export class Api implements IApi {} export type Config = Client.Config & { /** @@ -39,9 +22,7 @@ export type CustomClientPlugin = DefinePlugin; export const defaultConfig: CustomClientPlugin['Config'] = { ...clientDefaultMeta, - api: new Api({ - name: '@hey-api/custom-client', - }), + api: new Api(), config: { ...clientDefaultConfig, bundle: false, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-false/client/plugin.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-false/client/plugin.ts index c11a1606a..73f26494e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-false/client/plugin.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-false/client/plugin.ts @@ -1,4 +1,3 @@ -import type { Selector } from '@hey-api/codegen-core'; import { type Client, clientDefaultConfig, @@ -8,25 +7,9 @@ import { definePluginConfig, } from '@hey-api/openapi-ts'; -type SelectorType = 'client'; +export type IApi = any; -export type IApi = { - /** - * @param type Selector type. - * @param value Depends on `type`: - * - `client`: never - * @returns Selector array - */ - selector: (type: SelectorType, value?: string) => Selector; -}; - -export class Api implements IApi { - constructor(public meta: Pick) {} - - selector(...args: ReadonlyArray): Selector { - return [this.meta.name, ...(args as Selector)]; - } -} +export class Api implements IApi {} export type Config = Client.Config & { /** @@ -39,9 +22,7 @@ export type MyClientPlugin = DefinePlugin; export const defaultConfig: MyClientPlugin['Config'] = { ...clientDefaultMeta, - api: new Api({ - name: __filename, - }), + api: new Api(), config: clientDefaultConfig, handler: clientPluginHandler, name: __filename, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-number/client/plugin.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-number/client/plugin.ts index c11a1606a..73f26494e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-number/client/plugin.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-number/client/plugin.ts @@ -1,4 +1,3 @@ -import type { Selector } from '@hey-api/codegen-core'; import { type Client, clientDefaultConfig, @@ -8,25 +7,9 @@ import { definePluginConfig, } from '@hey-api/openapi-ts'; -type SelectorType = 'client'; +export type IApi = any; -export type IApi = { - /** - * @param type Selector type. - * @param value Depends on `type`: - * - `client`: never - * @returns Selector array - */ - selector: (type: SelectorType, value?: string) => Selector; -}; - -export class Api implements IApi { - constructor(public meta: Pick) {} - - selector(...args: ReadonlyArray): Selector { - return [this.meta.name, ...(args as Selector)]; - } -} +export class Api implements IApi {} export type Config = Client.Config & { /** @@ -39,9 +22,7 @@ export type MyClientPlugin = DefinePlugin; export const defaultConfig: MyClientPlugin['Config'] = { ...clientDefaultMeta, - api: new Api({ - name: __filename, - }), + api: new Api(), config: clientDefaultConfig, handler: clientPluginHandler, name: __filename, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-strict/client/plugin.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-strict/client/plugin.ts index c11a1606a..73f26494e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-strict/client/plugin.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-strict/client/plugin.ts @@ -1,4 +1,3 @@ -import type { Selector } from '@hey-api/codegen-core'; import { type Client, clientDefaultConfig, @@ -8,25 +7,9 @@ import { definePluginConfig, } from '@hey-api/openapi-ts'; -type SelectorType = 'client'; +export type IApi = any; -export type IApi = { - /** - * @param type Selector type. - * @param value Depends on `type`: - * - `client`: never - * @returns Selector array - */ - selector: (type: SelectorType, value?: string) => Selector; -}; - -export class Api implements IApi { - constructor(public meta: Pick) {} - - selector(...args: ReadonlyArray): Selector { - return [this.meta.name, ...(args as Selector)]; - } -} +export class Api implements IApi {} export type Config = Client.Config & { /** @@ -39,9 +22,7 @@ export type MyClientPlugin = DefinePlugin; export const defaultConfig: MyClientPlugin['Config'] = { ...clientDefaultMeta, - api: new Api({ - name: __filename, - }), + api: new Api(), config: clientDefaultConfig, handler: clientPluginHandler, name: __filename, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-string/client/plugin.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-string/client/plugin.ts index c11a1606a..73f26494e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-string/client/plugin.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/base-url-string/client/plugin.ts @@ -1,4 +1,3 @@ -import type { Selector } from '@hey-api/codegen-core'; import { type Client, clientDefaultConfig, @@ -8,25 +7,9 @@ import { definePluginConfig, } from '@hey-api/openapi-ts'; -type SelectorType = 'client'; +export type IApi = any; -export type IApi = { - /** - * @param type Selector type. - * @param value Depends on `type`: - * - `client`: never - * @returns Selector array - */ - selector: (type: SelectorType, value?: string) => Selector; -}; - -export class Api implements IApi { - constructor(public meta: Pick) {} - - selector(...args: ReadonlyArray): Selector { - return [this.meta.name, ...(args as Selector)]; - } -} +export class Api implements IApi {} export type Config = Client.Config & { /** @@ -39,9 +22,7 @@ export type MyClientPlugin = DefinePlugin; export const defaultConfig: MyClientPlugin['Config'] = { ...clientDefaultMeta, - api: new Api({ - name: __filename, - }), + api: new Api(), config: clientDefaultConfig, handler: clientPluginHandler, name: __filename, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/bundle/client/plugin.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/bundle/client/plugin.ts index c11a1606a..73f26494e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/bundle/client/plugin.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/bundle/client/plugin.ts @@ -1,4 +1,3 @@ -import type { Selector } from '@hey-api/codegen-core'; import { type Client, clientDefaultConfig, @@ -8,25 +7,9 @@ import { definePluginConfig, } from '@hey-api/openapi-ts'; -type SelectorType = 'client'; +export type IApi = any; -export type IApi = { - /** - * @param type Selector type. - * @param value Depends on `type`: - * - `client`: never - * @returns Selector array - */ - selector: (type: SelectorType, value?: string) => Selector; -}; - -export class Api implements IApi { - constructor(public meta: Pick) {} - - selector(...args: ReadonlyArray): Selector { - return [this.meta.name, ...(args as Selector)]; - } -} +export class Api implements IApi {} export type Config = Client.Config & { /** @@ -39,9 +22,7 @@ export type MyClientPlugin = DefinePlugin; export const defaultConfig: MyClientPlugin['Config'] = { ...clientDefaultMeta, - api: new Api({ - name: __filename, - }), + api: new Api(), config: clientDefaultConfig, handler: clientPluginHandler, name: __filename, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/default/client/plugin.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/default/client/plugin.ts index c11a1606a..73f26494e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/default/client/plugin.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/default/client/plugin.ts @@ -1,4 +1,3 @@ -import type { Selector } from '@hey-api/codegen-core'; import { type Client, clientDefaultConfig, @@ -8,25 +7,9 @@ import { definePluginConfig, } from '@hey-api/openapi-ts'; -type SelectorType = 'client'; +export type IApi = any; -export type IApi = { - /** - * @param type Selector type. - * @param value Depends on `type`: - * - `client`: never - * @returns Selector array - */ - selector: (type: SelectorType, value?: string) => Selector; -}; - -export class Api implements IApi { - constructor(public meta: Pick) {} - - selector(...args: ReadonlyArray): Selector { - return [this.meta.name, ...(args as Selector)]; - } -} +export class Api implements IApi {} export type Config = Client.Config & { /** @@ -39,9 +22,7 @@ export type MyClientPlugin = DefinePlugin; export const defaultConfig: MyClientPlugin['Config'] = { ...clientDefaultMeta, - api: new Api({ - name: __filename, - }), + api: new Api(), config: clientDefaultConfig, handler: clientPluginHandler, name: __filename, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-optional/client/plugin.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-optional/client/plugin.ts index c11a1606a..73f26494e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-optional/client/plugin.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-optional/client/plugin.ts @@ -1,4 +1,3 @@ -import type { Selector } from '@hey-api/codegen-core'; import { type Client, clientDefaultConfig, @@ -8,25 +7,9 @@ import { definePluginConfig, } from '@hey-api/openapi-ts'; -type SelectorType = 'client'; +export type IApi = any; -export type IApi = { - /** - * @param type Selector type. - * @param value Depends on `type`: - * - `client`: never - * @returns Selector array - */ - selector: (type: SelectorType, value?: string) => Selector; -}; - -export class Api implements IApi { - constructor(public meta: Pick) {} - - selector(...args: ReadonlyArray): Selector { - return [this.meta.name, ...(args as Selector)]; - } -} +export class Api implements IApi {} export type Config = Client.Config & { /** @@ -39,9 +22,7 @@ export type MyClientPlugin = DefinePlugin; export const defaultConfig: MyClientPlugin['Config'] = { ...clientDefaultMeta, - api: new Api({ - name: __filename, - }), + api: new Api(), config: clientDefaultConfig, handler: clientPluginHandler, name: __filename, diff --git a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-required/client/plugin.ts b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-required/client/plugin.ts index c11a1606a..73f26494e 100644 --- a/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-required/client/plugin.ts +++ b/packages/openapi-ts-tests/main/test/__snapshots__/3.1.x/clients/my-client/sdk-client-required/client/plugin.ts @@ -1,4 +1,3 @@ -import type { Selector } from '@hey-api/codegen-core'; import { type Client, clientDefaultConfig, @@ -8,25 +7,9 @@ import { definePluginConfig, } from '@hey-api/openapi-ts'; -type SelectorType = 'client'; +export type IApi = any; -export type IApi = { - /** - * @param type Selector type. - * @param value Depends on `type`: - * - `client`: never - * @returns Selector array - */ - selector: (type: SelectorType, value?: string) => Selector; -}; - -export class Api implements IApi { - constructor(public meta: Pick) {} - - selector(...args: ReadonlyArray): Selector { - return [this.meta.name, ...(args as Selector)]; - } -} +export class Api implements IApi {} export type Config = Client.Config & { /** @@ -39,9 +22,7 @@ export type MyClientPlugin = DefinePlugin; export const defaultConfig: MyClientPlugin['Config'] = { ...clientDefaultMeta, - api: new Api({ - name: __filename, - }), + api: new Api(), config: clientDefaultConfig, handler: clientPluginHandler, name: __filename, diff --git a/packages/openapi-ts-tests/main/test/custom/client/plugin.ts b/packages/openapi-ts-tests/main/test/custom/client/plugin.ts index c11a1606a..73f26494e 100644 --- a/packages/openapi-ts-tests/main/test/custom/client/plugin.ts +++ b/packages/openapi-ts-tests/main/test/custom/client/plugin.ts @@ -1,4 +1,3 @@ -import type { Selector } from '@hey-api/codegen-core'; import { type Client, clientDefaultConfig, @@ -8,25 +7,9 @@ import { definePluginConfig, } from '@hey-api/openapi-ts'; -type SelectorType = 'client'; +export type IApi = any; -export type IApi = { - /** - * @param type Selector type. - * @param value Depends on `type`: - * - `client`: never - * @returns Selector array - */ - selector: (type: SelectorType, value?: string) => Selector; -}; - -export class Api implements IApi { - constructor(public meta: Pick) {} - - selector(...args: ReadonlyArray): Selector { - return [this.meta.name, ...(args as Selector)]; - } -} +export class Api implements IApi {} export type Config = Client.Config & { /** @@ -39,9 +22,7 @@ export type MyClientPlugin = DefinePlugin; export const defaultConfig: MyClientPlugin['Config'] = { ...clientDefaultMeta, - api: new Api({ - name: __filename, - }), + api: new Api(), config: clientDefaultConfig, handler: clientPluginHandler, name: __filename, diff --git a/packages/openapi-ts/src/index.ts b/packages/openapi-ts/src/index.ts index fca759857..f0a2f4dc8 100644 --- a/packages/openapi-ts/src/index.ts +++ b/packages/openapi-ts/src/index.ts @@ -15,7 +15,13 @@ declare module '@hey-api/codegen-core' { } interface SymbolMeta { - category?: 'external' | 'schema' | 'sdk' | 'type' | (string & {}); + category?: + | 'client' + | 'external' + | 'schema' + | 'sdk' + | 'type' + | (string & {}); /** * Path to the resource this symbol represents. */ diff --git a/packages/openapi-ts/src/plugins/@angular/common/httpRequests.ts b/packages/openapi-ts/src/plugins/@angular/common/httpRequests.ts index d1e77a1cf..001318570 100644 --- a/packages/openapi-ts/src/plugins/@angular/common/httpRequests.ts +++ b/packages/openapi-ts/src/plugins/@angular/common/httpRequests.ts @@ -3,7 +3,6 @@ import type ts from 'typescript'; import type { IR } from '~/ir/types'; import { buildName } from '~/openApi/shared/utils/name'; -import { getClientPlugin } from '~/plugins/@hey-api/client-core/utils'; import { operationClasses } from '~/plugins/@hey-api/sdk/shared/operation'; import { createOperationComment, @@ -210,14 +209,9 @@ const generateRequestCallExpression = ({ operation: IR.OperationObject; plugin: AngularCommonPlugin['Instance']; }) => { - const client = getClientPlugin(plugin.context.config); - const symbolClient = - client.api && 'selector' in client.api - ? plugin.getSymbol( - // @ts-expect-error - client.api.selector('client'), - ) - : undefined; + const symbolClient = plugin.getSymbol({ + category: 'client', + }); const optionsClient = tsc.propertyAccessExpression({ expression: tsc.identifier({ text: 'options' }), diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-angular/api.ts b/packages/openapi-ts/src/plugins/@hey-api/client-angular/api.ts index d43e70f26..1496308d2 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-angular/api.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-angular/api.ts @@ -1,24 +1,3 @@ -import type { Selector } from '@hey-api/codegen-core'; +export type IApi = any; -import type { Plugin } from '~/plugins'; - -type SelectorType = 'client'; - -export type IApi = { - /** - * @param type Selector type. - * @param value Depends on `type`: - * - `client`: never - * @returns Selector array - * @deprecated - */ - selector: (type: SelectorType, value?: string) => Selector; -}; - -export class Api implements IApi { - constructor(public meta: Plugin.Name<'@hey-api/client-angular'>) {} - - selector(...args: ReadonlyArray): Selector { - return [this.meta.name, ...(args as Selector)]; - } -} +export class Api implements IApi {} diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-angular/config.ts b/packages/openapi-ts/src/plugins/@hey-api/client-angular/config.ts index f15b005af..4c83beaf1 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-angular/config.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-angular/config.ts @@ -10,9 +10,7 @@ import type { HeyApiClientAngularPlugin } from './types'; export const defaultConfig: HeyApiClientAngularPlugin['Config'] = { ...clientDefaultMeta, - api: new Api({ - name: '@hey-api/client-angular', - }), + api: new Api(), config: { ...clientDefaultConfig, throwOnError: false, diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-axios/api.ts b/packages/openapi-ts/src/plugins/@hey-api/client-axios/api.ts index 4081e0dc2..1496308d2 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-axios/api.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-axios/api.ts @@ -1,24 +1,3 @@ -import type { Selector } from '@hey-api/codegen-core'; +export type IApi = any; -import type { Plugin } from '~/plugins'; - -type SelectorType = 'client'; - -export type IApi = { - /** - * @param type Selector type. - * @param value Depends on `type`: - * - `client`: never - * @returns Selector array - * @deprecated - */ - selector: (type: SelectorType, value?: string) => Selector; -}; - -export class Api implements IApi { - constructor(public meta: Plugin.Name<'@hey-api/client-axios'>) {} - - selector(...args: ReadonlyArray): Selector { - return [this.meta.name, ...(args as Selector)]; - } -} +export class Api implements IApi {} diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-axios/config.ts b/packages/openapi-ts/src/plugins/@hey-api/client-axios/config.ts index cfb1d088f..8f6bd333f 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-axios/config.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-axios/config.ts @@ -10,9 +10,7 @@ import type { HeyApiClientAxiosPlugin } from './types'; export const defaultConfig: HeyApiClientAxiosPlugin['Config'] = { ...clientDefaultMeta, - api: new Api({ - name: '@hey-api/client-axios', - }), + api: new Api(), config: { ...clientDefaultConfig, throwOnError: false, diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-core/client.ts b/packages/openapi-ts/src/plugins/@hey-api/client-core/client.ts index 4a5bc7697..2e15033b6 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-core/client.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-core/client.ts @@ -94,8 +94,10 @@ export const createClient: PluginHandler = ({ plugin }) => { ]; const symbolClient = plugin.registerSymbol({ + meta: { + category: 'client', + }, name: 'client', - selector: plugin.api.selector('client'), }); const statement = tsc.constVariable({ exportConst: true, diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-fetch/api.ts b/packages/openapi-ts/src/plugins/@hey-api/client-fetch/api.ts index 6904136cb..1496308d2 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-fetch/api.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-fetch/api.ts @@ -1,24 +1,3 @@ -import type { Selector } from '@hey-api/codegen-core'; +export type IApi = any; -import type { Plugin } from '~/plugins'; - -type SelectorType = 'client'; - -export type IApi = { - /** - * @param type Selector type. - * @param value Depends on `type`: - * - `client`: never - * @returns Selector array - * @deprecated - */ - selector: (type: SelectorType, value?: string) => Selector; -}; - -export class Api implements IApi { - constructor(public meta: Plugin.Name<'@hey-api/client-fetch'>) {} - - selector(...args: ReadonlyArray): Selector { - return [this.meta.name, ...(args as Selector)]; - } -} +export class Api implements IApi {} diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-fetch/config.ts b/packages/openapi-ts/src/plugins/@hey-api/client-fetch/config.ts index 0e50f65d0..84bd0a542 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-fetch/config.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-fetch/config.ts @@ -10,9 +10,7 @@ import type { HeyApiClientFetchPlugin } from './types'; export const defaultConfig: HeyApiClientFetchPlugin['Config'] = { ...clientDefaultMeta, - api: new Api({ - name: '@hey-api/client-fetch', - }), + api: new Api(), config: { ...clientDefaultConfig, throwOnError: false, diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-next/api.ts b/packages/openapi-ts/src/plugins/@hey-api/client-next/api.ts index 5cd68151b..1496308d2 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-next/api.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-next/api.ts @@ -1,24 +1,3 @@ -import type { Selector } from '@hey-api/codegen-core'; +export type IApi = any; -import type { Plugin } from '~/plugins'; - -type SelectorType = 'client'; - -export type IApi = { - /** - * @param type Selector type. - * @param value Depends on `type`: - * - `client`: never - * @returns Selector array - * @deprecated - */ - selector: (type: SelectorType, value?: string) => Selector; -}; - -export class Api implements IApi { - constructor(public meta: Plugin.Name<'@hey-api/client-next'>) {} - - selector(...args: ReadonlyArray): Selector { - return [this.meta.name, ...(args as Selector)]; - } -} +export class Api implements IApi {} diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-next/config.ts b/packages/openapi-ts/src/plugins/@hey-api/client-next/config.ts index e219b4992..67bf1a5fa 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-next/config.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-next/config.ts @@ -10,9 +10,7 @@ import type { HeyApiClientNextPlugin } from './types'; export const defaultConfig: HeyApiClientNextPlugin['Config'] = { ...clientDefaultMeta, - api: new Api({ - name: '@hey-api/client-next', - }), + api: new Api(), config: { ...clientDefaultConfig, throwOnError: false, diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-nuxt/api.ts b/packages/openapi-ts/src/plugins/@hey-api/client-nuxt/api.ts index a3441eaba..1496308d2 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-nuxt/api.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-nuxt/api.ts @@ -1,24 +1,3 @@ -import type { Selector } from '@hey-api/codegen-core'; +export type IApi = any; -import type { Plugin } from '~/plugins'; - -type SelectorType = 'client'; - -export type IApi = { - /** - * @param type Selector type. - * @param value Depends on `type`: - * - `client`: never - * @returns Selector array - * @deprecated - */ - selector: (type: SelectorType, value?: string) => Selector; -}; - -export class Api implements IApi { - constructor(public meta: Plugin.Name<'@hey-api/client-nuxt'>) {} - - selector(...args: ReadonlyArray): Selector { - return [this.meta.name, ...(args as Selector)]; - } -} +export class Api implements IApi {} diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-nuxt/config.ts b/packages/openapi-ts/src/plugins/@hey-api/client-nuxt/config.ts index 6a686ecd4..bfb6cda63 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-nuxt/config.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-nuxt/config.ts @@ -10,9 +10,7 @@ import type { HeyApiClientNuxtPlugin } from './types'; export const defaultConfig: HeyApiClientNuxtPlugin['Config'] = { ...clientDefaultMeta, - api: new Api({ - name: '@hey-api/client-nuxt', - }), + api: new Api(), config: clientDefaultConfig, handler: clientPluginHandler, name: '@hey-api/client-nuxt', diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-ofetch/api.ts b/packages/openapi-ts/src/plugins/@hey-api/client-ofetch/api.ts index 252bb2ceb..1496308d2 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-ofetch/api.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-ofetch/api.ts @@ -1,24 +1,3 @@ -import type { Selector } from '@hey-api/codegen-core'; +export type IApi = any; -import type { Plugin } from '~/plugins'; - -type SelectorType = 'client'; - -export type IApi = { - /** - * @param type Selector type. - * @param value Depends on `type`: - * - `client`: never - * @returns Selector array - * @deprecated - */ - selector: (type: SelectorType, value?: string) => Selector; -}; - -export class Api implements IApi { - constructor(public meta: Plugin.Name<'@hey-api/client-ofetch'>) {} - - selector(...args: ReadonlyArray): Selector { - return [this.meta.name, ...(args as Selector)]; - } -} +export class Api implements IApi {} diff --git a/packages/openapi-ts/src/plugins/@hey-api/client-ofetch/config.ts b/packages/openapi-ts/src/plugins/@hey-api/client-ofetch/config.ts index adf180f20..094694128 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/client-ofetch/config.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/client-ofetch/config.ts @@ -10,9 +10,7 @@ import type { HeyApiClientOfetchPlugin } from './types'; export const defaultConfig: HeyApiClientOfetchPlugin['Config'] = { ...clientDefaultMeta, - api: new Api({ - name: '@hey-api/client-ofetch', - }), + api: new Api(), config: { ...clientDefaultConfig, throwOnError: false, diff --git a/packages/openapi-ts/src/plugins/@hey-api/sdk/shared/class.ts b/packages/openapi-ts/src/plugins/@hey-api/sdk/shared/class.ts index c2cfa21ad..975882024 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/sdk/shared/class.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/sdk/shared/class.ts @@ -63,14 +63,9 @@ const createClientClassNodes = ({ }); const symbolClient = plugin.referenceSymbol(plugin.api.selector('Client')); - const client = getClientPlugin(plugin.context.config); - const symClient = - client.api && 'selector' in client.api - ? plugin.getSymbol( - // @ts-expect-error - client.api.selector('client'), - ) - : undefined; + const symClient = plugin.getSymbol({ + category: 'client', + }); return [ tsc.propertyDeclaration({ diff --git a/packages/openapi-ts/src/plugins/@hey-api/sdk/shared/operation.ts b/packages/openapi-ts/src/plugins/@hey-api/sdk/shared/operation.ts index 9d1ad9563..a857afca1 100644 --- a/packages/openapi-ts/src/plugins/@hey-api/sdk/shared/operation.ts +++ b/packages/openapi-ts/src/plugins/@hey-api/sdk/shared/operation.ts @@ -683,13 +683,11 @@ export const operationStatements = ({ } } - const symbolClient = - plugin.config.client && client.api && 'selector' in client.api - ? plugin.getSymbol( - // @ts-expect-error - client.api.selector('client'), - ) - : undefined; + const symbolClient = plugin.config.client + ? plugin.getSymbol({ + category: 'client', + }) + : undefined; const optionsClient = tsc.propertyAccessExpression({ expression: tsc.identifier({ text: 'options' }), diff --git a/packages/openapi-ts/src/plugins/@pinia/colada/queryKey.ts b/packages/openapi-ts/src/plugins/@pinia/colada/queryKey.ts index b34408d12..60b5bd7ce 100644 --- a/packages/openapi-ts/src/plugins/@pinia/colada/queryKey.ts +++ b/packages/openapi-ts/src/plugins/@pinia/colada/queryKey.ts @@ -5,10 +5,7 @@ import { clientFolderAbsolutePath } from '~/generate/client'; import { hasOperationDataRequired } from '~/ir/operation'; import type { IR } from '~/ir/types'; import { buildName } from '~/openApi/shared/utils/name'; -import { - getClientBaseUrlKey, - getClientPlugin, -} from '~/plugins/@hey-api/client-core/utils'; +import { getClientBaseUrlKey } from '~/plugins/@hey-api/client-core/utils'; import { type Property, tsc } from '~/tsc'; import type { PiniaColadaPlugin } from './types'; @@ -56,14 +53,9 @@ export const createQueryKeyFunction = ({ const symbolOptions = plugin.referenceSymbol( sdkPlugin.api.selector('Options'), ); - const client = getClientPlugin(plugin.context.config); - const symbolClient = - client.api && 'selector' in client.api - ? plugin.getSymbol( - // @ts-expect-error - client.api.selector('client'), - ) - : undefined; + const symbolClient = plugin.getSymbol({ + category: 'client', + }); const clientModule = clientFolderAbsolutePath(plugin.context.config); const symbolSerializeQueryValue = plugin.registerSymbol({ diff --git a/packages/openapi-ts/src/plugins/@tanstack/query-core/queryKey.ts b/packages/openapi-ts/src/plugins/@tanstack/query-core/queryKey.ts index 8d72bfda7..ebb530c1e 100644 --- a/packages/openapi-ts/src/plugins/@tanstack/query-core/queryKey.ts +++ b/packages/openapi-ts/src/plugins/@tanstack/query-core/queryKey.ts @@ -4,10 +4,7 @@ import type { Expression } from 'typescript'; import { hasOperationDataRequired } from '~/ir/operation'; import type { IR } from '~/ir/types'; import { buildName } from '~/openApi/shared/utils/name'; -import { - getClientBaseUrlKey, - getClientPlugin, -} from '~/plugins/@hey-api/client-core/utils'; +import { getClientBaseUrlKey } from '~/plugins/@hey-api/client-core/utils'; import { type Property, tsc } from '~/tsc'; import type { PluginInstance } from './types'; @@ -48,14 +45,9 @@ export const createQueryKeyFunction = ({ const baseUrlKey = getClientBaseUrlKey(plugin.context.config); - const client = getClientPlugin(plugin.context.config); - const symbolClient = - client.api && 'selector' in client.api - ? plugin.getSymbol( - // @ts-expect-error - client.api.selector('client'), - ) - : undefined; + const symbolClient = plugin.getSymbol({ + category: 'client', + }); const sdkPlugin = plugin.getPluginOrThrow('@hey-api/sdk'); const symbolOptions = plugin.referenceSymbol(