-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathreplays.ts
More file actions
172 lines (153 loc) · 4.02 KB
/
replays.ts
File metadata and controls
172 lines (153 loc) · 4.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../../core/resource';
import { APIPromise } from '../../core/api-promise';
import { buildHeaders } from '../../internal/headers';
import { RequestOptions } from '../../internal/request-options';
import { path } from '../../internal/utils/path';
/**
* Record and manage browser session video replays.
*/
export class Replays extends APIResource {
/**
* List all replays for the specified browser session.
*
* @example
* ```ts
* const replays = await client.browsers.replays.list('id');
* ```
*/
list(id: string, options?: RequestOptions): APIPromise<ReplayListResponse> {
return this._client.get(path`/browsers/${id}/replays`, options);
}
/**
* Download or stream the specified replay recording.
*
* @example
* ```ts
* const response = await client.browsers.replays.download(
* 'replay_id',
* { id: 'id' },
* );
*
* const content = await response.blob();
* console.log(content);
* ```
*/
download(replayID: string, params: ReplayDownloadParams, options?: RequestOptions): APIPromise<Response> {
const { id } = params;
return this._client.get(path`/browsers/${id}/replays/${replayID}`, {
...options,
headers: buildHeaders([{ Accept: 'video/mp4' }, options?.headers]),
__binaryResponse: true,
});
}
/**
* Start recording the browser session and return a replay ID.
*
* @example
* ```ts
* const response = await client.browsers.replays.start('id');
* ```
*/
start(
id: string,
body: ReplayStartParams | null | undefined = {},
options?: RequestOptions,
): APIPromise<ReplayStartResponse> {
return this._client.post(path`/browsers/${id}/replays`, { body, ...options });
}
/**
* Stop the specified replay recording and persist the video.
*
* @example
* ```ts
* await client.browsers.replays.stop('replay_id', {
* id: 'id',
* });
* ```
*/
stop(replayID: string, params: ReplayStopParams, options?: RequestOptions): APIPromise<void> {
const { id } = params;
return this._client.post(path`/browsers/${id}/replays/${replayID}/stop`, {
...options,
headers: buildHeaders([{ Accept: '*/*' }, options?.headers]),
});
}
}
export type ReplayListResponse = Array<ReplayListResponse.ReplayListResponseItem>;
export namespace ReplayListResponse {
/**
* Information about a browser replay recording.
*/
export interface ReplayListResponseItem {
/**
* Unique identifier for the replay recording.
*/
replay_id: string;
/**
* Timestamp when replay finished
*/
finished_at?: string | null;
/**
* URL for viewing the replay recording.
*/
replay_view_url?: string;
/**
* Timestamp when replay started
*/
started_at?: string | null;
}
}
/**
* Information about a browser replay recording.
*/
export interface ReplayStartResponse {
/**
* Unique identifier for the replay recording.
*/
replay_id: string;
/**
* Timestamp when replay finished
*/
finished_at?: string | null;
/**
* URL for viewing the replay recording.
*/
replay_view_url?: string;
/**
* Timestamp when replay started
*/
started_at?: string | null;
}
export interface ReplayDownloadParams {
/**
* Browser session ID
*/
id: string;
}
export interface ReplayStartParams {
/**
* Recording framerate in fps. Values above 20 require GPU to be enabled on the
* browser session.
*/
framerate?: number;
/**
* Maximum recording duration in seconds.
*/
max_duration_in_seconds?: number;
}
export interface ReplayStopParams {
/**
* Browser session ID
*/
id: string;
}
export declare namespace Replays {
export {
type ReplayListResponse as ReplayListResponse,
type ReplayStartResponse as ReplayStartResponse,
type ReplayDownloadParams as ReplayDownloadParams,
type ReplayStartParams as ReplayStartParams,
type ReplayStopParams as ReplayStopParams,
};
}