@seamapi/http 2.34.0 → 2.35.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/resources/action-attempt.d.ts +63 -0
- package/lib/resources/camera-live-view-answer.d.ts +9 -0
- package/lib/resources/camera-live-view-answer.js +6 -0
- package/lib/resources/camera-live-view-answer.js.map +1 -0
- package/lib/resources/camera-live-view-session.d.ts +21 -0
- package/lib/resources/camera-live-view-session.js +6 -0
- package/lib/resources/camera-live-view-session.js.map +1 -0
- package/lib/resources/device-provider.d.ts +8 -0
- package/lib/resources/device.d.ts +8 -0
- package/lib/resources/event.d.ts +8 -0
- package/lib/resources/index.d.ts +3 -0
- package/lib/resources/media.d.ts +45 -0
- package/lib/resources/media.js +6 -0
- package/lib/resources/media.js.map +1 -0
- package/lib/resources/unmanaged-device.d.ts +8 -0
- package/lib/routes/cameras/cameras.d.ts +19 -0
- package/lib/routes/cameras/cameras.js +89 -0
- package/lib/routes/cameras/cameras.js.map +1 -0
- package/lib/routes/cameras/index.d.ts +2 -0
- package/lib/routes/cameras/index.js +7 -0
- package/lib/routes/cameras/index.js.map +1 -0
- package/lib/routes/cameras/live-views/index.d.ts +1 -0
- package/lib/routes/cameras/live-views/index.js +6 -0
- package/lib/routes/cameras/live-views/index.js.map +1 -0
- package/lib/routes/cameras/live-views/live-views.d.ts +100 -0
- package/lib/routes/cameras/live-views/live-views.js +144 -0
- package/lib/routes/cameras/live-views/live-views.js.map +1 -0
- package/lib/routes/index.d.ts +2 -0
- package/lib/routes/index.js +2 -0
- package/lib/routes/index.js.map +1 -1
- package/lib/routes/media/index.d.ts +1 -0
- package/lib/routes/media/index.js +6 -0
- package/lib/routes/media/index.js.map +1 -0
- package/lib/routes/media/media.d.ts +41 -0
- package/lib/routes/media/media.js +102 -0
- package/lib/routes/media/media.js.map +1 -0
- package/lib/routes/seam-http-endpoints.d.ts +31 -3
- package/lib/routes/seam-http-endpoints.js +58 -0
- package/lib/routes/seam-http-endpoints.js.map +1 -1
- package/lib/routes/seam-http.d.ts +4 -0
- package/lib/routes/seam-http.js +8 -0
- package/lib/routes/seam-http.js.map +1 -1
- package/lib/routes/thermostats/thermostats.d.ts +18 -0
- package/lib/routes/thermostats/thermostats.js +20 -0
- package/lib/routes/thermostats/thermostats.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +2 -2
- package/src/lib/resources/action-attempt.ts +77 -0
- package/src/lib/resources/camera-live-view-answer.ts +14 -0
- package/src/lib/resources/camera-live-view-session.ts +29 -0
- package/src/lib/resources/device-provider.ts +8 -0
- package/src/lib/resources/device.ts +8 -0
- package/src/lib/resources/event.ts +8 -0
- package/src/lib/resources/index.ts +3 -0
- package/src/lib/resources/media.ts +54 -0
- package/src/lib/resources/unmanaged-device.ts +8 -0
- package/src/lib/routes/cameras/cameras.ts +165 -0
- package/src/lib/routes/cameras/index.ts +7 -0
- package/src/lib/routes/cameras/live-views/index.ts +6 -0
- package/src/lib/routes/cameras/live-views/live-views.ts +316 -0
- package/src/lib/routes/index.ts +2 -0
- package/src/lib/routes/media/index.ts +6 -0
- package/src/lib/routes/media/media.ts +203 -0
- package/src/lib/routes/seam-http-endpoints.ts +112 -0
- package/src/lib/routes/seam-http.ts +10 -0
- package/src/lib/routes/thermostats/thermostats.ts +49 -0
- package/src/lib/version.ts +1 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Automatically generated by codegen/smith.ts.
|
|
3
|
+
* Do not edit this file.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Represents a short-lived live view session for a single camera. Use the session ID and token to start a WebRTC stream and to stop the session.
|
|
8
|
+
*/
|
|
9
|
+
export type CameraLiveViewSession = {
|
|
10
|
+
/**
|
|
11
|
+
* ID of the camera live view session.
|
|
12
|
+
*/
|
|
13
|
+
camera_live_view_session_id: string
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* ID of the camera.
|
|
17
|
+
*/
|
|
18
|
+
device_id: string
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Date and time at which the live view session expires.
|
|
22
|
+
*/
|
|
23
|
+
expires_at: string
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Token that authorizes the offer and stop requests for this session.
|
|
27
|
+
*/
|
|
28
|
+
token: string
|
|
29
|
+
}
|
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
export type DeviceProvider = {
|
|
7
|
+
/**
|
|
8
|
+
* Indicates whether the thermostat can be returned to its weekly program, the schedule that is configured on the device itself, releasing any hold that Seam has set.
|
|
9
|
+
*/
|
|
10
|
+
can_activate_weekly_program?: boolean | undefined
|
|
7
11
|
/**
|
|
8
12
|
* Indicates whether the lock supports configuring automatic locking.
|
|
9
13
|
*/
|
|
@@ -76,6 +80,10 @@ export type DeviceProvider = {
|
|
|
76
80
|
* Indicates whether the device supports simulating removal in a sandbox.
|
|
77
81
|
*/
|
|
78
82
|
can_simulate_removal?: boolean | undefined
|
|
83
|
+
/**
|
|
84
|
+
* Indicates whether the camera supports streaming live video through a camera live view session.
|
|
85
|
+
*/
|
|
86
|
+
can_stream_live_video?: boolean | undefined
|
|
79
87
|
/**
|
|
80
88
|
* Indicates whether the thermostat can be turned off.
|
|
81
89
|
*/
|
|
@@ -7,6 +7,10 @@
|
|
|
7
7
|
* Represents a [device](https://www.seam.co/docs/core-concepts/devices) that has been connected to Seam.
|
|
8
8
|
*/
|
|
9
9
|
export type Device = {
|
|
10
|
+
/**
|
|
11
|
+
* Indicates whether the thermostat can be returned to its weekly program, the schedule that is configured on the device itself, releasing any hold that Seam has set.
|
|
12
|
+
*/
|
|
13
|
+
can_activate_weekly_program?: boolean | undefined
|
|
10
14
|
/**
|
|
11
15
|
* Indicates whether the lock supports configuring automatic locking.
|
|
12
16
|
*/
|
|
@@ -79,6 +83,10 @@ export type Device = {
|
|
|
79
83
|
* Indicates whether the device supports simulating removal in a sandbox.
|
|
80
84
|
*/
|
|
81
85
|
can_simulate_removal?: boolean | undefined
|
|
86
|
+
/**
|
|
87
|
+
* Indicates whether the camera supports streaming live video through a camera live view session.
|
|
88
|
+
*/
|
|
89
|
+
can_stream_live_video?: boolean | undefined
|
|
82
90
|
/**
|
|
83
91
|
* Indicates whether the thermostat can be turned off.
|
|
84
92
|
*/
|
|
@@ -6363,6 +6363,10 @@ export type SeamEvent =
|
|
|
6363
6363
|
* URL to a thumbnail image captured at the time of activation.
|
|
6364
6364
|
*/
|
|
6365
6365
|
image_url?: string | undefined
|
|
6366
|
+
/**
|
|
6367
|
+
* IDs of the media, such as a video clip and a thumbnail image, captured for this activation. Use `/media/get` to retrieve each one.
|
|
6368
|
+
*/
|
|
6369
|
+
media_ids?: Array<string> | undefined
|
|
6366
6370
|
/**
|
|
6367
6371
|
* Sub-type of motion detected, if available.
|
|
6368
6372
|
*/
|
|
@@ -6425,6 +6429,10 @@ export type SeamEvent =
|
|
|
6425
6429
|
* URL to a thumbnail image captured at the time the doorbell was pressed.
|
|
6426
6430
|
*/
|
|
6427
6431
|
image_url?: string | undefined
|
|
6432
|
+
/**
|
|
6433
|
+
* IDs of the media, such as a video clip and a thumbnail image, captured when the doorbell was pressed. Use `/media/get` to retrieve each one.
|
|
6434
|
+
*/
|
|
6435
|
+
media_ids?: Array<string> | undefined
|
|
6428
6436
|
/**
|
|
6429
6437
|
* Date and time at which the event occurred.
|
|
6430
6438
|
*/
|
|
@@ -14,6 +14,8 @@ export type { AcsSystem } from './acs-system.js'
|
|
|
14
14
|
export type { AcsUser } from './acs-user.js'
|
|
15
15
|
export type { ActionAttempt } from './action-attempt.js'
|
|
16
16
|
export type { Batch } from './batch.js'
|
|
17
|
+
export type { CameraLiveViewAnswer } from './camera-live-view-answer.js'
|
|
18
|
+
export type { CameraLiveViewSession } from './camera-live-view-session.js'
|
|
17
19
|
export type { ClientSession } from './client-session.js'
|
|
18
20
|
export type { ConnectWebview } from './connect-webview.js'
|
|
19
21
|
export type { ConnectedAccount } from './connected-account.js'
|
|
@@ -22,6 +24,7 @@ export type { Device } from './device.js'
|
|
|
22
24
|
export type { DeviceProvider } from './device-provider.js'
|
|
23
25
|
export type { SeamEvent } from './event.js'
|
|
24
26
|
export type { InstantKey } from './instant-key.js'
|
|
27
|
+
export type { Media } from './media.js'
|
|
25
28
|
export type { NoiseThreshold } from './noise-threshold.js'
|
|
26
29
|
export type { Phone } from './phone.js'
|
|
27
30
|
export type { Space } from './space.js'
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Automatically generated by codegen/smith.ts.
|
|
3
|
+
* Do not edit this file.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Represents a piece of media, such as a video clip or a thumbnail image, that a device captured for an event. Media is in beta.
|
|
8
|
+
*/
|
|
9
|
+
export type Media = {
|
|
10
|
+
/**
|
|
11
|
+
* MIME type of the media, such as `video/mp4` or `image/jpeg`.
|
|
12
|
+
*/
|
|
13
|
+
content_type: string | null
|
|
14
|
+
/**
|
|
15
|
+
* Date and time at which the media was created.
|
|
16
|
+
*/
|
|
17
|
+
created_at: string
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* ID of the device that captured the media.
|
|
21
|
+
*/
|
|
22
|
+
device_id: string | null
|
|
23
|
+
/**
|
|
24
|
+
* ID of the event that the media belongs to.
|
|
25
|
+
*/
|
|
26
|
+
event_id: string | null
|
|
27
|
+
/**
|
|
28
|
+
* Date and time at which the media stops being available. Null when Seam does not know when the media expires.
|
|
29
|
+
*/
|
|
30
|
+
expires_at: string | null
|
|
31
|
+
/**
|
|
32
|
+
* ID of the media.
|
|
33
|
+
*/
|
|
34
|
+
media_id: string
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Type of the media: a video clip or a still image.
|
|
38
|
+
*/
|
|
39
|
+
media_type: 'video' | 'image'
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Status of the media. `pending` means that Seam is still retrieving the media. `available` means that `url` can be used to download it. `unavailable` means that no media exists for the event, and `failed` means that Seam could not retrieve it.
|
|
43
|
+
*/
|
|
44
|
+
status: 'pending' | 'available' | 'unavailable' | 'failed'
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Short-lived URL from which you can download the media. Null unless `status` is `available`. The URL expires after about five minutes. Call `/media/get` again for a new URL.
|
|
48
|
+
*/
|
|
49
|
+
url: string | null
|
|
50
|
+
/**
|
|
51
|
+
* ID of the workspace that contains the media.
|
|
52
|
+
*/
|
|
53
|
+
workspace_id: string
|
|
54
|
+
}
|
|
@@ -7,6 +7,10 @@
|
|
|
7
7
|
* Represents an [unmanaged device](https://www.seam.co/docs/core-concepts/devices/managed-and-unmanaged-devices). An unmanaged device has a limited set of visible properties and a subset of supported events. You cannot control an unmanaged device. Any [access codes](https://www.seam.co/docs/low-level-apis/smart-locks/access-codes/migrating-existing-access-codes) on an unmanaged device are unmanaged. To control an unmanaged device with Seam, [convert it to a managed device](https://www.seam.co/docs/core-concepts/devices/managed-and-unmanaged-devices#convert-an-unmanaged-device-to-managed).
|
|
8
8
|
*/
|
|
9
9
|
export type UnmanagedDevice = {
|
|
10
|
+
/**
|
|
11
|
+
* Indicates whether the thermostat can be returned to its weekly program, the schedule that is configured on the device itself, releasing any hold that Seam has set.
|
|
12
|
+
*/
|
|
13
|
+
can_activate_weekly_program?: boolean | undefined
|
|
10
14
|
/**
|
|
11
15
|
* Indicates whether the lock supports configuring automatic locking.
|
|
12
16
|
*/
|
|
@@ -79,6 +83,10 @@ export type UnmanagedDevice = {
|
|
|
79
83
|
* Indicates whether the device supports simulating removal in a sandbox.
|
|
80
84
|
*/
|
|
81
85
|
can_simulate_removal?: boolean | undefined
|
|
86
|
+
/**
|
|
87
|
+
* Indicates whether the camera supports streaming live video through a camera live view session.
|
|
88
|
+
*/
|
|
89
|
+
can_stream_live_video?: boolean | undefined
|
|
82
90
|
/**
|
|
83
91
|
* Indicates whether the thermostat can be turned off.
|
|
84
92
|
*/
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Automatically generated by codegen/smith.ts.
|
|
3
|
+
* Do not edit this file or add other files to this directory.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
getAuthHeadersForClientSessionToken,
|
|
8
|
+
warnOnInsecureuserIdentifierKey,
|
|
9
|
+
} from 'lib/auth.js'
|
|
10
|
+
import { type Client, createClient } from 'lib/client.js'
|
|
11
|
+
import {
|
|
12
|
+
isSeamHttpOptionsWithApiKey,
|
|
13
|
+
isSeamHttpOptionsWithClient,
|
|
14
|
+
isSeamHttpOptionsWithClientSessionToken,
|
|
15
|
+
isSeamHttpOptionsWithConsoleSessionToken,
|
|
16
|
+
isSeamHttpOptionsWithPersonalAccessToken,
|
|
17
|
+
type SeamHttpFromPublishableKeyOptions,
|
|
18
|
+
SeamHttpInvalidOptionsError,
|
|
19
|
+
type SeamHttpOptions,
|
|
20
|
+
type SeamHttpOptionsWithApiKey,
|
|
21
|
+
type SeamHttpOptionsWithClient,
|
|
22
|
+
type SeamHttpOptionsWithClientSessionToken,
|
|
23
|
+
type SeamHttpOptionsWithConsoleSessionToken,
|
|
24
|
+
type SeamHttpOptionsWithPersonalAccessToken,
|
|
25
|
+
type SeamHttpRequestOptions,
|
|
26
|
+
} from 'lib/options.js'
|
|
27
|
+
import {
|
|
28
|
+
limitToSeamHttpRequestOptions,
|
|
29
|
+
parseOptions,
|
|
30
|
+
} from 'lib/parse-options.js'
|
|
31
|
+
import { SeamHttpClientSessions } from 'lib/routes/client-sessions/index.js'
|
|
32
|
+
import type { SeamPaginatedRequest } from 'lib/seam-http-request.js'
|
|
33
|
+
import { SeamPaginator } from 'lib/seam-paginator.js'
|
|
34
|
+
|
|
35
|
+
import { SeamHttpCamerasLiveViews } from './live-views/index.js'
|
|
36
|
+
|
|
37
|
+
export class SeamHttpCameras {
|
|
38
|
+
client: Client
|
|
39
|
+
readonly defaults: Required<SeamHttpRequestOptions>
|
|
40
|
+
|
|
41
|
+
constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
|
|
42
|
+
const options = parseOptions(apiKeyOrOptions)
|
|
43
|
+
this.client = 'client' in options ? options.client : createClient(options)
|
|
44
|
+
this.defaults = limitToSeamHttpRequestOptions(options)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
static fromClient(
|
|
48
|
+
client: SeamHttpOptionsWithClient['client'],
|
|
49
|
+
options: Omit<SeamHttpOptionsWithClient, 'client'> = {},
|
|
50
|
+
): SeamHttpCameras {
|
|
51
|
+
const constructorOptions = { ...options, client }
|
|
52
|
+
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
53
|
+
throw new SeamHttpInvalidOptionsError('Missing client')
|
|
54
|
+
}
|
|
55
|
+
return new SeamHttpCameras(constructorOptions)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
static fromApiKey(
|
|
59
|
+
apiKey: SeamHttpOptionsWithApiKey['apiKey'],
|
|
60
|
+
options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
|
|
61
|
+
): SeamHttpCameras {
|
|
62
|
+
const constructorOptions = { ...options, apiKey }
|
|
63
|
+
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
64
|
+
throw new SeamHttpInvalidOptionsError('Missing apiKey')
|
|
65
|
+
}
|
|
66
|
+
return new SeamHttpCameras(constructorOptions)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
static fromClientSessionToken(
|
|
70
|
+
clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
|
|
71
|
+
options: Omit<
|
|
72
|
+
SeamHttpOptionsWithClientSessionToken,
|
|
73
|
+
'clientSessionToken'
|
|
74
|
+
> = {},
|
|
75
|
+
): SeamHttpCameras {
|
|
76
|
+
const constructorOptions = { ...options, clientSessionToken }
|
|
77
|
+
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
78
|
+
throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
|
|
79
|
+
}
|
|
80
|
+
return new SeamHttpCameras(constructorOptions)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
static async fromPublishableKey(
|
|
84
|
+
publishableKey: string,
|
|
85
|
+
userIdentifierKey: string,
|
|
86
|
+
options: SeamHttpFromPublishableKeyOptions = {},
|
|
87
|
+
): Promise<SeamHttpCameras> {
|
|
88
|
+
warnOnInsecureuserIdentifierKey(userIdentifierKey)
|
|
89
|
+
const clientOptions = parseOptions({ ...options, publishableKey })
|
|
90
|
+
if (isSeamHttpOptionsWithClient(clientOptions)) {
|
|
91
|
+
throw new SeamHttpInvalidOptionsError(
|
|
92
|
+
'The client option cannot be used with SeamHttpCameras.fromPublishableKey',
|
|
93
|
+
)
|
|
94
|
+
}
|
|
95
|
+
const client = createClient(clientOptions)
|
|
96
|
+
const clientSessions = SeamHttpClientSessions.fromClient(client)
|
|
97
|
+
const { token } = await clientSessions.getOrCreate({
|
|
98
|
+
user_identifier_key: userIdentifierKey,
|
|
99
|
+
})
|
|
100
|
+
return SeamHttpCameras.fromClientSessionToken(token, options)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
static fromConsoleSessionToken(
|
|
104
|
+
consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'],
|
|
105
|
+
workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'],
|
|
106
|
+
options: Omit<
|
|
107
|
+
SeamHttpOptionsWithConsoleSessionToken,
|
|
108
|
+
'consoleSessionToken' | 'workspaceId'
|
|
109
|
+
> = {},
|
|
110
|
+
): SeamHttpCameras {
|
|
111
|
+
const constructorOptions = { ...options, consoleSessionToken, workspaceId }
|
|
112
|
+
if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) {
|
|
113
|
+
throw new SeamHttpInvalidOptionsError(
|
|
114
|
+
'Missing consoleSessionToken or workspaceId',
|
|
115
|
+
)
|
|
116
|
+
}
|
|
117
|
+
return new SeamHttpCameras(constructorOptions)
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
static fromPersonalAccessToken(
|
|
121
|
+
personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'],
|
|
122
|
+
workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'],
|
|
123
|
+
options: Omit<
|
|
124
|
+
SeamHttpOptionsWithPersonalAccessToken,
|
|
125
|
+
'personalAccessToken' | 'workspaceId'
|
|
126
|
+
> = {},
|
|
127
|
+
): SeamHttpCameras {
|
|
128
|
+
const constructorOptions = { ...options, personalAccessToken, workspaceId }
|
|
129
|
+
if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) {
|
|
130
|
+
throw new SeamHttpInvalidOptionsError(
|
|
131
|
+
'Missing personalAccessToken or workspaceId',
|
|
132
|
+
)
|
|
133
|
+
}
|
|
134
|
+
return new SeamHttpCameras(constructorOptions)
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
createPaginator<const TResponse, const TResponseKey extends keyof TResponse>(
|
|
138
|
+
request: SeamPaginatedRequest<TResponse, TResponseKey>,
|
|
139
|
+
): SeamPaginator<TResponse, TResponseKey> {
|
|
140
|
+
return new SeamPaginator<TResponse, TResponseKey>(request)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
async updateClientSessionToken(
|
|
144
|
+
clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
|
|
145
|
+
): Promise<void> {
|
|
146
|
+
const { headers } = this.client.defaults
|
|
147
|
+
const authHeaders = getAuthHeadersForClientSessionToken({
|
|
148
|
+
clientSessionToken,
|
|
149
|
+
})
|
|
150
|
+
for (const key of Object.keys(authHeaders)) {
|
|
151
|
+
if (headers[key] == null) {
|
|
152
|
+
throw new Error(
|
|
153
|
+
'Cannot update a clientSessionToken on a client created without a clientSessionToken',
|
|
154
|
+
)
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
this.client.defaults.headers = { ...headers, ...authHeaders }
|
|
158
|
+
const clientSessions = SeamHttpClientSessions.fromClient(this.client)
|
|
159
|
+
await clientSessions.get()
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
get liveViews(): SeamHttpCamerasLiveViews {
|
|
163
|
+
return SeamHttpCamerasLiveViews.fromClient(this.client, this.defaults)
|
|
164
|
+
}
|
|
165
|
+
}
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Automatically generated by codegen/smith.ts.
|
|
3
|
+
* Do not edit this file or add other files to this directory.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
getAuthHeadersForClientSessionToken,
|
|
8
|
+
warnOnInsecureuserIdentifierKey,
|
|
9
|
+
} from 'lib/auth.js'
|
|
10
|
+
import { type Client, createClient } from 'lib/client.js'
|
|
11
|
+
import {
|
|
12
|
+
isSeamHttpOptionsWithApiKey,
|
|
13
|
+
isSeamHttpOptionsWithClient,
|
|
14
|
+
isSeamHttpOptionsWithClientSessionToken,
|
|
15
|
+
isSeamHttpOptionsWithConsoleSessionToken,
|
|
16
|
+
isSeamHttpOptionsWithPersonalAccessToken,
|
|
17
|
+
type SeamHttpFromPublishableKeyOptions,
|
|
18
|
+
SeamHttpInvalidOptionsError,
|
|
19
|
+
type SeamHttpOptions,
|
|
20
|
+
type SeamHttpOptionsWithApiKey,
|
|
21
|
+
type SeamHttpOptionsWithClient,
|
|
22
|
+
type SeamHttpOptionsWithClientSessionToken,
|
|
23
|
+
type SeamHttpOptionsWithConsoleSessionToken,
|
|
24
|
+
type SeamHttpOptionsWithPersonalAccessToken,
|
|
25
|
+
type SeamHttpRequestOptions,
|
|
26
|
+
} from 'lib/options.js'
|
|
27
|
+
import {
|
|
28
|
+
limitToSeamHttpRequestOptions,
|
|
29
|
+
parseOptions,
|
|
30
|
+
} from 'lib/parse-options.js'
|
|
31
|
+
import type { CameraLiveViewAnswer } from 'lib/resources/camera-live-view-answer.js'
|
|
32
|
+
import type { CameraLiveViewSession } from 'lib/resources/camera-live-view-session.js'
|
|
33
|
+
import { SeamHttpClientSessions } from 'lib/routes/client-sessions/index.js'
|
|
34
|
+
import {
|
|
35
|
+
SeamHttpRequest,
|
|
36
|
+
type SeamPaginatedRequest,
|
|
37
|
+
} from 'lib/seam-http-request.js'
|
|
38
|
+
import { SeamPaginator } from 'lib/seam-paginator.js'
|
|
39
|
+
|
|
40
|
+
export class SeamHttpCamerasLiveViews {
|
|
41
|
+
client: Client
|
|
42
|
+
readonly defaults: Required<SeamHttpRequestOptions>
|
|
43
|
+
|
|
44
|
+
constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
|
|
45
|
+
const options = parseOptions(apiKeyOrOptions)
|
|
46
|
+
this.client = 'client' in options ? options.client : createClient(options)
|
|
47
|
+
this.defaults = limitToSeamHttpRequestOptions(options)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
static fromClient(
|
|
51
|
+
client: SeamHttpOptionsWithClient['client'],
|
|
52
|
+
options: Omit<SeamHttpOptionsWithClient, 'client'> = {},
|
|
53
|
+
): SeamHttpCamerasLiveViews {
|
|
54
|
+
const constructorOptions = { ...options, client }
|
|
55
|
+
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
56
|
+
throw new SeamHttpInvalidOptionsError('Missing client')
|
|
57
|
+
}
|
|
58
|
+
return new SeamHttpCamerasLiveViews(constructorOptions)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
static fromApiKey(
|
|
62
|
+
apiKey: SeamHttpOptionsWithApiKey['apiKey'],
|
|
63
|
+
options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
|
|
64
|
+
): SeamHttpCamerasLiveViews {
|
|
65
|
+
const constructorOptions = { ...options, apiKey }
|
|
66
|
+
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
67
|
+
throw new SeamHttpInvalidOptionsError('Missing apiKey')
|
|
68
|
+
}
|
|
69
|
+
return new SeamHttpCamerasLiveViews(constructorOptions)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
static fromClientSessionToken(
|
|
73
|
+
clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
|
|
74
|
+
options: Omit<
|
|
75
|
+
SeamHttpOptionsWithClientSessionToken,
|
|
76
|
+
'clientSessionToken'
|
|
77
|
+
> = {},
|
|
78
|
+
): SeamHttpCamerasLiveViews {
|
|
79
|
+
const constructorOptions = { ...options, clientSessionToken }
|
|
80
|
+
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
81
|
+
throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
|
|
82
|
+
}
|
|
83
|
+
return new SeamHttpCamerasLiveViews(constructorOptions)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
static async fromPublishableKey(
|
|
87
|
+
publishableKey: string,
|
|
88
|
+
userIdentifierKey: string,
|
|
89
|
+
options: SeamHttpFromPublishableKeyOptions = {},
|
|
90
|
+
): Promise<SeamHttpCamerasLiveViews> {
|
|
91
|
+
warnOnInsecureuserIdentifierKey(userIdentifierKey)
|
|
92
|
+
const clientOptions = parseOptions({ ...options, publishableKey })
|
|
93
|
+
if (isSeamHttpOptionsWithClient(clientOptions)) {
|
|
94
|
+
throw new SeamHttpInvalidOptionsError(
|
|
95
|
+
'The client option cannot be used with SeamHttpCamerasLiveViews.fromPublishableKey',
|
|
96
|
+
)
|
|
97
|
+
}
|
|
98
|
+
const client = createClient(clientOptions)
|
|
99
|
+
const clientSessions = SeamHttpClientSessions.fromClient(client)
|
|
100
|
+
const { token } = await clientSessions.getOrCreate({
|
|
101
|
+
user_identifier_key: userIdentifierKey,
|
|
102
|
+
})
|
|
103
|
+
return SeamHttpCamerasLiveViews.fromClientSessionToken(token, options)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
static fromConsoleSessionToken(
|
|
107
|
+
consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'],
|
|
108
|
+
workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'],
|
|
109
|
+
options: Omit<
|
|
110
|
+
SeamHttpOptionsWithConsoleSessionToken,
|
|
111
|
+
'consoleSessionToken' | 'workspaceId'
|
|
112
|
+
> = {},
|
|
113
|
+
): SeamHttpCamerasLiveViews {
|
|
114
|
+
const constructorOptions = { ...options, consoleSessionToken, workspaceId }
|
|
115
|
+
if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) {
|
|
116
|
+
throw new SeamHttpInvalidOptionsError(
|
|
117
|
+
'Missing consoleSessionToken or workspaceId',
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
return new SeamHttpCamerasLiveViews(constructorOptions)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
static fromPersonalAccessToken(
|
|
124
|
+
personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'],
|
|
125
|
+
workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'],
|
|
126
|
+
options: Omit<
|
|
127
|
+
SeamHttpOptionsWithPersonalAccessToken,
|
|
128
|
+
'personalAccessToken' | 'workspaceId'
|
|
129
|
+
> = {},
|
|
130
|
+
): SeamHttpCamerasLiveViews {
|
|
131
|
+
const constructorOptions = { ...options, personalAccessToken, workspaceId }
|
|
132
|
+
if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) {
|
|
133
|
+
throw new SeamHttpInvalidOptionsError(
|
|
134
|
+
'Missing personalAccessToken or workspaceId',
|
|
135
|
+
)
|
|
136
|
+
}
|
|
137
|
+
return new SeamHttpCamerasLiveViews(constructorOptions)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
createPaginator<const TResponse, const TResponseKey extends keyof TResponse>(
|
|
141
|
+
request: SeamPaginatedRequest<TResponse, TResponseKey>,
|
|
142
|
+
): SeamPaginator<TResponse, TResponseKey> {
|
|
143
|
+
return new SeamPaginator<TResponse, TResponseKey>(request)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
async updateClientSessionToken(
|
|
147
|
+
clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
|
|
148
|
+
): Promise<void> {
|
|
149
|
+
const { headers } = this.client.defaults
|
|
150
|
+
const authHeaders = getAuthHeadersForClientSessionToken({
|
|
151
|
+
clientSessionToken,
|
|
152
|
+
})
|
|
153
|
+
for (const key of Object.keys(authHeaders)) {
|
|
154
|
+
if (headers[key] == null) {
|
|
155
|
+
throw new Error(
|
|
156
|
+
'Cannot update a clientSessionToken on a client created without a clientSessionToken',
|
|
157
|
+
)
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
this.client.defaults.headers = { ...headers, ...authHeaders }
|
|
161
|
+
const clientSessions = SeamHttpClientSessions.fromClient(this.client)
|
|
162
|
+
await clientSessions.get()
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Creates a short-lived live view session for a single camera. Pass the returned session ID and token to `/cameras/live_views/offer` to start a WebRTC stream, and to `/cameras/live_views/stop` to end the session.
|
|
167
|
+
*
|
|
168
|
+
* Camera live view is in beta. To enable it for your workspace, contact Seam support. To check whether a camera supports live view, use `device.can_stream_live_video`.
|
|
169
|
+
*/
|
|
170
|
+
create(
|
|
171
|
+
parameters: CamerasLiveViewsCreateParameters,
|
|
172
|
+
options: CamerasLiveViewsCreateOptions = {},
|
|
173
|
+
): CamerasLiveViewsCreateRequest {
|
|
174
|
+
return new SeamHttpRequest(this, {
|
|
175
|
+
pathname: '/cameras/live_views/create',
|
|
176
|
+
method: 'POST',
|
|
177
|
+
body: parameters,
|
|
178
|
+
parameters,
|
|
179
|
+
hasRequiredParameters: true,
|
|
180
|
+
requiredParameterNames: ['device_id'],
|
|
181
|
+
atLeastOneParameterNames: [],
|
|
182
|
+
responseKey: 'camera_live_view_session',
|
|
183
|
+
options,
|
|
184
|
+
})
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Exchanges a WebRTC SDP offer for an SDP answer that starts streaming video from the camera, for a live view session that you created using `/cameras/live_views/create`.
|
|
189
|
+
*
|
|
190
|
+
* Camera live view is in beta. To enable it for your workspace, contact Seam support.
|
|
191
|
+
*/
|
|
192
|
+
offer(
|
|
193
|
+
parameters: CamerasLiveViewsOfferParameters,
|
|
194
|
+
options: CamerasLiveViewsOfferOptions = {},
|
|
195
|
+
): CamerasLiveViewsOfferRequest {
|
|
196
|
+
return new SeamHttpRequest(this, {
|
|
197
|
+
pathname: '/cameras/live_views/offer',
|
|
198
|
+
method: 'POST',
|
|
199
|
+
body: parameters,
|
|
200
|
+
parameters,
|
|
201
|
+
hasRequiredParameters: true,
|
|
202
|
+
requiredParameterNames: [
|
|
203
|
+
'camera_live_view_session_id',
|
|
204
|
+
'sdp_offer',
|
|
205
|
+
'token',
|
|
206
|
+
],
|
|
207
|
+
atLeastOneParameterNames: [],
|
|
208
|
+
responseKey: 'camera_live_view_answer',
|
|
209
|
+
options,
|
|
210
|
+
})
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Stops a camera live view session that the current client session owns.
|
|
215
|
+
*
|
|
216
|
+
* Camera live view is in beta. To enable it for your workspace, contact Seam support.
|
|
217
|
+
*/
|
|
218
|
+
stop(
|
|
219
|
+
parameters: CamerasLiveViewsStopParameters,
|
|
220
|
+
options: CamerasLiveViewsStopOptions = {},
|
|
221
|
+
): CamerasLiveViewsStopRequest {
|
|
222
|
+
return new SeamHttpRequest(this, {
|
|
223
|
+
pathname: '/cameras/live_views/stop',
|
|
224
|
+
method: 'POST',
|
|
225
|
+
body: parameters,
|
|
226
|
+
parameters,
|
|
227
|
+
hasRequiredParameters: true,
|
|
228
|
+
requiredParameterNames: ['camera_live_view_session_id', 'token'],
|
|
229
|
+
atLeastOneParameterNames: [],
|
|
230
|
+
responseKey: undefined,
|
|
231
|
+
options,
|
|
232
|
+
})
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export type CamerasLiveViewsCreateParameters = {
|
|
237
|
+
/**
|
|
238
|
+
* ID of the camera to view.
|
|
239
|
+
*/
|
|
240
|
+
device_id: string
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Number of seconds for which the live view session is valid, up to 600.
|
|
244
|
+
*/
|
|
245
|
+
duration_seconds?: number | undefined
|
|
246
|
+
/**
|
|
247
|
+
* Indicates whether to include the camera's audio.
|
|
248
|
+
*/
|
|
249
|
+
include_audio?: boolean | undefined
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* @deprecated Use CamerasLiveViewsCreateRequest instead.
|
|
254
|
+
*/
|
|
255
|
+
export type CamerasLiveViewsCreateResponse = {
|
|
256
|
+
camera_live_view_session: CameraLiveViewSession
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export type CamerasLiveViewsCreateRequest = SeamHttpRequest<
|
|
260
|
+
CamerasLiveViewsCreateResponse,
|
|
261
|
+
'camera_live_view_session'
|
|
262
|
+
>
|
|
263
|
+
|
|
264
|
+
export interface CamerasLiveViewsCreateOptions {}
|
|
265
|
+
|
|
266
|
+
export type CamerasLiveViewsOfferParameters = {
|
|
267
|
+
/**
|
|
268
|
+
* ID of the camera live view session.
|
|
269
|
+
*/
|
|
270
|
+
camera_live_view_session_id: string
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* WebRTC SDP offer from the viewer, limited to 64 KiB of UTF-8 data.
|
|
274
|
+
*/
|
|
275
|
+
sdp_offer: string
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Token returned when the camera live view session was created.
|
|
279
|
+
*/
|
|
280
|
+
token: string
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* @deprecated Use CamerasLiveViewsOfferRequest instead.
|
|
285
|
+
*/
|
|
286
|
+
export type CamerasLiveViewsOfferResponse = {
|
|
287
|
+
camera_live_view_answer: CameraLiveViewAnswer
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
export type CamerasLiveViewsOfferRequest = SeamHttpRequest<
|
|
291
|
+
CamerasLiveViewsOfferResponse,
|
|
292
|
+
'camera_live_view_answer'
|
|
293
|
+
>
|
|
294
|
+
|
|
295
|
+
export interface CamerasLiveViewsOfferOptions {}
|
|
296
|
+
|
|
297
|
+
export type CamerasLiveViewsStopParameters = {
|
|
298
|
+
/**
|
|
299
|
+
* ID of the camera live view session.
|
|
300
|
+
*/
|
|
301
|
+
camera_live_view_session_id: string
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Token returned when the camera live view session was created.
|
|
305
|
+
*/
|
|
306
|
+
token: string
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* @deprecated Use CamerasLiveViewsStopRequest instead.
|
|
311
|
+
*/
|
|
312
|
+
export type CamerasLiveViewsStopResponse = void
|
|
313
|
+
|
|
314
|
+
export type CamerasLiveViewsStopRequest = SeamHttpRequest<void, undefined>
|
|
315
|
+
|
|
316
|
+
export interface CamerasLiveViewsStopOptions {}
|