Skip to content

Commit a9a0278

Browse files
committed
feat: Add normalized Parameters types
1 parent 359031a commit a9a0278

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

codegen/layouts/partials/route-class-endpoint-export.hbs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
export type {{requestTypeName}} = RouteRequest{{requestFormatSuffix}}<'{{path}}'>
1+
export type {{parametersTypeName}} = RouteRequest{{requestFormatSuffix}}<'{{path}}'>
2+
3+
/**
4+
* @deprecated Use {{parametersTypeName}} instead.
5+
*/
6+
export type {{legacyRequestTypeName}} = {{parametersTypeName}}
27

38
export type {{responseTypeName}} = SetNonNullable<
49
Required<RouteResponse<'{{path}}'>>

codegen/layouts/partials/route-class-endpoint.hbs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{methodName}}(
2-
{{methodParamName}}{{#if isOptionalParamsOk}}?{{/if}}: {{requestTypeName}},
2+
parameters{{#if isOptionalParamsOk}}?{{/if}}: {{parametersTypeName}},
33
options: {{optionsTypeName}} = {},
44
): SeamHttpRequest<{{#if returnsVoid}}void, undefined{{else}}{{responseTypeName}}, '{{responseKey}}'{{/if}}>
55
{
@@ -11,7 +11,7 @@
1111
return new SeamHttpRequest(this, {
1212
pathname: '{{path}}',
1313
method: '{{method}}',
14-
{{requestFormat}}: {{methodParamName}},
14+
{{requestFormat}}: parameters,
1515
responseKey: {{#if returnsVoid}}undefined{{else}}'{{responseKey}}'{{/if}},
1616
options,
1717
})

codegen/lib/layouts/route.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ export interface EndpointLayoutContext {
2121
className: string
2222
method: Method
2323
responseKey: string
24-
methodParamName: 'params' | 'body'
2524
requestFormat: 'params' | 'body'
26-
requestTypeName: string
25+
parametersTypeName: string
26+
legacyRequestTypeName: string
2727
responseTypeName: string
2828
requestFormatSuffix: string
2929
optionsTypeName: string
@@ -78,7 +78,7 @@ export const getEndpointLayoutContext = (
7878
): EndpointLayoutContext => {
7979
const prefix = pascalCase([route.path.split('/'), endpoint.name].join('_'))
8080

81-
const methodParamName = ['GET', 'DELETE'].includes(
81+
const legacyMethodParamName = ['GET', 'DELETE'].includes(
8282
endpoint.request.semanticMethod,
8383
)
8484
? 'params'
@@ -104,11 +104,11 @@ export const getEndpointLayoutContext = (
104104
functionName: camelCase(prefix),
105105
method: endpoint.request.preferredMethod,
106106
className: getClassName(route.path),
107-
methodParamName,
108107
requestFormat,
109108
requestFormatSuffix,
110109
returnsActionAttempt,
111-
requestTypeName: `${prefix}${pascalCase(methodParamName)}`,
110+
parametersTypeName: `${prefix}Parameters`,
111+
legacyRequestTypeName: `${prefix}${pascalCase(legacyMethodParamName)}`,
112112
responseTypeName: `${prefix}Response`,
113113
optionsTypeName: `${prefix}Options`,
114114
// UPSTREAM: Needs support in blueprint, fallback to true for now.

0 commit comments

Comments
 (0)