1import type * as kv from "@distilled.cloud/aws/kinesis-video";
2import type * as kvws from "@distilled.cloud/aws/kinesis-video-webrtc-storage";
3import type * as Effect from "effect/Effect";
4import * as Binding from "../../Binding.ts";
5import type { SignalingEndpointUnavailable } from "./internal.ts";
6import type { SignalingChannel } from "./SignalingChannel.ts";
7
8export interface JoinStorageSessionAsViewerRequest extends Omit<
9 kvws.JoinStorageSessionAsViewerInput,
10 "channelArn"
11> {}
12
13/**
14 * Runtime binding for `kinesisvideo:JoinStorageSessionAsViewer` (WebRTC
15 * storage data plane).
16 *
17 * Bind this operation to a `SignalingChannel` inside a function runtime to
18 * get a callable that resolves the per-channel WEBRTC storage endpoint
19 * (`GetSignalingChannelEndpoint`) and joins the ongoing WebRTC session as
20 * a viewer, identified by `clientId`.
21 *
22 * Requires the channel's media storage to be configured (an ENABLED
23 * `MediaStorageConfiguration` linking the channel to a stream); without it
24 * the endpoint discovery fails with the typed `SignalingEndpointUnavailable`
25 * error.
26 * ### WebRTC Storage
27 * **Example:** Join a Storage Session as Viewer
28 * ```typescript
29 * // init
30 * const joinAsViewer =
31 * yield* AWS.KinesisVideo.JoinStorageSessionAsViewer(channel);
32 *
33 * // runtime
34 * yield* joinAsViewer({ clientId: "viewer-1" });
35 * ```
36 *
37 * @binding
38 */
39export interface JoinStorageSessionAsViewer extends Binding.Service<
40 JoinStorageSessionAsViewer,
41 "AWS.KinesisVideo.JoinStorageSessionAsViewer",
42 <C extends SignalingChannel>(
43 channel: C,
44 ) => Effect.Effect<
45 (
46 request: JoinStorageSessionAsViewerRequest,
47 ) => Effect.Effect<
48 kvws.JoinStorageSessionAsViewerResponse,
49 | kvws.JoinStorageSessionAsViewerError
50 | kv.GetSignalingChannelEndpointError
51 | SignalingEndpointUnavailable
52 >
53 >
54> {}
55
56export const JoinStorageSessionAsViewer =
57 Binding.Service<JoinStorageSessionAsViewer>(
58 "AWS.KinesisVideo.JoinStorageSessionAsViewer",
59 );