From a6286dbffdd124e6c78ce9764d1c8018926088c7 Mon Sep 17 00:00:00 2001 From: Stephen Zhou <38493346+hyoban@users.noreply.github.com> Date: Sun, 25 Jan 2026 20:03:54 +0800 Subject: [PATCH] update --- web/plugins/hey-api-orpc/config.ts | 15 ++++++++----- web/plugins/hey-api-orpc/index.ts | 2 +- web/plugins/hey-api-orpc/types.d.ts | 35 +++++++++++++++++++++++++++++ web/plugins/hey-api-orpc/types.ts | 34 ---------------------------- 4 files changed, 45 insertions(+), 41 deletions(-) create mode 100644 web/plugins/hey-api-orpc/types.d.ts delete mode 100644 web/plugins/hey-api-orpc/types.ts diff --git a/web/plugins/hey-api-orpc/config.ts b/web/plugins/hey-api-orpc/config.ts index 46d05e598a..d86f2b44e4 100644 --- a/web/plugins/hey-api-orpc/config.ts +++ b/web/plugins/hey-api-orpc/config.ts @@ -6,18 +6,21 @@ import { handler } from './plugin' export const defaultConfig: OrpcPlugin['Config'] = { config: { + contractNameBuilder: (id: string) => `${id}Contract`, + defaultTag: 'default', + exportFromIndex: false, output: 'orpc', }, dependencies: ['@hey-api/typescript', 'zod'], handler, name: 'orpc', - resolveConfig: (plugin) => { - plugin.config.output = plugin.config.output ?? 'orpc' - plugin.config.exportFromIndex = plugin.config.exportFromIndex ?? false - plugin.config.contractNameBuilder = plugin.config.contractNameBuilder - ?? ((id: string) => `${id}Contract`) - plugin.config.defaultTag = plugin.config.defaultTag ?? 'default' + resolveConfig: (plugin, _context) => { + plugin.config.output ??= 'orpc' + plugin.config.exportFromIndex ??= false + plugin.config.contractNameBuilder ??= (id: string) => `${id}Contract` + plugin.config.defaultTag ??= 'default' }, + tags: ['client'], } /** diff --git a/web/plugins/hey-api-orpc/index.ts b/web/plugins/hey-api-orpc/index.ts index f2f65bcd22..64a91044b1 100644 --- a/web/plugins/hey-api-orpc/index.ts +++ b/web/plugins/hey-api-orpc/index.ts @@ -1,2 +1,2 @@ export { defaultConfig, defineConfig } from './config' -export type { Config, OrpcPlugin, ResolvedConfig } from './types' +export type { OrpcPlugin, UserConfig } from './types' diff --git a/web/plugins/hey-api-orpc/types.d.ts b/web/plugins/hey-api-orpc/types.d.ts new file mode 100644 index 0000000000..d65295ce9e --- /dev/null +++ b/web/plugins/hey-api-orpc/types.d.ts @@ -0,0 +1,35 @@ +import type { DefinePlugin, Plugin } from '@hey-api/openapi-ts' + +export type UserConfig = Plugin.Name<'orpc'> + & Plugin.Hooks & { + /** + * Name of the generated file. + * @default 'orpc' + */ + output?: string + /** + * Whether exports should be re-exported in the index file. + * @default false + */ + exportFromIndex?: boolean + /** + * Custom naming function for contract symbols. + * @default (id) => `${id}Contract` + */ + contractNameBuilder?: (operationId: string) => string + /** + * Default tag name for operations without tags. + * @default 'default' + */ + defaultTag?: string + } + +export type Config = Plugin.Name<'orpc'> + & Plugin.Hooks & { + output: string + exportFromIndex: boolean + contractNameBuilder: (operationId: string) => string + defaultTag: string + } + +export type OrpcPlugin = DefinePlugin diff --git a/web/plugins/hey-api-orpc/types.ts b/web/plugins/hey-api-orpc/types.ts deleted file mode 100644 index 9cf3ac69a6..0000000000 --- a/web/plugins/hey-api-orpc/types.ts +++ /dev/null @@ -1,34 +0,0 @@ -import type { DefinePlugin } from '@hey-api/openapi-ts' - -export type Config = { name: 'orpc' } & { - /** - * Name of the generated file. - * @default 'orpc' - */ - output?: string - /** - * Whether exports should be re-exported in the index file. - * @default false - */ - exportFromIndex?: boolean - /** - * Custom naming function for contract symbols. - * @default (id) => `${id}Contract` - */ - contractNameBuilder?: (operationId: string) => string - /** - * Default tag name for operations without tags. - * @default 'default' - */ - defaultTag?: string -} - -export type ResolvedConfig = { - name: 'orpc' - output: string - exportFromIndex: boolean - contractNameBuilder: (operationId: string) => string - defaultTag: string -} - -export type OrpcPlugin = DefinePlugin