Skip to content

Commit

Permalink
Fix type names with Params vs Boyd
Browse files Browse the repository at this point in the history
  • Loading branch information
razor-x committed Nov 2, 2023
1 parent 87c68b3 commit bd00c49
Show file tree
Hide file tree
Showing 19 changed files with 91 additions and 77 deletions.
21 changes: 16 additions & 5 deletions generate-routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,6 @@ const renderClassMethod = ({
}: ${renderRequestType({
name,
namespace,
requestFormat,
})},
): Promise<${
resource === null
Expand Down Expand Up @@ -363,7 +362,6 @@ const renderEndpointExports = ({
export type ${renderRequestType({
name,
namespace,
requestFormat,
})} = RouteRequest${pascalCase(requestFormat)}<'${path}'>
export type ${renderResponseType({ name, namespace })}= SetNonNullable<
Expand All @@ -374,9 +372,22 @@ export type ${renderResponseType({ name, namespace })}= SetNonNullable<
const renderRequestType = ({
name,
namespace,
requestFormat,
}: Pick<Endpoint, 'name' | 'namespace' | 'requestFormat'>): string =>
[pascalCase(namespace), pascalCase(name), pascalCase(requestFormat)].join('')
}: Pick<Endpoint, 'name' | 'namespace'>): string =>
[
pascalCase(namespace),
pascalCase(name),
pascalCase(requestFormatToRequestType(name, namespace)),
].join('')

// UPSTREAM: Should be just requestFormat, but blocked on https://github.com/seamapi/nextlove/issues/117
const requestFormatToRequestType = (
name: string,
_namespace: string,
): 'params' | 'body' => {
if (['get', 'list', 'view'].includes(name)) return 'params'
if (name.startsWith('list')) return 'params'
return 'body'
}

const renderResponseType = ({
name,
Expand Down
8 changes: 4 additions & 4 deletions src/lib/seam/connect/routes/access-codes-unmanaged.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export class SeamHttpAccessCodesUnmanaged {
}

async get(
body: AccessCodesUnmanagedGetBody,
body: AccessCodesUnmanagedGetParams,
): Promise<AccessCodesUnmanagedGetResponse['access_code']> {
const { data } = await this.client.request<AccessCodesUnmanagedGetResponse>(
{
Expand All @@ -114,7 +114,7 @@ export class SeamHttpAccessCodesUnmanaged {
}

async list(
body: AccessCodesUnmanagedListBody,
body: AccessCodesUnmanagedListParams,
): Promise<AccessCodesUnmanagedListResponse['access_codes']> {
const { data } =
await this.client.request<AccessCodesUnmanagedListResponse>({
Expand Down Expand Up @@ -148,14 +148,14 @@ export type AccessCodesUnmanagedDeleteResponse = SetNonNullable<
Required<RouteResponse<'/access_codes/unmanaged/delete'>>
>

export type AccessCodesUnmanagedGetBody =
export type AccessCodesUnmanagedGetParams =
RouteRequestBody<'/access_codes/unmanaged/get'>

export type AccessCodesUnmanagedGetResponse = SetNonNullable<
Required<RouteResponse<'/access_codes/unmanaged/get'>>
>

export type AccessCodesUnmanagedListBody =
export type AccessCodesUnmanagedListParams =
RouteRequestBody<'/access_codes/unmanaged/list'>

export type AccessCodesUnmanagedListResponse = SetNonNullable<
Expand Down
8 changes: 4 additions & 4 deletions src/lib/seam/connect/routes/access-codes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export class SeamHttpAccessCodes {
}

async get(
body: AccessCodesGetBody,
body: AccessCodesGetParams,
): Promise<AccessCodesGetResponse['access_code']> {
const { data } = await this.client.request<AccessCodesGetResponse>({
url: '/access_codes/get',
Expand All @@ -143,7 +143,7 @@ export class SeamHttpAccessCodes {
}

async list(
body: AccessCodesListBody,
body: AccessCodesListParams,
): Promise<AccessCodesListResponse['access_codes']> {
const { data } = await this.client.request<AccessCodesListResponse>({
url: '/access_codes/list',
Expand Down Expand Up @@ -200,13 +200,13 @@ export type AccessCodesGenerateCodeResponse = SetNonNullable<
Required<RouteResponse<'/access_codes/generate_code'>>
>

export type AccessCodesGetBody = RouteRequestBody<'/access_codes/get'>
export type AccessCodesGetParams = RouteRequestBody<'/access_codes/get'>

export type AccessCodesGetResponse = SetNonNullable<
Required<RouteResponse<'/access_codes/get'>>
>

export type AccessCodesListBody = RouteRequestBody<'/access_codes/list'>
export type AccessCodesListParams = RouteRequestBody<'/access_codes/list'>

export type AccessCodesListResponse = SetNonNullable<
Required<RouteResponse<'/access_codes/list'>>
Expand Down
13 changes: 7 additions & 6 deletions src/lib/seam/connect/routes/acs-access-groups.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export class SeamHttpAcsAccessGroups {
}

async get(
body: AcsAccessGroupsGetBody,
body: AcsAccessGroupsGetParams,
): Promise<AcsAccessGroupsGetResponse['acs_access_group']> {
const { data } = await this.client.request<AcsAccessGroupsGetResponse>({
url: '/acs/access_groups/get',
Expand All @@ -121,7 +121,7 @@ export class SeamHttpAcsAccessGroups {
}

async list(
body: AcsAccessGroupsListBody,
body: AcsAccessGroupsListParams,
): Promise<AcsAccessGroupsListResponse['acs_access_groups']> {
const { data } = await this.client.request<AcsAccessGroupsListResponse>({
url: '/acs/access_groups/list',
Expand All @@ -132,7 +132,7 @@ export class SeamHttpAcsAccessGroups {
}

async listUsers(
body: AcsAccessGroupsListUsersBody,
body: AcsAccessGroupsListUsersParams,
): Promise<AcsAccessGroupsListUsersResponse['acs_users']> {
const { data } =
await this.client.request<AcsAccessGroupsListUsersResponse>({
Expand Down Expand Up @@ -181,20 +181,21 @@ export type AcsAccessGroupsDeleteResponse = SetNonNullable<
Required<RouteResponse<'/acs/access_groups/delete'>>
>

export type AcsAccessGroupsGetBody = RouteRequestBody<'/acs/access_groups/get'>
export type AcsAccessGroupsGetParams =
RouteRequestBody<'/acs/access_groups/get'>

export type AcsAccessGroupsGetResponse = SetNonNullable<
Required<RouteResponse<'/acs/access_groups/get'>>
>

export type AcsAccessGroupsListBody =
export type AcsAccessGroupsListParams =
RouteRequestBody<'/acs/access_groups/list'>

export type AcsAccessGroupsListResponse = SetNonNullable<
Required<RouteResponse<'/acs/access_groups/list'>>
>

export type AcsAccessGroupsListUsersBody =
export type AcsAccessGroupsListUsersParams =
RouteRequestBody<'/acs/access_groups/list_users'>

export type AcsAccessGroupsListUsersResponse = SetNonNullable<
Expand Down
8 changes: 4 additions & 4 deletions src/lib/seam/connect/routes/acs-credentials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export class SeamHttpAcsCredentials {
}

async get(
body: AcsCredentialsGetBody,
body: AcsCredentialsGetParams,
): Promise<AcsCredentialsGetResponse['acs_credential']> {
const { data } = await this.client.request<AcsCredentialsGetResponse>({
url: '/acs/credentials/get',
Expand All @@ -113,7 +113,7 @@ export class SeamHttpAcsCredentials {
}

async list(
body: AcsCredentialsListBody,
body: AcsCredentialsListParams,
): Promise<AcsCredentialsListResponse['acs_credentials']> {
const { data } = await this.client.request<AcsCredentialsListResponse>({
url: '/acs/credentials/list',
Expand All @@ -138,13 +138,13 @@ export type AcsCredentialsDeleteResponse = SetNonNullable<
Required<RouteResponse<'/acs/credentials/delete'>>
>

export type AcsCredentialsGetBody = RouteRequestBody<'/acs/credentials/get'>
export type AcsCredentialsGetParams = RouteRequestBody<'/acs/credentials/get'>

export type AcsCredentialsGetResponse = SetNonNullable<
Required<RouteResponse<'/acs/credentials/get'>>
>

export type AcsCredentialsListBody = RouteRequestBody<'/acs/credentials/list'>
export type AcsCredentialsListParams = RouteRequestBody<'/acs/credentials/list'>

export type AcsCredentialsListResponse = SetNonNullable<
Required<RouteResponse<'/acs/credentials/list'>>
Expand Down
8 changes: 4 additions & 4 deletions src/lib/seam/connect/routes/acs-systems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class SeamHttpAcsSystems {
}

async get(
body: AcsSystemsGetBody,
body: AcsSystemsGetParams,
): Promise<AcsSystemsGetResponse['acs_system']> {
const { data } = await this.client.request<AcsSystemsGetResponse>({
url: '/acs/systems/get',
Expand All @@ -94,7 +94,7 @@ export class SeamHttpAcsSystems {
}

async list(
body: AcsSystemsListBody,
body: AcsSystemsListParams,
): Promise<AcsSystemsListResponse['acs_systems']> {
const { data } = await this.client.request<AcsSystemsListResponse>({
url: '/acs/systems/list',
Expand All @@ -105,13 +105,13 @@ export class SeamHttpAcsSystems {
}
}

export type AcsSystemsGetBody = RouteRequestBody<'/acs/systems/get'>
export type AcsSystemsGetParams = RouteRequestBody<'/acs/systems/get'>

export type AcsSystemsGetResponse = SetNonNullable<
Required<RouteResponse<'/acs/systems/get'>>
>

export type AcsSystemsListBody = RouteRequestBody<'/acs/systems/list'>
export type AcsSystemsListParams = RouteRequestBody<'/acs/systems/list'>

export type AcsSystemsListResponse = SetNonNullable<
Required<RouteResponse<'/acs/systems/list'>>
Expand Down
8 changes: 4 additions & 4 deletions src/lib/seam/connect/routes/acs-users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export class SeamHttpAcsUsers {
})
}

async get(body: AcsUsersGetBody): Promise<AcsUsersGetResponse['acs_user']> {
async get(body: AcsUsersGetParams): Promise<AcsUsersGetResponse['acs_user']> {
const { data } = await this.client.request<AcsUsersGetResponse>({
url: '/acs/users/get',
method: 'post',
Expand All @@ -119,7 +119,7 @@ export class SeamHttpAcsUsers {
}

async list(
body: AcsUsersListBody,
body: AcsUsersListParams,
): Promise<AcsUsersListResponse['acs_users']> {
const { data } = await this.client.request<AcsUsersListResponse>({
url: '/acs/users/list',
Expand Down Expand Up @@ -183,13 +183,13 @@ export type AcsUsersDeleteResponse = SetNonNullable<
Required<RouteResponse<'/acs/users/delete'>>
>

export type AcsUsersGetBody = RouteRequestBody<'/acs/users/get'>
export type AcsUsersGetParams = RouteRequestBody<'/acs/users/get'>

export type AcsUsersGetResponse = SetNonNullable<
Required<RouteResponse<'/acs/users/get'>>
>

export type AcsUsersListBody = RouteRequestBody<'/acs/users/list'>
export type AcsUsersListParams = RouteRequestBody<'/acs/users/list'>

export type AcsUsersListResponse = SetNonNullable<
Required<RouteResponse<'/acs/users/list'>>
Expand Down
8 changes: 4 additions & 4 deletions src/lib/seam/connect/routes/action-attempts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export class SeamHttpActionAttempts {
}

async get(
body: ActionAttemptsGetBody,
body: ActionAttemptsGetParams,
): Promise<ActionAttemptsGetResponse['action_attempt']> {
const { data } = await this.client.request<ActionAttemptsGetResponse>({
url: '/action_attempts/get',
Expand All @@ -94,7 +94,7 @@ export class SeamHttpActionAttempts {
}

async list(
body: ActionAttemptsListBody,
body: ActionAttemptsListParams,
): Promise<ActionAttemptsListResponse['action_attempts']> {
const { data } = await this.client.request<ActionAttemptsListResponse>({
url: '/action_attempts/list',
Expand All @@ -105,13 +105,13 @@ export class SeamHttpActionAttempts {
}
}

export type ActionAttemptsGetBody = RouteRequestBody<'/action_attempts/get'>
export type ActionAttemptsGetParams = RouteRequestBody<'/action_attempts/get'>

export type ActionAttemptsGetResponse = SetNonNullable<
Required<RouteResponse<'/action_attempts/get'>>
>

export type ActionAttemptsListBody = RouteRequestBody<'/action_attempts/list'>
export type ActionAttemptsListParams = RouteRequestBody<'/action_attempts/list'>

export type ActionAttemptsListResponse = SetNonNullable<
Required<RouteResponse<'/action_attempts/list'>>
Expand Down
8 changes: 4 additions & 4 deletions src/lib/seam/connect/routes/client-sessions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export class SeamHttpClientSessions {
}

async get(
body: ClientSessionsGetBody,
body: ClientSessionsGetParams,
): Promise<ClientSessionsGetResponse['client_session']> {
const { data } = await this.client.request<ClientSessionsGetResponse>({
url: '/client_sessions/get',
Expand Down Expand Up @@ -135,7 +135,7 @@ export class SeamHttpClientSessions {
}

async list(
body: ClientSessionsListBody,
body: ClientSessionsListParams,
): Promise<ClientSessionsListResponse['client_sessions']> {
const { data } = await this.client.request<ClientSessionsListResponse>({
url: '/client_sessions/list',
Expand All @@ -160,7 +160,7 @@ export type ClientSessionsDeleteResponse = SetNonNullable<
Required<RouteResponse<'/client_sessions/delete'>>
>

export type ClientSessionsGetBody = RouteRequestBody<'/client_sessions/get'>
export type ClientSessionsGetParams = RouteRequestBody<'/client_sessions/get'>

export type ClientSessionsGetResponse = SetNonNullable<
Required<RouteResponse<'/client_sessions/get'>>
Expand All @@ -180,7 +180,7 @@ export type ClientSessionsGrantAccessResponse = SetNonNullable<
Required<RouteResponse<'/client_sessions/grant_access'>>
>

export type ClientSessionsListBody = RouteRequestBody<'/client_sessions/list'>
export type ClientSessionsListParams = RouteRequestBody<'/client_sessions/list'>

export type ClientSessionsListResponse = SetNonNullable<
Required<RouteResponse<'/client_sessions/list'>>
Expand Down
9 changes: 5 additions & 4 deletions src/lib/seam/connect/routes/connect-webviews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export class SeamHttpConnectWebviews {
}

async get(
body: ConnectWebviewsGetBody,
body: ConnectWebviewsGetParams,
): Promise<ConnectWebviewsGetResponse['connect_webview']> {
const { data } = await this.client.request<ConnectWebviewsGetResponse>({
url: '/connect_webviews/get',
Expand All @@ -117,7 +117,7 @@ export class SeamHttpConnectWebviews {
}

async list(
body: ConnectWebviewsListBody,
body: ConnectWebviewsListParams,
): Promise<ConnectWebviewsListResponse['connect_webviews']> {
const { data } = await this.client.request<ConnectWebviewsListResponse>({
url: '/connect_webviews/list',
Expand Down Expand Up @@ -150,13 +150,14 @@ export type ConnectWebviewsDeleteResponse = SetNonNullable<
Required<RouteResponse<'/connect_webviews/delete'>>
>

export type ConnectWebviewsGetBody = RouteRequestBody<'/connect_webviews/get'>
export type ConnectWebviewsGetParams = RouteRequestBody<'/connect_webviews/get'>

export type ConnectWebviewsGetResponse = SetNonNullable<
Required<RouteResponse<'/connect_webviews/get'>>
>

export type ConnectWebviewsListBody = RouteRequestBody<'/connect_webviews/list'>
export type ConnectWebviewsListParams =
RouteRequestBody<'/connect_webviews/list'>

export type ConnectWebviewsListResponse = SetNonNullable<
Required<RouteResponse<'/connect_webviews/list'>>
Expand Down
4 changes: 2 additions & 2 deletions src/lib/seam/connect/routes/connected-accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export class SeamHttpConnectedAccounts {
}

async get(
body: ConnectedAccountsGetBody,
body: ConnectedAccountsGetParams,
): Promise<ConnectedAccountsGetResponse['connected_account']> {
const { data } = await this.client.request<ConnectedAccountsGetResponse>({
url: '/connected_accounts/get',
Expand Down Expand Up @@ -124,7 +124,7 @@ export type ConnectedAccountsDeleteResponse = SetNonNullable<
Required<RouteResponse<'/connected_accounts/delete'>>
>

export type ConnectedAccountsGetBody =
export type ConnectedAccountsGetParams =
RouteRequestBody<'/connected_accounts/get'>

export type ConnectedAccountsGetResponse = SetNonNullable<
Expand Down
Loading

0 comments on commit bd00c49

Please sign in to comment.