Skip to content

Commit d8863db

Browse files
committed
Move ResponseFromSeamHttpRequest to test
1 parent 724ad99 commit d8863db

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

src/lib/seam/connect/seam-http-request.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,9 @@ export interface SeamHttpRequestConfig<TBody, TResponseKey> {
1616
readonly params?: any
1717
readonly data?: TBody
1818
readonly responseKey: TResponseKey
19-
readonly options: Pick<SeamHttpRequestOptions, 'waitForActionAttempt'>
19+
readonly options?: Pick<SeamHttpRequestOptions, 'waitForActionAttempt'>
2020
}
2121

22-
export type ResponseFromSeamHttpRequest<T> =
23-
T extends SeamHttpRequest<any, infer TResponse, infer TResponseKey>
24-
? TResponseKey extends keyof TResponse
25-
? TResponse[TResponseKey]
26-
: undefined
27-
: never
28-
2922
export class SeamHttpRequest<
3023
const TBody,
3124
const TResponse,
@@ -58,7 +51,7 @@ export class SeamHttpRequest<
5851
return this.#config.method ?? 'get'
5952
}
6053

61-
public get params() {
54+
public get params(): any {
6255
return this.#config.params
6356
}
6457

@@ -84,7 +77,7 @@ export class SeamHttpRequest<
8477
const data = response.data[this.responseKey]
8578
if (this.responseKey === 'action_attempt') {
8679
const waitForActionAttempt =
87-
this.#config.options.waitForActionAttempt ??
80+
this.#config.options?.waitForActionAttempt ??
8881
this.#parent.defaults.waitForActionAttempt
8982
if (waitForActionAttempt !== false) {
9083
return await resolveActionAttempt(

test/seam/connect/seam-http-request.test.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,9 @@ import { getTestServer } from 'fixtures/seam/connect/api.js'
33

44
import { SeamHttp } from '@seamapi/http/connect'
55

6-
import {
7-
type ResponseFromSeamHttpRequest,
8-
SeamHttpRequest,
9-
} from 'lib/seam/connect/seam-http-request.js'
6+
import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js'
107

11-
test('serializes array params when undefined', async (t) => {
8+
test('returns a SeamHttpRequest', async (t) => {
129
const { seed, endpoint } = await getTestServer(t)
1310
const seam = SeamHttp.fromApiKey(seed.seam_apikey1_token, { endpoint })
1411

@@ -34,3 +31,10 @@ test('serializes array params when undefined', async (t) => {
3431
const invalidDeviceType: Expected['device_type'] = 'invalid_device_type'
3532
t.truthy(invalidDeviceType)
3633
})
34+
35+
type ResponseFromSeamHttpRequest<T> =
36+
T extends SeamHttpRequest<any, infer TResponse, infer TResponseKey>
37+
? TResponseKey extends keyof TResponse
38+
? TResponse[TResponseKey]
39+
: undefined
40+
: never

0 commit comments

Comments
 (0)