11import type { IR } from '@hey-api/shared' ;
2- import { applyNaming } from '@hey-api/shared' ;
3- import { operationResponsesMap } from '@hey-api/shared' ;
4- import { deduplicateSchema } from '@hey-api/shared' ;
2+ import {
3+ applyNaming ,
4+ buildSymbolIn ,
5+ deduplicateSchema ,
6+ operationResponsesMap ,
7+ } from '@hey-api/shared' ;
58
69import { $ } from '../../../../ts-dsl' ;
710import type { HeyApiTypeScriptPlugin } from '../types' ;
@@ -117,17 +120,22 @@ export const operationToType = ({
117120 schema : data ,
118121 } ) ;
119122
120- const dataSymbol = plugin . symbol ( applyNaming ( operation . id , plugin . config . requests ) , {
121- meta : {
122- category : 'type' ,
123- path,
124- resource : 'operation' ,
125- resourceId : operation . id ,
126- role : 'data' ,
127- tags,
128- tool : 'typescript' ,
129- } ,
130- } ) ;
123+ const dataSymbol = plugin . registerSymbol (
124+ buildSymbolIn ( {
125+ meta : {
126+ category : 'type' ,
127+ path,
128+ resource : 'operation' ,
129+ resourceId : operation . id ,
130+ role : 'data' ,
131+ tags,
132+ tool : 'typescript' ,
133+ } ,
134+ name : applyNaming ( operation . id , plugin . config . requests ) ,
135+ operation,
136+ plugin,
137+ } ) ,
138+ ) ;
131139 const dataNode = $ . type
132140 . alias ( dataSymbol )
133141 . export ( )
@@ -149,30 +157,31 @@ export const operationToType = ({
149157 schema : errors ,
150158 } ) ;
151159
152- const errorsSymbol = plugin . symbol ( applyNaming ( operation . id , plugin . config . errors ) , {
153- meta : {
154- category : 'type' ,
155- path,
156- resource : 'operation' ,
157- resourceId : operation . id ,
158- role : 'errors' ,
159- tags,
160- tool : 'typescript' ,
161- } ,
162- } ) ;
160+ const errorsSymbol = plugin . registerSymbol (
161+ buildSymbolIn ( {
162+ meta : {
163+ category : 'type' ,
164+ path,
165+ resource : 'operation' ,
166+ resourceId : operation . id ,
167+ role : 'errors' ,
168+ tags,
169+ tool : 'typescript' ,
170+ } ,
171+ name : applyNaming ( operation . id , plugin . config . errors ) ,
172+ operation,
173+ plugin,
174+ } ) ,
175+ ) ;
163176 const errorsNode = $ . type
164177 . alias ( errorsSymbol )
165178 . export ( )
166179 . type ( errorsResult ?. type ?? $ . type ( 'never' ) ) ;
167180 plugin . node ( errorsNode ) ;
168181
169182 if ( error ) {
170- const errorSymbol = plugin . symbol (
171- applyNaming ( operation . id , {
172- case : plugin . config . errors . case ,
173- name : plugin . config . errors . error ,
174- } ) ,
175- {
183+ const errorSymbol = plugin . registerSymbol (
184+ buildSymbolIn ( {
176185 meta : {
177186 category : 'type' ,
178187 path,
@@ -182,7 +191,13 @@ export const operationToType = ({
182191 tags,
183192 tool : 'typescript' ,
184193 } ,
185- } ,
194+ name : applyNaming ( operation . id , {
195+ case : plugin . config . errors . case ,
196+ name : plugin . config . errors . error ,
197+ } ) ,
198+ operation,
199+ plugin,
200+ } ) ,
186201 ) ;
187202 const errorNode = $ . type
188203 . alias ( errorSymbol )
@@ -205,30 +220,31 @@ export const operationToType = ({
205220 schema : responses ,
206221 } ) ;
207222
208- const responsesSymbol = plugin . symbol ( applyNaming ( operation . id , plugin . config . responses ) , {
209- meta : {
210- category : 'type' ,
211- path,
212- resource : 'operation' ,
213- resourceId : operation . id ,
214- role : 'responses' ,
215- tags,
216- tool : 'typescript' ,
217- } ,
218- } ) ;
223+ const responsesSymbol = plugin . registerSymbol (
224+ buildSymbolIn ( {
225+ meta : {
226+ category : 'type' ,
227+ path,
228+ resource : 'operation' ,
229+ resourceId : operation . id ,
230+ role : 'responses' ,
231+ tags,
232+ tool : 'typescript' ,
233+ } ,
234+ name : applyNaming ( operation . id , plugin . config . responses ) ,
235+ operation,
236+ plugin,
237+ } ) ,
238+ ) ;
219239 const responsesNode = $ . type
220240 . alias ( responsesSymbol )
221241 . export ( )
222242 . type ( responsesResult ?. type ?? $ . type ( 'never' ) ) ;
223243 plugin . node ( responsesNode ) ;
224244
225245 if ( response ) {
226- const responseSymbol = plugin . symbol (
227- applyNaming ( operation . id , {
228- case : plugin . config . responses . case ,
229- name : plugin . config . responses . response ,
230- } ) ,
231- {
246+ const responseSymbol = plugin . registerSymbol (
247+ buildSymbolIn ( {
232248 meta : {
233249 category : 'type' ,
234250 path,
@@ -238,7 +254,13 @@ export const operationToType = ({
238254 tags,
239255 tool : 'typescript' ,
240256 } ,
241- } ,
257+ name : applyNaming ( operation . id , {
258+ case : plugin . config . responses . case ,
259+ name : plugin . config . responses . response ,
260+ } ) ,
261+ operation,
262+ plugin,
263+ } ) ,
242264 ) ;
243265 const responseNode = $ . type
244266 . alias ( responseSymbol )
0 commit comments