refactor: use satisfies for fetch body types in screen-recording

This commit is contained in:
Tommy D. Rossi
2026-01-23 17:25:21 +01:00
parent e79dd472db
commit b159d6fbc7
2 changed files with 17 additions and 4 deletions
+5
View File
@@ -89,6 +89,11 @@ export type StartRecordingParams = {
audioBitsPerSecond?: number
}
/** HTTP body for /recording/start endpoint */
export type StartRecordingBody = StartRecordingParams & {
outputPath: string
}
export type StopRecordingParams = {
sessionId?: string
}
+12 -4
View File
@@ -6,7 +6,15 @@
*/
import type { Page } from 'playwright-core'
import type { StartRecordingResult, StopRecordingResult, IsRecordingResult, CancelRecordingResult } from './protocol.js'
import type {
StartRecordingBody,
StopRecordingParams,
CancelRecordingParams,
StartRecordingResult,
StopRecordingResult,
IsRecordingResult,
CancelRecordingResult,
} from './protocol.js'
export interface StartRecordingOptions {
/** Target page to record */
@@ -72,7 +80,7 @@ export async function startRecording(options: StartRecordingOptions): Promise<Re
audioBitsPerSecond,
audio,
outputPath,
}),
} satisfies StartRecordingBody),
})
const result = await response.json() as StartRecordingResult
@@ -100,7 +108,7 @@ export async function stopRecording(options: StopRecordingOptions): Promise<{ pa
const response = await fetch(`http://127.0.0.1:${relayPort}/recording/stop`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ sessionId }),
body: JSON.stringify({ sessionId } satisfies StopRecordingParams),
})
const result = await response.json() as StopRecordingResult
@@ -145,7 +153,7 @@ export async function cancelRecording(options: { page: Page; relayPort?: number
const response = await fetch(`http://127.0.0.1:${relayPort}/recording/cancel`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ sessionId }),
body: JSON.stringify({ sessionId } satisfies CancelRecordingParams),
})
const result = await response.json() as CancelRecordingResult