Skip to content

Commit f1752ba

Browse files
committed
Rename classes
1 parent 1d710a2 commit f1752ba

File tree

6 files changed

+24
-24
lines changed

6 files changed

+24
-24
lines changed

generate-routes.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ import { parseOptions } from 'lib/seam/connect/parse-options.js'
3636

3737
const renderClass = ({ endpoints }: Route): string =>
3838
`
39-
export class WorkspacesHttp {
39+
export class SeamHttpWorkspaces {
4040
client: Axios
4141
4242
constructor(apiKeyOrOptionsOrClient: Axios | string | SeamHttpOptions) {
@@ -90,15 +90,15 @@ const renderEndpointExports = ({
9090
namespace,
9191
requestFormat,
9292
}: Endpoint): string => `
93-
export type ${renderRequestType({
93+
type ${renderRequestType({
9494
name,
9595
namespace,
9696
requestFormat,
9797
})} = SetNonNullable<
9898
Required<RouteRequest${requestFormat}<'${path}'>>
9999
>
100100
101-
export type ${renderResponseType({ name, namespace })}= SetNonNullable<
101+
type ${renderResponseType({ name, namespace })}= SetNonNullable<
102102
Required<RouteResponse<'${path}'>>
103103
>
104104
`

src/lib/seam/connect/auth.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {
2-
InvalidSeamHttpOptionsError,
32
isSeamHttpOptionsWithApiKey,
43
isSeamHttpOptionsWithClientSessionToken,
4+
SeamHttpInvalidOptionsError,
55
type SeamHttpOptions,
66
type SeamHttpOptionsWithApiKey,
77
type SeamHttpOptionsWithClientSessionToken,
@@ -18,7 +18,7 @@ export const getAuthHeaders = (options: SeamHttpOptions): Headers => {
1818
return getAuthHeadersForClientSessionToken(options)
1919
}
2020

21-
throw new InvalidSeamHttpOptionsError(
21+
throw new SeamHttpInvalidOptionsError(
2222
'Must specify an apiKey or clientSessionToken',
2323
)
2424
}
@@ -27,19 +27,19 @@ const getAuthHeadersForApiKey = ({
2727
apiKey,
2828
}: SeamHttpOptionsWithApiKey): Headers => {
2929
if (isClientSessionToken(apiKey)) {
30-
throw new InvalidSeamTokenError(
30+
throw new SeamHttpInvalidTokenError(
3131
'A Client Session Token cannot be used as an apiKey',
3232
)
3333
}
3434

3535
if (isAccessToken(apiKey)) {
36-
throw new InvalidSeamTokenError(
36+
throw new SeamHttpInvalidTokenError(
3737
'An access token cannot be used as an apiKey',
3838
)
3939
}
4040

4141
if (isJwt(apiKey) || !isSeamToken(apiKey)) {
42-
throw new InvalidSeamTokenError(
42+
throw new SeamHttpInvalidTokenError(
4343
`Unknown or invalid apiKey format, expected token to start with ${tokenPrefix}`,
4444
)
4545
}
@@ -53,7 +53,7 @@ const getAuthHeadersForClientSessionToken = ({
5353
clientSessionToken,
5454
}: SeamHttpOptionsWithClientSessionToken): Headers => {
5555
if (!isClientSessionToken(clientSessionToken)) {
56-
throw new InvalidSeamTokenError(
56+
throw new SeamHttpInvalidTokenError(
5757
`Unknown or invalid clientSessionToken format, expected token to start with ${clientSessionTokenPrefix}`,
5858
)
5959
}
@@ -64,7 +64,7 @@ const getAuthHeadersForClientSessionToken = ({
6464
}
6565
}
6666

67-
export class InvalidSeamTokenError extends Error {
67+
export class SeamHttpInvalidTokenError extends Error {
6868
constructor(message: string) {
6969
super(`SeamHttp received an invalid token: ${message}`)
7070
this.name = this.constructor.name

src/lib/seam/connect/client-options.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const isSeamHttpOptionsWithApiKey = (
2020
if (!('apiKey' in options)) return false
2121

2222
if ('clientSessionToken' in options && options.clientSessionToken != null) {
23-
throw new InvalidSeamHttpOptionsError(
23+
throw new SeamHttpInvalidOptionsError(
2424
'The clientSessionToken option cannot be used with the apiKey option.',
2525
)
2626
}
@@ -39,15 +39,15 @@ export const isSeamHttpOptionsWithClientSessionToken = (
3939
if (!('clientSessionToken' in options)) return false
4040

4141
if ('apiKey' in options && options.apiKey != null) {
42-
throw new InvalidSeamHttpOptionsError(
42+
throw new SeamHttpInvalidOptionsError(
4343
'The clientSessionToken option cannot be used with the apiKey option.',
4444
)
4545
}
4646

4747
return true
4848
}
4949

50-
export class InvalidSeamHttpOptionsError extends Error {
50+
export class SeamHttpInvalidOptionsError extends Error {
5151
constructor(message: string) {
5252
super(`SeamHttp received invalid options: ${message}`)
5353
this.name = this.constructor.name

src/lib/seam/connect/client.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ import type { Axios } from 'axios'
22

33
import { createAxiosClient } from './axios.js'
44
import {
5-
InvalidSeamHttpOptionsError,
65
isSeamHttpOptionsWithApiKey,
76
isSeamHttpOptionsWithClientSessionToken,
7+
SeamHttpInvalidOptionsError,
88
type SeamHttpOptions,
99
type SeamHttpOptionsWithApiKey,
1010
type SeamHttpOptionsWithClientSessionToken,
1111
} from './client-options.js'
12-
import { LegacyWorkspacesHttp } from './legacy/workspaces.js'
12+
import { SeamHttpLegacyWorkspaces } from './legacy/workspaces.js'
1313
import { parseOptions } from './parse-options.js'
14-
import { WorkspacesHttp } from './routes/workspaces.js'
14+
import { SeamHttpWorkspaces } from './routes/workspaces.js'
1515

1616
export class SeamHttp {
1717
client: Axios
@@ -30,7 +30,7 @@ export class SeamHttp {
3030
): SeamHttp {
3131
const opts = { ...options, apiKey }
3232
if (!isSeamHttpOptionsWithApiKey(opts)) {
33-
throw new InvalidSeamHttpOptionsError('Missing apiKey')
33+
throw new SeamHttpInvalidOptionsError('Missing apiKey')
3434
}
3535
return new SeamHttp(opts)
3636
}
@@ -44,7 +44,7 @@ export class SeamHttp {
4444
): SeamHttp {
4545
const opts = { ...options, clientSessionToken }
4646
if (!isSeamHttpOptionsWithClientSessionToken(opts)) {
47-
throw new InvalidSeamHttpOptionsError('Missing clientSessionToken')
47+
throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
4848
}
4949
return new SeamHttp(opts)
5050
}
@@ -56,8 +56,8 @@ export class SeamHttp {
5656
// Better to implement error handling and wrapping in an error handler.
5757
// makeRequest
5858

59-
get workspaces(): WorkspacesHttp {
60-
if (this.#legacy) return new LegacyWorkspacesHttp(this.client)
61-
return new WorkspacesHttp(this.client)
59+
get workspaces(): SeamHttpWorkspaces {
60+
if (this.#legacy) return new SeamHttpLegacyWorkspaces(this.client)
61+
return new SeamHttpWorkspaces(this.client)
6262
}
6363
}

src/lib/seam/connect/legacy/workspaces.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import type { RouteRequestParams, RouteResponse } from '@seamapi/types/connect'
22
import type { SetNonNullable } from 'type-fest'
33

4-
import { WorkspacesHttp } from 'lib/seam/connect/routes/workspaces.js'
4+
import { SeamHttpWorkspaces } from 'lib/seam/connect/routes/workspaces.js'
55

6-
export class LegacyWorkspacesHttp extends WorkspacesHttp {
6+
export class SeamHttpLegacyWorkspaces extends SeamHttpWorkspaces {
77
override async get(
88
params: WorkspacesGetParams = {},
99
): Promise<WorkspacesGetResponse['workspace']> {

src/lib/seam/connect/routes/workspaces.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { createAxiosClient } from 'lib/seam/connect/axios.js'
66
import type { SeamHttpOptions } from 'lib/seam/connect/client-options.js'
77
import { parseOptions } from 'lib/seam/connect/parse-options.js'
88

9-
export class WorkspacesHttp {
9+
export class SeamHttpWorkspaces {
1010
client: Axios
1111

1212
constructor(apiKeyOrOptionsOrClient: Axios | string | SeamHttpOptions) {

0 commit comments

Comments
 (0)