Skip to content

Commit

Permalink
Use RouteResponse and RouteRequestParams
Browse files Browse the repository at this point in the history
  • Loading branch information
razor-x committed Sep 21, 2023
1 parent 73fb0e0 commit 43a7cf9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 24 deletions.
18 changes: 6 additions & 12 deletions src/lib/seam/connect/legacy/workspaces.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// TODO: Example of non-generated overrides to methods to preserve legacy behavior
import type { Routes } from '@seamapi/types/connect'
import type { RouteRequestParams, RouteResponse } from '@seamapi/types/connect'
import type { SetNonNullable } from 'type-fest'

import { Workspaces } from 'lib/seam/connect/routes/workspaces.js'

export class LegacyWorkspaces extends Workspaces {
override async get(params: WorkspacesGetParams = {}): Promise<Workspace> {
override async get(
params: WorkspacesGetParams = {},
): Promise<WorkspacesGetResponse['workspace']> {
const {
data: { workspace },
} = await this.client.get<WorkspacesGetResponse>('/workspaces/get', {
Expand All @@ -16,16 +17,9 @@ export class LegacyWorkspaces extends Workspaces {
}

export type WorkspacesGetParams = SetNonNullable<
Required<Routes['/workspaces/get']['commonParams']>
Required<RouteRequestParams<'/workspaces/get'>>
>

export type WorkspacesGetResponse = SetNonNullable<
Required<Routes['/workspaces/get']['jsonResponse']>
Required<RouteResponse<'/workspaces/get'>>
>

// UPSTREAM: Should come from @seamapi/types/connect
// import type { Workspace } from @seamapi/types
// export type { Workspace } from '@seamapi/types/connect'
export interface Workspace {
workspace_id: string
}
18 changes: 6 additions & 12 deletions src/lib/seam/connect/routes/workspaces.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// TODO: This file is generated from route spec
import type { Routes } from '@seamapi/types/connect'
import type { RouteRequestParams, RouteResponse } from '@seamapi/types/connect'
import type { Axios } from 'axios'
import type { SetNonNullable } from 'type-fest'

Expand All @@ -10,7 +9,9 @@ export class Workspaces {
this.client = client
}

async get(params: WorkspacesGetParams = {}): Promise<Workspace> {
async get(
params: WorkspacesGetParams = {},
): Promise<WorkspacesGetResponse['workspace']> {
const {
data: { workspace },
} = await this.client.get<WorkspacesGetResponse>('/workspaces/get', {
Expand All @@ -21,16 +22,9 @@ export class Workspaces {
}

export type WorkspacesGetParams = SetNonNullable<
Required<Routes['/workspaces/get']['commonParams']>
Required<RouteRequestParams<'/workspaces/get'>>
>

export type WorkspacesGetResponse = SetNonNullable<
Required<Routes['/workspaces/get']['jsonResponse']>
Required<RouteResponse<'/workspaces/get'>>
>

// UPSTREAM: Should come from @seamapi/types/connect
// import type { Workspace } from @seamapi/types
// export type { Workspace } from '@seamapi/types/connect'
export interface Workspace {
workspace_id: string
}

0 comments on commit 43a7cf9

Please sign in to comment.