Skip to content

Commit 71a51b0

Browse files
committed
feat: Add named Request types
1 parent 404817d commit 71a51b0

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
(
22
parameters{{#if isOptionalParamsOk}}?{{/if}}: {{parametersTypeName}},
33
options{{#if isFnType}}?{{/if}}: {{optionsTypeName}}{{#unless isFnType}} = {}{{/unless}},
4-
){{#if isFnType}} => {{else}}: {{/if}} SeamHttpRequest<{{#if returnsVoid}}void, undefined{{else}}{{responseTypeName}}, '{{responseKey}}'{{/if}}>
4+
){{#if isFnType}} => {{else}}: {{/if}}{{requestTypeName}}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@ export type {{parametersTypeName}} = RouteRequest{{requestFormatSuffix}}<'{{path
55
*/
66
export type {{legacyRequestTypeName}} = {{parametersTypeName}}
77

8+
/**
9+
* @deprecated Use {{requestTypeName}} instead.
10+
*/
811
export type {{responseTypeName}} = SetNonNullable<
912
Required<RouteResponse<'{{path}}'>>
1013
>
1114

15+
export type {{requestTypeName}} = SeamHttpRequest<{{#if returnsVoid}}void, undefined{{else}}{{responseTypeName}}, '{{responseKey}}'{{/if}}>
16+
1217
export type {{optionsTypeName}} = {{#if returnsActionAttempt}}Pick<SeamHttpRequestOptions, 'waitForActionAttempt'>{{else}}Record<string, never>{{/if}}

codegen/lib/layouts/endpoints.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export const setEndpointsLayoutContext = (
4141
typeNames: endpoints.flatMap((endpoint) => [
4242
endpoint.parametersTypeName,
4343
endpoint.optionsTypeName,
44-
endpoint.responseTypeName,
44+
endpoint.requestTypeName,
4545
]),
4646
}
4747
})

codegen/lib/layouts/route.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export interface EndpointLayoutContext {
2727
responseTypeName: string
2828
requestFormatSuffix: string
2929
optionsTypeName: string
30+
requestTypeName: string
3031
returnsActionAttempt: boolean
3132
returnsVoid: boolean
3233
isOptionalParamsOk: boolean
@@ -111,6 +112,7 @@ export const getEndpointLayoutContext = (
111112
legacyRequestTypeName: `${prefix}${pascalCase(legacyMethodParamName)}`,
112113
responseTypeName: `${prefix}Response`,
113114
optionsTypeName: `${prefix}Options`,
115+
requestTypeName: `${prefix}Request`,
114116
// UPSTREAM: Needs support in blueprint, fallback to true for now.
115117
// https://github.com/seamapi/blueprint/issues/205
116118
isOptionalParamsOk: true,

0 commit comments

Comments
 (0)