@seamapi/http 0.23.0 → 0.25.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/README.md +15 -0
- package/dist/connect.cjs +847 -727
- package/dist/connect.cjs.map +1 -1
- package/dist/connect.d.cts +167 -126
- package/lib/seam/connect/routes/access-codes-unmanaged.d.ts +6 -5
- package/lib/seam/connect/routes/access-codes-unmanaged.js +26 -22
- package/lib/seam/connect/routes/access-codes-unmanaged.js.map +1 -1
- package/lib/seam/connect/routes/access-codes.d.ts +9 -8
- package/lib/seam/connect/routes/access-codes.js +41 -38
- package/lib/seam/connect/routes/access-codes.js.map +1 -1
- package/lib/seam/connect/routes/acs-access-groups.d.ts +6 -5
- package/lib/seam/connect/routes/acs-access-groups.js +26 -23
- package/lib/seam/connect/routes/acs-access-groups.js.map +1 -1
- package/lib/seam/connect/routes/acs-credential-pools.d.ts +2 -1
- package/lib/seam/connect/routes/acs-credential-pools.js +6 -5
- package/lib/seam/connect/routes/acs-credential-pools.js.map +1 -1
- package/lib/seam/connect/routes/acs-credential-provisioning-automations.d.ts +2 -1
- package/lib/seam/connect/routes/acs-credential-provisioning-automations.js +6 -5
- package/lib/seam/connect/routes/acs-credential-provisioning-automations.js.map +1 -1
- package/lib/seam/connect/routes/acs-credentials.d.ts +8 -7
- package/lib/seam/connect/routes/acs-credentials.js +36 -34
- package/lib/seam/connect/routes/acs-credentials.js.map +1 -1
- package/lib/seam/connect/routes/acs-entrances.d.ts +5 -4
- package/lib/seam/connect/routes/acs-entrances.js +21 -19
- package/lib/seam/connect/routes/acs-entrances.js.map +1 -1
- package/lib/seam/connect/routes/acs-systems.d.ts +3 -2
- package/lib/seam/connect/routes/acs-systems.js +11 -10
- package/lib/seam/connect/routes/acs-systems.js.map +1 -1
- package/lib/seam/connect/routes/acs-users.d.ts +12 -11
- package/lib/seam/connect/routes/acs-users.js +56 -48
- package/lib/seam/connect/routes/acs-users.js.map +1 -1
- package/lib/seam/connect/routes/action-attempts.d.ts +3 -2
- package/lib/seam/connect/routes/action-attempts.js +12 -18
- package/lib/seam/connect/routes/action-attempts.js.map +1 -1
- package/lib/seam/connect/routes/client-sessions.d.ts +8 -7
- package/lib/seam/connect/routes/client-sessions.js +36 -33
- package/lib/seam/connect/routes/client-sessions.js.map +1 -1
- package/lib/seam/connect/routes/connect-webviews.d.ts +6 -5
- package/lib/seam/connect/routes/connect-webviews.js +25 -22
- package/lib/seam/connect/routes/connect-webviews.js.map +1 -1
- package/lib/seam/connect/routes/connected-accounts.d.ts +5 -4
- package/lib/seam/connect/routes/connected-accounts.js +21 -19
- package/lib/seam/connect/routes/connected-accounts.js.map +1 -1
- package/lib/seam/connect/routes/devices-simulate.d.ts +21 -0
- package/lib/seam/connect/routes/devices-simulate.js +88 -0
- package/lib/seam/connect/routes/devices-simulate.js.map +1 -0
- package/lib/seam/connect/routes/devices-unmanaged.d.ts +4 -3
- package/lib/seam/connect/routes/devices-unmanaged.js +16 -14
- package/lib/seam/connect/routes/devices-unmanaged.js.map +1 -1
- package/lib/seam/connect/routes/devices.d.ts +8 -5
- package/lib/seam/connect/routes/devices.js +30 -23
- package/lib/seam/connect/routes/devices.js.map +1 -1
- package/lib/seam/connect/routes/events.d.ts +3 -2
- package/lib/seam/connect/routes/events.js +11 -10
- package/lib/seam/connect/routes/events.js.map +1 -1
- package/lib/seam/connect/routes/index.d.ts +1 -0
- package/lib/seam/connect/routes/index.js +1 -0
- package/lib/seam/connect/routes/index.js.map +1 -1
- package/lib/seam/connect/routes/locks.d.ts +5 -4
- package/lib/seam/connect/routes/locks.js +23 -36
- package/lib/seam/connect/routes/locks.js.map +1 -1
- package/lib/seam/connect/routes/networks.d.ts +3 -2
- package/lib/seam/connect/routes/networks.js +11 -10
- package/lib/seam/connect/routes/networks.js.map +1 -1
- package/lib/seam/connect/routes/noise-sensors-noise-thresholds.d.ts +6 -5
- package/lib/seam/connect/routes/noise-sensors-noise-thresholds.js +26 -23
- package/lib/seam/connect/routes/noise-sensors-noise-thresholds.js.map +1 -1
- package/lib/seam/connect/routes/phones-simulate.d.ts +2 -1
- package/lib/seam/connect/routes/phones-simulate.js +6 -5
- package/lib/seam/connect/routes/phones-simulate.js.map +1 -1
- package/lib/seam/connect/routes/phones.d.ts +3 -2
- package/lib/seam/connect/routes/phones.js +11 -9
- package/lib/seam/connect/routes/phones.js.map +1 -1
- package/lib/seam/connect/routes/thermostats-climate-setting-schedules.d.ts +6 -5
- package/lib/seam/connect/routes/thermostats-climate-setting-schedules.js +26 -23
- package/lib/seam/connect/routes/thermostats-climate-setting-schedules.js.map +1 -1
- package/lib/seam/connect/routes/thermostats.d.ts +9 -8
- package/lib/seam/connect/routes/thermostats.js +46 -76
- package/lib/seam/connect/routes/thermostats.js.map +1 -1
- package/lib/seam/connect/routes/user-identities-enrollment-automations.d.ts +5 -4
- package/lib/seam/connect/routes/user-identities-enrollment-automations.js +21 -19
- package/lib/seam/connect/routes/user-identities-enrollment-automations.js.map +1 -1
- package/lib/seam/connect/routes/user-identities.d.ts +13 -12
- package/lib/seam/connect/routes/user-identities.js +61 -54
- package/lib/seam/connect/routes/user-identities.js.map +1 -1
- package/lib/seam/connect/routes/webhooks.d.ts +6 -5
- package/lib/seam/connect/routes/webhooks.js +26 -23
- package/lib/seam/connect/routes/webhooks.js.map +1 -1
- package/lib/seam/connect/routes/workspaces.d.ts +5 -4
- package/lib/seam/connect/routes/workspaces.js +21 -19
- package/lib/seam/connect/routes/workspaces.js.map +1 -1
- package/lib/seam/connect/seam-http-request.d.ts +26 -0
- package/lib/seam/connect/seam-http-request.js +87 -0
- package/lib/seam/connect/seam-http-request.js.map +1 -0
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +4 -4
- package/src/lib/seam/connect/routes/access-codes-unmanaged.ts +37 -34
- package/src/lib/seam/connect/routes/access-codes.ts +56 -60
- package/src/lib/seam/connect/routes/acs-access-groups.ts +33 -32
- package/src/lib/seam/connect/routes/acs-credential-pools.ts +7 -7
- package/src/lib/seam/connect/routes/acs-credential-provisioning-automations.ts +11 -13
- package/src/lib/seam/connect/routes/acs-credentials.ts +42 -46
- package/src/lib/seam/connect/routes/acs-entrances.ts +31 -28
- package/src/lib/seam/connect/routes/acs-systems.ts +13 -14
- package/src/lib/seam/connect/routes/acs-users.ts +66 -61
- package/src/lib/seam/connect/routes/action-attempts.ts +14 -26
- package/src/lib/seam/connect/routes/client-sessions.ts +45 -49
- package/src/lib/seam/connect/routes/connect-webviews.ts +28 -28
- package/src/lib/seam/connect/routes/connected-accounts.ts +26 -29
- package/src/lib/seam/connect/routes/devices-simulate.ts +174 -0
- package/src/lib/seam/connect/routes/devices-unmanaged.ts +18 -18
- package/src/lib/seam/connect/routes/devices.ts +35 -31
- package/src/lib/seam/connect/routes/events.ts +11 -12
- package/src/lib/seam/connect/routes/index.ts +1 -0
- package/src/lib/seam/connect/routes/locks.ts +25 -50
- package/src/lib/seam/connect/routes/networks.ts +14 -13
- package/src/lib/seam/connect/routes/noise-sensors-noise-thresholds.ts +48 -38
- package/src/lib/seam/connect/routes/phones-simulate.ts +9 -10
- package/src/lib/seam/connect/routes/phones.ts +11 -10
- package/src/lib/seam/connect/routes/thermostats-climate-setting-schedules.ts +47 -55
- package/src/lib/seam/connect/routes/thermostats.ts +53 -110
- package/src/lib/seam/connect/routes/user-identities-enrollment-automations.ts +39 -48
- package/src/lib/seam/connect/routes/user-identities.ts +81 -78
- package/src/lib/seam/connect/routes/webhooks.ts +30 -28
- package/src/lib/seam/connect/routes/workspaces.ts +26 -25
- package/src/lib/seam/connect/seam-http-request.ts +144 -0
- package/src/lib/version.ts +1 -1
|
@@ -35,6 +35,7 @@ import {
|
|
|
35
35
|
limitToSeamHttpRequestOptions,
|
|
36
36
|
parseOptions,
|
|
37
37
|
} from 'lib/seam/connect/parse-options.js'
|
|
38
|
+
import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js'
|
|
38
39
|
|
|
39
40
|
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
40
41
|
|
|
@@ -157,55 +158,54 @@ export class SeamHttpConnectWebviews {
|
|
|
157
158
|
await clientSessions.get()
|
|
158
159
|
}
|
|
159
160
|
|
|
160
|
-
|
|
161
|
+
create(
|
|
161
162
|
body?: ConnectWebviewsCreateBody,
|
|
162
|
-
):
|
|
163
|
-
|
|
164
|
-
|
|
163
|
+
): SeamHttpRequest<ConnectWebviewsCreateResponse, 'connect_webview'> {
|
|
164
|
+
return new SeamHttpRequest(this, {
|
|
165
|
+
path: '/connect_webviews/create',
|
|
165
166
|
method: 'post',
|
|
166
|
-
|
|
167
|
+
body,
|
|
168
|
+
responseKey: 'connect_webview',
|
|
167
169
|
})
|
|
168
|
-
|
|
169
|
-
return data.connect_webview
|
|
170
170
|
}
|
|
171
171
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
172
|
+
delete(body?: ConnectWebviewsDeleteBody): SeamHttpRequest<void, undefined> {
|
|
173
|
+
return new SeamHttpRequest(this, {
|
|
174
|
+
path: '/connect_webviews/delete',
|
|
175
175
|
method: 'post',
|
|
176
|
-
|
|
176
|
+
body,
|
|
177
|
+
responseKey: undefined,
|
|
177
178
|
})
|
|
178
179
|
}
|
|
179
180
|
|
|
180
|
-
|
|
181
|
+
get(
|
|
181
182
|
body?: ConnectWebviewsGetParams,
|
|
182
|
-
):
|
|
183
|
-
|
|
184
|
-
|
|
183
|
+
): SeamHttpRequest<ConnectWebviewsGetResponse, 'connect_webview'> {
|
|
184
|
+
return new SeamHttpRequest(this, {
|
|
185
|
+
path: '/connect_webviews/get',
|
|
185
186
|
method: 'post',
|
|
186
|
-
|
|
187
|
+
body,
|
|
188
|
+
responseKey: 'connect_webview',
|
|
187
189
|
})
|
|
188
|
-
|
|
189
|
-
return data.connect_webview
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
-
|
|
192
|
+
list(
|
|
193
193
|
body?: ConnectWebviewsListParams,
|
|
194
|
-
):
|
|
195
|
-
|
|
196
|
-
|
|
194
|
+
): SeamHttpRequest<ConnectWebviewsListResponse, 'connect_webviews'> {
|
|
195
|
+
return new SeamHttpRequest(this, {
|
|
196
|
+
path: '/connect_webviews/list',
|
|
197
197
|
method: 'post',
|
|
198
|
-
|
|
198
|
+
body,
|
|
199
|
+
responseKey: 'connect_webviews',
|
|
199
200
|
})
|
|
200
|
-
|
|
201
|
-
return data.connect_webviews
|
|
202
201
|
}
|
|
203
202
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
203
|
+
view(params?: ConnectWebviewsViewParams): SeamHttpRequest<void, undefined> {
|
|
204
|
+
return new SeamHttpRequest(this, {
|
|
205
|
+
path: '/connect_webviews/view',
|
|
207
206
|
method: 'get',
|
|
208
207
|
params,
|
|
208
|
+
responseKey: undefined,
|
|
209
209
|
})
|
|
210
210
|
}
|
|
211
211
|
}
|
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
limitToSeamHttpRequestOptions,
|
|
32
32
|
parseOptions,
|
|
33
33
|
} from 'lib/seam/connect/parse-options.js'
|
|
34
|
+
import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js'
|
|
34
35
|
|
|
35
36
|
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
36
37
|
|
|
@@ -153,50 +154,46 @@ export class SeamHttpConnectedAccounts {
|
|
|
153
154
|
await clientSessions.get()
|
|
154
155
|
}
|
|
155
156
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
157
|
+
delete(body?: ConnectedAccountsDeleteBody): SeamHttpRequest<void, undefined> {
|
|
158
|
+
return new SeamHttpRequest(this, {
|
|
159
|
+
path: '/connected_accounts/delete',
|
|
159
160
|
method: 'post',
|
|
160
|
-
|
|
161
|
+
body,
|
|
162
|
+
responseKey: undefined,
|
|
161
163
|
})
|
|
162
164
|
}
|
|
163
165
|
|
|
164
|
-
|
|
166
|
+
get(
|
|
165
167
|
body?: ConnectedAccountsGetParams,
|
|
166
|
-
):
|
|
167
|
-
|
|
168
|
-
|
|
168
|
+
): SeamHttpRequest<ConnectedAccountsGetResponse, 'connected_account'> {
|
|
169
|
+
return new SeamHttpRequest(this, {
|
|
170
|
+
path: '/connected_accounts/get',
|
|
169
171
|
method: 'post',
|
|
170
|
-
|
|
172
|
+
body,
|
|
173
|
+
responseKey: 'connected_account',
|
|
171
174
|
})
|
|
172
|
-
|
|
173
|
-
return data.connected_account
|
|
174
175
|
}
|
|
175
176
|
|
|
176
|
-
|
|
177
|
+
list(
|
|
177
178
|
body?: ConnectedAccountsListParams,
|
|
178
|
-
):
|
|
179
|
-
|
|
180
|
-
|
|
179
|
+
): SeamHttpRequest<ConnectedAccountsListResponse, 'connected_accounts'> {
|
|
180
|
+
return new SeamHttpRequest(this, {
|
|
181
|
+
path: '/connected_accounts/list',
|
|
181
182
|
method: 'post',
|
|
182
|
-
|
|
183
|
+
body,
|
|
184
|
+
responseKey: 'connected_accounts',
|
|
183
185
|
})
|
|
184
|
-
|
|
185
|
-
return data.connected_accounts
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
-
|
|
188
|
+
update(
|
|
189
189
|
body?: ConnectedAccountsUpdateBody,
|
|
190
|
-
):
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
)
|
|
198
|
-
|
|
199
|
-
return data.connected_account
|
|
190
|
+
): SeamHttpRequest<ConnectedAccountsUpdateResponse, 'connected_account'> {
|
|
191
|
+
return new SeamHttpRequest(this, {
|
|
192
|
+
path: '/connected_accounts/update',
|
|
193
|
+
method: 'post',
|
|
194
|
+
body,
|
|
195
|
+
responseKey: 'connected_account',
|
|
196
|
+
})
|
|
200
197
|
}
|
|
201
198
|
}
|
|
202
199
|
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Automatically generated by generate-routes.ts.
|
|
3
|
+
* Do not edit this file or add other files to this directory.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import type { RouteRequestBody, RouteResponse } from '@seamapi/types/connect'
|
|
7
|
+
import type { SetNonNullable } from 'type-fest'
|
|
8
|
+
|
|
9
|
+
import {
|
|
10
|
+
getAuthHeadersForClientSessionToken,
|
|
11
|
+
warnOnInsecureuserIdentifierKey,
|
|
12
|
+
} from 'lib/seam/connect/auth.js'
|
|
13
|
+
import { type Client, createClient } from 'lib/seam/connect/client.js'
|
|
14
|
+
import {
|
|
15
|
+
isSeamHttpOptionsWithApiKey,
|
|
16
|
+
isSeamHttpOptionsWithClient,
|
|
17
|
+
isSeamHttpOptionsWithClientSessionToken,
|
|
18
|
+
isSeamHttpOptionsWithConsoleSessionToken,
|
|
19
|
+
isSeamHttpOptionsWithPersonalAccessToken,
|
|
20
|
+
type SeamHttpFromPublishableKeyOptions,
|
|
21
|
+
SeamHttpInvalidOptionsError,
|
|
22
|
+
type SeamHttpOptions,
|
|
23
|
+
type SeamHttpOptionsWithApiKey,
|
|
24
|
+
type SeamHttpOptionsWithClient,
|
|
25
|
+
type SeamHttpOptionsWithClientSessionToken,
|
|
26
|
+
type SeamHttpOptionsWithConsoleSessionToken,
|
|
27
|
+
type SeamHttpOptionsWithPersonalAccessToken,
|
|
28
|
+
type SeamHttpRequestOptions,
|
|
29
|
+
} from 'lib/seam/connect/options.js'
|
|
30
|
+
import {
|
|
31
|
+
limitToSeamHttpRequestOptions,
|
|
32
|
+
parseOptions,
|
|
33
|
+
} from 'lib/seam/connect/parse-options.js'
|
|
34
|
+
import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js'
|
|
35
|
+
|
|
36
|
+
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
37
|
+
|
|
38
|
+
export class SeamHttpDevicesSimulate {
|
|
39
|
+
client: Client
|
|
40
|
+
readonly defaults: Required<SeamHttpRequestOptions>
|
|
41
|
+
|
|
42
|
+
constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
|
|
43
|
+
const options = parseOptions(apiKeyOrOptions)
|
|
44
|
+
this.client = 'client' in options ? options.client : createClient(options)
|
|
45
|
+
this.defaults = limitToSeamHttpRequestOptions(options)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
static fromClient(
|
|
49
|
+
client: SeamHttpOptionsWithClient['client'],
|
|
50
|
+
options: Omit<SeamHttpOptionsWithClient, 'client'> = {},
|
|
51
|
+
): SeamHttpDevicesSimulate {
|
|
52
|
+
const constructorOptions = { ...options, client }
|
|
53
|
+
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
54
|
+
throw new SeamHttpInvalidOptionsError('Missing client')
|
|
55
|
+
}
|
|
56
|
+
return new SeamHttpDevicesSimulate(constructorOptions)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
static fromApiKey(
|
|
60
|
+
apiKey: SeamHttpOptionsWithApiKey['apiKey'],
|
|
61
|
+
options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
|
|
62
|
+
): SeamHttpDevicesSimulate {
|
|
63
|
+
const constructorOptions = { ...options, apiKey }
|
|
64
|
+
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
65
|
+
throw new SeamHttpInvalidOptionsError('Missing apiKey')
|
|
66
|
+
}
|
|
67
|
+
return new SeamHttpDevicesSimulate(constructorOptions)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
static fromClientSessionToken(
|
|
71
|
+
clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
|
|
72
|
+
options: Omit<
|
|
73
|
+
SeamHttpOptionsWithClientSessionToken,
|
|
74
|
+
'clientSessionToken'
|
|
75
|
+
> = {},
|
|
76
|
+
): SeamHttpDevicesSimulate {
|
|
77
|
+
const constructorOptions = { ...options, clientSessionToken }
|
|
78
|
+
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
79
|
+
throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
|
|
80
|
+
}
|
|
81
|
+
return new SeamHttpDevicesSimulate(constructorOptions)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
static async fromPublishableKey(
|
|
85
|
+
publishableKey: string,
|
|
86
|
+
userIdentifierKey: string,
|
|
87
|
+
options: SeamHttpFromPublishableKeyOptions = {},
|
|
88
|
+
): Promise<SeamHttpDevicesSimulate> {
|
|
89
|
+
warnOnInsecureuserIdentifierKey(userIdentifierKey)
|
|
90
|
+
const clientOptions = parseOptions({ ...options, publishableKey })
|
|
91
|
+
if (isSeamHttpOptionsWithClient(clientOptions)) {
|
|
92
|
+
throw new SeamHttpInvalidOptionsError(
|
|
93
|
+
'The client option cannot be used with SeamHttp.fromPublishableKey',
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
const client = createClient(clientOptions)
|
|
97
|
+
const clientSessions = SeamHttpClientSessions.fromClient(client)
|
|
98
|
+
const { token } = await clientSessions.getOrCreate({
|
|
99
|
+
user_identifier_key: userIdentifierKey,
|
|
100
|
+
})
|
|
101
|
+
return SeamHttpDevicesSimulate.fromClientSessionToken(token, options)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
static fromConsoleSessionToken(
|
|
105
|
+
consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'],
|
|
106
|
+
workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'],
|
|
107
|
+
options: Omit<
|
|
108
|
+
SeamHttpOptionsWithConsoleSessionToken,
|
|
109
|
+
'consoleSessionToken' | 'workspaceId'
|
|
110
|
+
> = {},
|
|
111
|
+
): SeamHttpDevicesSimulate {
|
|
112
|
+
const constructorOptions = { ...options, consoleSessionToken, workspaceId }
|
|
113
|
+
if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) {
|
|
114
|
+
throw new SeamHttpInvalidOptionsError(
|
|
115
|
+
'Missing consoleSessionToken or workspaceId',
|
|
116
|
+
)
|
|
117
|
+
}
|
|
118
|
+
return new SeamHttpDevicesSimulate(constructorOptions)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
static fromPersonalAccessToken(
|
|
122
|
+
personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'],
|
|
123
|
+
workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'],
|
|
124
|
+
options: Omit<
|
|
125
|
+
SeamHttpOptionsWithPersonalAccessToken,
|
|
126
|
+
'personalAccessToken' | 'workspaceId'
|
|
127
|
+
> = {},
|
|
128
|
+
): SeamHttpDevicesSimulate {
|
|
129
|
+
const constructorOptions = { ...options, personalAccessToken, workspaceId }
|
|
130
|
+
if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) {
|
|
131
|
+
throw new SeamHttpInvalidOptionsError(
|
|
132
|
+
'Missing personalAccessToken or workspaceId',
|
|
133
|
+
)
|
|
134
|
+
}
|
|
135
|
+
return new SeamHttpDevicesSimulate(constructorOptions)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async updateClientSessionToken(
|
|
139
|
+
clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
|
|
140
|
+
): Promise<void> {
|
|
141
|
+
const { headers } = this.client.defaults
|
|
142
|
+
const authHeaders = getAuthHeadersForClientSessionToken({
|
|
143
|
+
clientSessionToken,
|
|
144
|
+
})
|
|
145
|
+
for (const key of Object.keys(authHeaders)) {
|
|
146
|
+
if (headers[key] == null) {
|
|
147
|
+
throw new Error(
|
|
148
|
+
'Cannot update a clientSessionToken on a client created without a clientSessionToken',
|
|
149
|
+
)
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
this.client.defaults.headers = { ...headers, ...authHeaders }
|
|
153
|
+
const clientSessions = SeamHttpClientSessions.fromClient(this.client)
|
|
154
|
+
await clientSessions.get()
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
remove(body?: DevicesSimulateRemoveBody): SeamHttpRequest<void, undefined> {
|
|
158
|
+
return new SeamHttpRequest(this, {
|
|
159
|
+
path: '/devices/simulate/remove',
|
|
160
|
+
method: 'post',
|
|
161
|
+
body,
|
|
162
|
+
responseKey: undefined,
|
|
163
|
+
})
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export type DevicesSimulateRemoveBody =
|
|
168
|
+
RouteRequestBody<'/devices/simulate/remove'>
|
|
169
|
+
|
|
170
|
+
export type DevicesSimulateRemoveResponse = SetNonNullable<
|
|
171
|
+
Required<RouteResponse<'/devices/simulate/remove'>>
|
|
172
|
+
>
|
|
173
|
+
|
|
174
|
+
export type DevicesSimulateRemoveOptions = never
|
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
limitToSeamHttpRequestOptions,
|
|
32
32
|
parseOptions,
|
|
33
33
|
} from 'lib/seam/connect/parse-options.js'
|
|
34
|
+
import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js'
|
|
34
35
|
|
|
35
36
|
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
36
37
|
|
|
@@ -153,35 +154,34 @@ export class SeamHttpDevicesUnmanaged {
|
|
|
153
154
|
await clientSessions.get()
|
|
154
155
|
}
|
|
155
156
|
|
|
156
|
-
|
|
157
|
+
get(
|
|
157
158
|
body?: DevicesUnmanagedGetParams,
|
|
158
|
-
):
|
|
159
|
-
|
|
160
|
-
|
|
159
|
+
): SeamHttpRequest<DevicesUnmanagedGetResponse, 'device'> {
|
|
160
|
+
return new SeamHttpRequest(this, {
|
|
161
|
+
path: '/devices/unmanaged/get',
|
|
161
162
|
method: 'post',
|
|
162
|
-
|
|
163
|
+
body,
|
|
164
|
+
responseKey: 'device',
|
|
163
165
|
})
|
|
164
|
-
|
|
165
|
-
return data.device
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
-
|
|
168
|
+
list(
|
|
169
169
|
body?: DevicesUnmanagedListParams,
|
|
170
|
-
):
|
|
171
|
-
|
|
172
|
-
|
|
170
|
+
): SeamHttpRequest<DevicesUnmanagedListResponse, 'devices'> {
|
|
171
|
+
return new SeamHttpRequest(this, {
|
|
172
|
+
path: '/devices/unmanaged/list',
|
|
173
173
|
method: 'post',
|
|
174
|
-
|
|
174
|
+
body,
|
|
175
|
+
responseKey: 'devices',
|
|
175
176
|
})
|
|
176
|
-
|
|
177
|
-
return data.devices
|
|
178
177
|
}
|
|
179
178
|
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
179
|
+
update(body?: DevicesUnmanagedUpdateBody): SeamHttpRequest<void, undefined> {
|
|
180
|
+
return new SeamHttpRequest(this, {
|
|
181
|
+
path: '/devices/unmanaged/update',
|
|
183
182
|
method: 'post',
|
|
184
|
-
|
|
183
|
+
body,
|
|
184
|
+
responseKey: undefined,
|
|
185
185
|
})
|
|
186
186
|
}
|
|
187
187
|
}
|
|
@@ -31,8 +31,10 @@ import {
|
|
|
31
31
|
limitToSeamHttpRequestOptions,
|
|
32
32
|
parseOptions,
|
|
33
33
|
} from 'lib/seam/connect/parse-options.js'
|
|
34
|
+
import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js'
|
|
34
35
|
|
|
35
36
|
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
37
|
+
import { SeamHttpDevicesSimulate } from './devices-simulate.js'
|
|
36
38
|
import { SeamHttpDevicesUnmanaged } from './devices-unmanaged.js'
|
|
37
39
|
|
|
38
40
|
export class SeamHttpDevices {
|
|
@@ -158,54 +160,56 @@ export class SeamHttpDevices {
|
|
|
158
160
|
return SeamHttpDevicesUnmanaged.fromClient(this.client, this.defaults)
|
|
159
161
|
}
|
|
160
162
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
163
|
+
get simulate(): SeamHttpDevicesSimulate {
|
|
164
|
+
return SeamHttpDevicesSimulate.fromClient(this.client, this.defaults)
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
delete(body?: DevicesDeleteBody): SeamHttpRequest<void, undefined> {
|
|
168
|
+
return new SeamHttpRequest(this, {
|
|
169
|
+
path: '/devices/delete',
|
|
164
170
|
method: 'post',
|
|
165
|
-
|
|
171
|
+
body,
|
|
172
|
+
responseKey: undefined,
|
|
166
173
|
})
|
|
167
174
|
}
|
|
168
175
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
176
|
+
get(body?: DevicesGetParams): SeamHttpRequest<DevicesGetResponse, 'device'> {
|
|
177
|
+
return new SeamHttpRequest(this, {
|
|
178
|
+
path: '/devices/get',
|
|
172
179
|
method: 'post',
|
|
173
|
-
|
|
180
|
+
body,
|
|
181
|
+
responseKey: 'device',
|
|
174
182
|
})
|
|
175
|
-
|
|
176
|
-
return data.device
|
|
177
183
|
}
|
|
178
184
|
|
|
179
|
-
|
|
185
|
+
list(
|
|
180
186
|
body?: DevicesListParams,
|
|
181
|
-
):
|
|
182
|
-
|
|
183
|
-
|
|
187
|
+
): SeamHttpRequest<DevicesListResponse, 'devices'> {
|
|
188
|
+
return new SeamHttpRequest(this, {
|
|
189
|
+
path: '/devices/list',
|
|
184
190
|
method: 'post',
|
|
185
|
-
|
|
191
|
+
body,
|
|
192
|
+
responseKey: 'devices',
|
|
186
193
|
})
|
|
187
|
-
|
|
188
|
-
return data.devices
|
|
189
194
|
}
|
|
190
195
|
|
|
191
|
-
|
|
196
|
+
listDeviceProviders(
|
|
192
197
|
body?: DevicesListDeviceProvidersParams,
|
|
193
|
-
):
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
return data.device_providers
|
|
198
|
+
): SeamHttpRequest<DevicesListDeviceProvidersResponse, 'device_providers'> {
|
|
199
|
+
return new SeamHttpRequest(this, {
|
|
200
|
+
path: '/devices/list_device_providers',
|
|
201
|
+
method: 'post',
|
|
202
|
+
body,
|
|
203
|
+
responseKey: 'device_providers',
|
|
204
|
+
})
|
|
202
205
|
}
|
|
203
206
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
+
update(body?: DevicesUpdateBody): SeamHttpRequest<void, undefined> {
|
|
208
|
+
return new SeamHttpRequest(this, {
|
|
209
|
+
path: '/devices/update',
|
|
207
210
|
method: 'post',
|
|
208
|
-
|
|
211
|
+
body,
|
|
212
|
+
responseKey: undefined,
|
|
209
213
|
})
|
|
210
214
|
}
|
|
211
215
|
}
|
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
limitToSeamHttpRequestOptions,
|
|
32
32
|
parseOptions,
|
|
33
33
|
} from 'lib/seam/connect/parse-options.js'
|
|
34
|
+
import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js'
|
|
34
35
|
|
|
35
36
|
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
36
37
|
|
|
@@ -153,24 +154,22 @@ export class SeamHttpEvents {
|
|
|
153
154
|
await clientSessions.get()
|
|
154
155
|
}
|
|
155
156
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
157
|
+
get(body?: EventsGetParams): SeamHttpRequest<EventsGetResponse, 'event'> {
|
|
158
|
+
return new SeamHttpRequest(this, {
|
|
159
|
+
path: '/events/get',
|
|
159
160
|
method: 'post',
|
|
160
|
-
|
|
161
|
+
body,
|
|
162
|
+
responseKey: 'event',
|
|
161
163
|
})
|
|
162
|
-
|
|
163
|
-
return data.event
|
|
164
164
|
}
|
|
165
165
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
166
|
+
list(body?: EventsListParams): SeamHttpRequest<EventsListResponse, 'events'> {
|
|
167
|
+
return new SeamHttpRequest(this, {
|
|
168
|
+
path: '/events/list',
|
|
169
169
|
method: 'post',
|
|
170
|
-
|
|
170
|
+
body,
|
|
171
|
+
responseKey: 'events',
|
|
171
172
|
})
|
|
172
|
-
|
|
173
|
-
return data.events
|
|
174
173
|
}
|
|
175
174
|
}
|
|
176
175
|
|
|
@@ -13,6 +13,7 @@ export * from './client-sessions.js'
|
|
|
13
13
|
export * from './connect-webviews.js'
|
|
14
14
|
export * from './connected-accounts.js'
|
|
15
15
|
export * from './devices.js'
|
|
16
|
+
export * from './devices-simulate.js'
|
|
16
17
|
export * from './devices-unmanaged.js'
|
|
17
18
|
export * from './events.js'
|
|
18
19
|
export * from './locks.js'
|
|
@@ -31,9 +31,8 @@ import {
|
|
|
31
31
|
limitToSeamHttpRequestOptions,
|
|
32
32
|
parseOptions,
|
|
33
33
|
} from 'lib/seam/connect/parse-options.js'
|
|
34
|
-
import {
|
|
34
|
+
import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js'
|
|
35
35
|
|
|
36
|
-
import { SeamHttpActionAttempts } from './action-attempts.js'
|
|
37
36
|
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
38
37
|
|
|
39
38
|
export class SeamHttpLocks {
|
|
@@ -155,72 +154,48 @@ export class SeamHttpLocks {
|
|
|
155
154
|
await clientSessions.get()
|
|
156
155
|
}
|
|
157
156
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
157
|
+
get(body?: LocksGetParams): SeamHttpRequest<LocksGetResponse, 'device'> {
|
|
158
|
+
return new SeamHttpRequest(this, {
|
|
159
|
+
path: '/locks/get',
|
|
161
160
|
method: 'post',
|
|
162
|
-
|
|
161
|
+
body,
|
|
162
|
+
responseKey: 'device',
|
|
163
163
|
})
|
|
164
|
-
|
|
165
|
-
return data.device
|
|
166
164
|
}
|
|
167
165
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
166
|
+
list(body?: LocksListParams): SeamHttpRequest<LocksListResponse, 'devices'> {
|
|
167
|
+
return new SeamHttpRequest(this, {
|
|
168
|
+
path: '/locks/list',
|
|
171
169
|
method: 'post',
|
|
172
|
-
|
|
170
|
+
body,
|
|
171
|
+
responseKey: 'devices',
|
|
173
172
|
})
|
|
174
|
-
|
|
175
|
-
return data.devices
|
|
176
173
|
}
|
|
177
174
|
|
|
178
|
-
|
|
175
|
+
lockDoor(
|
|
179
176
|
body?: LocksLockDoorBody,
|
|
180
177
|
options: Pick<SeamHttpRequestOptions, 'waitForActionAttempt'> = {},
|
|
181
|
-
):
|
|
182
|
-
|
|
183
|
-
|
|
178
|
+
): SeamHttpRequest<LocksLockDoorResponse, 'action_attempt'> {
|
|
179
|
+
return new SeamHttpRequest(this, {
|
|
180
|
+
path: '/locks/lock_door',
|
|
184
181
|
method: 'post',
|
|
185
|
-
|
|
182
|
+
body,
|
|
183
|
+
responseKey: 'action_attempt',
|
|
184
|
+
options,
|
|
186
185
|
})
|
|
187
|
-
const waitForActionAttempt =
|
|
188
|
-
options.waitForActionAttempt ?? this.defaults.waitForActionAttempt
|
|
189
|
-
if (waitForActionAttempt !== false) {
|
|
190
|
-
return await resolveActionAttempt(
|
|
191
|
-
data.action_attempt,
|
|
192
|
-
SeamHttpActionAttempts.fromClient(this.client, {
|
|
193
|
-
...this.defaults,
|
|
194
|
-
waitForActionAttempt: false,
|
|
195
|
-
}),
|
|
196
|
-
typeof waitForActionAttempt === 'boolean' ? {} : waitForActionAttempt,
|
|
197
|
-
)
|
|
198
|
-
}
|
|
199
|
-
return data.action_attempt
|
|
200
186
|
}
|
|
201
187
|
|
|
202
|
-
|
|
188
|
+
unlockDoor(
|
|
203
189
|
body?: LocksUnlockDoorBody,
|
|
204
190
|
options: Pick<SeamHttpRequestOptions, 'waitForActionAttempt'> = {},
|
|
205
|
-
):
|
|
206
|
-
|
|
207
|
-
|
|
191
|
+
): SeamHttpRequest<LocksUnlockDoorResponse, 'action_attempt'> {
|
|
192
|
+
return new SeamHttpRequest(this, {
|
|
193
|
+
path: '/locks/unlock_door',
|
|
208
194
|
method: 'post',
|
|
209
|
-
|
|
195
|
+
body,
|
|
196
|
+
responseKey: 'action_attempt',
|
|
197
|
+
options,
|
|
210
198
|
})
|
|
211
|
-
const waitForActionAttempt =
|
|
212
|
-
options.waitForActionAttempt ?? this.defaults.waitForActionAttempt
|
|
213
|
-
if (waitForActionAttempt !== false) {
|
|
214
|
-
return await resolveActionAttempt(
|
|
215
|
-
data.action_attempt,
|
|
216
|
-
SeamHttpActionAttempts.fromClient(this.client, {
|
|
217
|
-
...this.defaults,
|
|
218
|
-
waitForActionAttempt: false,
|
|
219
|
-
}),
|
|
220
|
-
typeof waitForActionAttempt === 'boolean' ? {} : waitForActionAttempt,
|
|
221
|
-
)
|
|
222
|
-
}
|
|
223
|
-
return data.action_attempt
|
|
224
199
|
}
|
|
225
200
|
}
|
|
226
201
|
|