1- import type {
2- // Casing,
3- DefinePlugin ,
4- // FeatureToggle,
5- // IR,
6- // NameTransformer,
7- // NamingOptions,
8- NamingConfig ,
9- NamingRule ,
10- OperationPathStrategy ,
11- OperationsStrategy ,
12- Plugin ,
13- } from '@hey-api/shared' ;
1+ import type { DefinePlugin , OperationsStrategy , Plugin } from '@hey-api/shared' ;
142
153import type { PluginValidatorNames } from '../../types' ;
164import type { ContractsConfig , UserContractsConfig } from './contracts/types' ;
175
18- export interface UserRouterConfig {
19- /**
20- * Customize method/key names for operations in the router.
21- *
22- * Applied to the final segment of the path.
23- */
24- methodName ?: NamingRule ;
25- /**
26- * How to derive nesting structure from operations.
27- *
28- * - `'operationId'` - Split operationId by delimiters (e.g., `users.list` → `{ users: { list } }`)
29- * - `'id'` - Use operation id as-is, no nesting
30- * - Custom function for full control
31- *
32- * @default 'operationId'
33- */
34- nesting ?: 'id' | 'operationId' | OperationPathStrategy ;
35- /**
36- * Delimiters for splitting operationId.
37- *
38- * Only applies when `nesting` is `'operationId'`.
39- *
40- * @default /[./]/
41- */
42- nestingDelimiters ?: RegExp ;
43- /**
44- * Customize segment names for nested groups.
45- *
46- * Applied to intermediate path segments (not the key name).
47- */
48- segmentName ?: NamingRule ;
49- /**
50- * Grouping strategy.
51- *
52- * - `'flat'` - No grouping, all contracts at root level
53- * - `'byTags'` - One group per operation tag
54- * - `'single'` - All operations in one group
55- * - Custom function for full control
56- *
57- * @default 'flat'
58- */
59- strategy ?: OperationsStrategy ;
60- /**
61- * Default group name for operations without tags.
62- *
63- * Only applies when `strategy` is `'byTags'`.
64- *
65- * @default 'default'
66- */
67- strategyDefaultTag ?: string ;
68- }
69-
70- export interface RouterConfig {
71- /**
72- * Customize method/key names for operations in the router.
73- *
74- * Applied to the final segment of the path.
75- */
76- methodName : NamingConfig ;
77- /**
78- * How to derive nesting structure from operations.
79- *
80- * - `'operationId'` - Split operationId by delimiters (e.g., `users.list` → `{ users: { list } }`)
81- * - `'id'` - Use operation id as-is, no nesting
82- * - Custom function for full control
83- */
84- nesting : 'id' | 'operationId' | OperationPathStrategy ;
85- /**
86- * Delimiters for splitting operationId.
87- *
88- * Only applies when `nesting` is `'operationId'`.
89- */
90- nestingDelimiters : RegExp ;
91- /**
92- * Customize segment names for nested groups.
93- *
94- * Applied to intermediate path segments (not the key name).
95- */
96- segmentName : NamingConfig ;
97- /**
98- * Grouping strategy.
99- *
100- * - `'flat'` - No grouping, all contracts at root level
101- * - `'byTags'` - One group per operation tag
102- * - `'single'` - All operations in one group
103- * - Custom function for full control
104- */
105- strategy : OperationsStrategy ;
106- /**
107- * Default group name for operations without tags.
108- *
109- * Only applies when `strategy` is `'byTags'`.
110- */
111- strategyDefaultTag : string ;
112- }
113-
1146export type UserConfig = Plugin . Name < '@orpc/contract' > &
1157 Plugin . Hooks &
1168 Plugin . UserExports & {
@@ -128,46 +20,6 @@ export type UserConfig = Plugin.Name<'@orpc/contract'> &
12820 * @default 'flat'
12921 */
13022 contracts ?: OperationsStrategy | UserContractsConfig ;
131- /**
132- * Router configuration for grouping and nesting operations.
133- *
134- * Can be a strategy string for simple cases, or an object for full control.
135- *
136- * @default { strategy: 'flat' }
137- *
138- * @example
139- * // Simple: just set strategy
140- * router: 'byTags'
141- *
142- * @example
143- * // Full control
144- * router: {
145- * strategy: 'byTags',
146- * nesting: 'operationId',
147- * segmentName: { casing: 'camelCase' },
148- * methodName: { casing: 'camelCase' },
149- * }
150- */
151- router ?: OperationsStrategy | UserRouterConfig ;
152- /**
153- * Naming rule for the router export.
154- * The type export will be the PascalCase version (e.g., 'router' → 'Router').
155- *
156- * @default 'router'
157- *
158- * @example
159- * // Simple string
160- * routerName: 'contract'
161- *
162- * @example
163- * // Template string
164- * routerName: '{{name}}Contract'
165- *
166- * @example
167- * // With casing
168- * routerName: { name: '{{name}}Contract', casing: 'camelCase' }
169- */
170- routerName ?: NamingRule ;
17123 /**
17224 * Validate input/output schemas.
17325 *
@@ -203,8 +55,6 @@ export type Config = Plugin.Name<'@orpc/contract'> &
20355 Plugin . Exports & {
20456 /** Define the structure of generated oRPC contracts. */
20557 contracts : ContractsConfig ;
206- router : RouterConfig ;
207- routerName : NamingConfig ;
20858 /** Validate input/output schemas. */
20959 validator : {
21060 /** The validator plugin to use for input schemas. */
0 commit comments