@seamapi/http 1.32.0 → 1.34.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/dist/connect.cjs +637 -210
- package/dist/connect.cjs.map +1 -1
- package/dist/connect.d.cts +537 -85
- package/lib/seam/connect/resolve-action-attempt.d.ts +488 -52
- package/lib/seam/connect/routes/access-codes.d.ts +4 -0
- package/lib/seam/connect/routes/access-codes.js +8 -0
- package/lib/seam/connect/routes/access-codes.js.map +1 -1
- package/lib/seam/connect/routes/access-grants.d.ts +35 -0
- package/lib/seam/connect/routes/access-grants.js +116 -0
- package/lib/seam/connect/routes/access-grants.js.map +1 -0
- package/lib/seam/connect/routes/{networks.d.ts → access-methods.d.ts} +19 -15
- package/lib/seam/connect/routes/{bridges.js → access-methods.js} +20 -12
- package/lib/seam/connect/routes/access-methods.js.map +1 -0
- package/lib/seam/connect/routes/acs-encoders.d.ts +4 -0
- package/lib/seam/connect/routes/acs-encoders.js +9 -0
- package/lib/seam/connect/routes/acs-encoders.js.map +1 -1
- package/lib/seam/connect/routes/connected-accounts.d.ts +4 -0
- package/lib/seam/connect/routes/connected-accounts.js +8 -0
- package/lib/seam/connect/routes/connected-accounts.js.map +1 -1
- package/lib/seam/connect/routes/index.d.ts +5 -2
- package/lib/seam/connect/routes/index.js +5 -2
- package/lib/seam/connect/routes/index.js.map +1 -1
- package/lib/seam/connect/routes/spaces.d.ts +55 -0
- package/lib/seam/connect/routes/spaces.js +156 -0
- package/lib/seam/connect/routes/spaces.js.map +1 -0
- package/lib/seam/connect/routes/thermostats-daily-programs.d.ts +31 -0
- package/lib/seam/connect/routes/thermostats-daily-programs.js +109 -0
- package/lib/seam/connect/routes/thermostats-daily-programs.js.map +1 -0
- package/lib/seam/connect/routes/thermostats.d.ts +6 -0
- package/lib/seam/connect/routes/thermostats.js +13 -0
- package/lib/seam/connect/routes/thermostats.js.map +1 -1
- package/lib/seam/connect/routes/{bridges.d.ts → unstable-partner.d.ts} +8 -18
- package/lib/seam/connect/routes/{networks.js → unstable-partner.js} +8 -25
- package/lib/seam/connect/routes/unstable-partner.js.map +1 -0
- package/lib/seam/connect/routes/workspaces.d.ts +4 -0
- package/lib/seam/connect/routes/workspaces.js +8 -0
- package/lib/seam/connect/routes/workspaces.js.map +1 -1
- package/lib/seam/connect/seam-http.d.ts +4 -2
- package/lib/seam/connect/seam-http.js +10 -4
- package/lib/seam/connect/seam-http.js.map +1 -1
- 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.ts +20 -0
- package/src/lib/seam/connect/routes/access-grants.ts +237 -0
- package/src/lib/seam/connect/routes/{networks.ts → access-methods.ts} +47 -29
- package/src/lib/seam/connect/routes/acs-encoders.ts +25 -0
- package/src/lib/seam/connect/routes/connected-accounts.ts +18 -0
- package/src/lib/seam/connect/routes/index.ts +5 -2
- package/src/lib/seam/connect/routes/spaces.ts +329 -0
- package/src/lib/seam/connect/routes/thermostats-daily-programs.ts +234 -0
- package/src/lib/seam/connect/routes/thermostats.ts +33 -0
- package/src/lib/seam/connect/routes/{bridges.ts → unstable-partner.ts} +14 -53
- package/src/lib/seam/connect/routes/workspaces.ts +17 -0
- package/src/lib/seam/connect/seam-http.ts +15 -5
- package/src/lib/version.ts +1 -1
- package/lib/seam/connect/routes/bridges.js.map +0 -1
- package/lib/seam/connect/routes/networks.js.map +0 -1
|
@@ -194,6 +194,15 @@ export class SeamHttpConnectedAccounts {
|
|
|
194
194
|
})
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
+
sync(body?: ConnectedAccountsSyncBody): SeamHttpRequest<void, undefined> {
|
|
198
|
+
return new SeamHttpRequest(this, {
|
|
199
|
+
pathname: '/connected_accounts/sync',
|
|
200
|
+
method: 'post',
|
|
201
|
+
body,
|
|
202
|
+
responseKey: undefined,
|
|
203
|
+
})
|
|
204
|
+
}
|
|
205
|
+
|
|
197
206
|
update(body?: ConnectedAccountsUpdateBody): SeamHttpRequest<void, undefined> {
|
|
198
207
|
return new SeamHttpRequest(this, {
|
|
199
208
|
pathname: '/connected_accounts/update',
|
|
@@ -231,6 +240,15 @@ export type ConnectedAccountsListResponse = SetNonNullable<
|
|
|
231
240
|
|
|
232
241
|
export type ConnectedAccountsListOptions = never
|
|
233
242
|
|
|
243
|
+
export type ConnectedAccountsSyncBody =
|
|
244
|
+
RouteRequestBody<'/connected_accounts/sync'>
|
|
245
|
+
|
|
246
|
+
export type ConnectedAccountsSyncResponse = SetNonNullable<
|
|
247
|
+
Required<RouteResponse<'/connected_accounts/sync'>>
|
|
248
|
+
>
|
|
249
|
+
|
|
250
|
+
export type ConnectedAccountsSyncOptions = never
|
|
251
|
+
|
|
234
252
|
export type ConnectedAccountsUpdateBody =
|
|
235
253
|
RouteRequestBody<'/connected_accounts/update'>
|
|
236
254
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export * from './access-codes.js'
|
|
2
2
|
export * from './access-codes-simulate.js'
|
|
3
3
|
export * from './access-codes-unmanaged.js'
|
|
4
|
+
export * from './access-grants.js'
|
|
5
|
+
export * from './access-methods.js'
|
|
4
6
|
export * from './acs.js'
|
|
5
7
|
export * from './acs-access-groups.js'
|
|
6
8
|
export * from './acs-credentials.js'
|
|
@@ -10,7 +12,6 @@ export * from './acs-entrances.js'
|
|
|
10
12
|
export * from './acs-systems.js'
|
|
11
13
|
export * from './acs-users.js'
|
|
12
14
|
export * from './action-attempts.js'
|
|
13
|
-
export * from './bridges.js'
|
|
14
15
|
export * from './client-sessions.js'
|
|
15
16
|
export * from './connect-webviews.js'
|
|
16
17
|
export * from './connected-accounts.js'
|
|
@@ -19,15 +20,17 @@ export * from './devices-simulate.js'
|
|
|
19
20
|
export * from './devices-unmanaged.js'
|
|
20
21
|
export * from './events.js'
|
|
21
22
|
export * from './locks.js'
|
|
22
|
-
export * from './networks.js'
|
|
23
23
|
export * from './noise-sensors.js'
|
|
24
24
|
export * from './noise-sensors-noise-thresholds.js'
|
|
25
25
|
export * from './noise-sensors-simulate.js'
|
|
26
26
|
export * from './phones.js'
|
|
27
27
|
export * from './phones-simulate.js'
|
|
28
|
+
export * from './spaces.js'
|
|
28
29
|
export * from './thermostats.js'
|
|
30
|
+
export * from './thermostats-daily-programs.js'
|
|
29
31
|
export * from './thermostats-schedules.js'
|
|
30
32
|
export * from './thermostats-simulate.js'
|
|
33
|
+
export * from './unstable-partner.js'
|
|
31
34
|
export * from './user-identities.js'
|
|
32
35
|
export * from './user-identities-enrollment-automations.js'
|
|
33
36
|
export * from './webhooks.js'
|
|
@@ -0,0 +1,329 @@
|
|
|
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
|
+
|
|
8
|
+
import {
|
|
9
|
+
getAuthHeadersForClientSessionToken,
|
|
10
|
+
warnOnInsecureuserIdentifierKey,
|
|
11
|
+
} from 'lib/seam/connect/auth.js'
|
|
12
|
+
import { type Client, createClient } from 'lib/seam/connect/client.js'
|
|
13
|
+
import {
|
|
14
|
+
isSeamHttpOptionsWithApiKey,
|
|
15
|
+
isSeamHttpOptionsWithClient,
|
|
16
|
+
isSeamHttpOptionsWithClientSessionToken,
|
|
17
|
+
isSeamHttpOptionsWithConsoleSessionToken,
|
|
18
|
+
isSeamHttpOptionsWithPersonalAccessToken,
|
|
19
|
+
type SeamHttpFromPublishableKeyOptions,
|
|
20
|
+
SeamHttpInvalidOptionsError,
|
|
21
|
+
type SeamHttpOptions,
|
|
22
|
+
type SeamHttpOptionsWithApiKey,
|
|
23
|
+
type SeamHttpOptionsWithClient,
|
|
24
|
+
type SeamHttpOptionsWithClientSessionToken,
|
|
25
|
+
type SeamHttpOptionsWithConsoleSessionToken,
|
|
26
|
+
type SeamHttpOptionsWithPersonalAccessToken,
|
|
27
|
+
type SeamHttpRequestOptions,
|
|
28
|
+
} from 'lib/seam/connect/options.js'
|
|
29
|
+
import {
|
|
30
|
+
limitToSeamHttpRequestOptions,
|
|
31
|
+
parseOptions,
|
|
32
|
+
} from 'lib/seam/connect/parse-options.js'
|
|
33
|
+
import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js'
|
|
34
|
+
import { SeamPaginator } from 'lib/seam/connect/seam-paginator.js'
|
|
35
|
+
import type { SetNonNullable } from 'lib/types.js'
|
|
36
|
+
|
|
37
|
+
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
38
|
+
|
|
39
|
+
export class SeamHttpSpaces {
|
|
40
|
+
client: Client
|
|
41
|
+
readonly defaults: Required<SeamHttpRequestOptions>
|
|
42
|
+
|
|
43
|
+
constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
|
|
44
|
+
const options = parseOptions(apiKeyOrOptions)
|
|
45
|
+
this.client = 'client' in options ? options.client : createClient(options)
|
|
46
|
+
this.defaults = limitToSeamHttpRequestOptions(options)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static fromClient(
|
|
50
|
+
client: SeamHttpOptionsWithClient['client'],
|
|
51
|
+
options: Omit<SeamHttpOptionsWithClient, 'client'> = {},
|
|
52
|
+
): SeamHttpSpaces {
|
|
53
|
+
const constructorOptions = { ...options, client }
|
|
54
|
+
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
55
|
+
throw new SeamHttpInvalidOptionsError('Missing client')
|
|
56
|
+
}
|
|
57
|
+
return new SeamHttpSpaces(constructorOptions)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
static fromApiKey(
|
|
61
|
+
apiKey: SeamHttpOptionsWithApiKey['apiKey'],
|
|
62
|
+
options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
|
|
63
|
+
): SeamHttpSpaces {
|
|
64
|
+
const constructorOptions = { ...options, apiKey }
|
|
65
|
+
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
66
|
+
throw new SeamHttpInvalidOptionsError('Missing apiKey')
|
|
67
|
+
}
|
|
68
|
+
return new SeamHttpSpaces(constructorOptions)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
static fromClientSessionToken(
|
|
72
|
+
clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
|
|
73
|
+
options: Omit<
|
|
74
|
+
SeamHttpOptionsWithClientSessionToken,
|
|
75
|
+
'clientSessionToken'
|
|
76
|
+
> = {},
|
|
77
|
+
): SeamHttpSpaces {
|
|
78
|
+
const constructorOptions = { ...options, clientSessionToken }
|
|
79
|
+
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
80
|
+
throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
|
|
81
|
+
}
|
|
82
|
+
return new SeamHttpSpaces(constructorOptions)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
static async fromPublishableKey(
|
|
86
|
+
publishableKey: string,
|
|
87
|
+
userIdentifierKey: string,
|
|
88
|
+
options: SeamHttpFromPublishableKeyOptions = {},
|
|
89
|
+
): Promise<SeamHttpSpaces> {
|
|
90
|
+
warnOnInsecureuserIdentifierKey(userIdentifierKey)
|
|
91
|
+
const clientOptions = parseOptions({ ...options, publishableKey })
|
|
92
|
+
if (isSeamHttpOptionsWithClient(clientOptions)) {
|
|
93
|
+
throw new SeamHttpInvalidOptionsError(
|
|
94
|
+
'The client option cannot be used with SeamHttp.fromPublishableKey',
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
const client = createClient(clientOptions)
|
|
98
|
+
const clientSessions = SeamHttpClientSessions.fromClient(client)
|
|
99
|
+
const { token } = await clientSessions.getOrCreate({
|
|
100
|
+
user_identifier_key: userIdentifierKey,
|
|
101
|
+
})
|
|
102
|
+
return SeamHttpSpaces.fromClientSessionToken(token, options)
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
static fromConsoleSessionToken(
|
|
106
|
+
consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'],
|
|
107
|
+
workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'],
|
|
108
|
+
options: Omit<
|
|
109
|
+
SeamHttpOptionsWithConsoleSessionToken,
|
|
110
|
+
'consoleSessionToken' | 'workspaceId'
|
|
111
|
+
> = {},
|
|
112
|
+
): SeamHttpSpaces {
|
|
113
|
+
const constructorOptions = { ...options, consoleSessionToken, workspaceId }
|
|
114
|
+
if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) {
|
|
115
|
+
throw new SeamHttpInvalidOptionsError(
|
|
116
|
+
'Missing consoleSessionToken or workspaceId',
|
|
117
|
+
)
|
|
118
|
+
}
|
|
119
|
+
return new SeamHttpSpaces(constructorOptions)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
static fromPersonalAccessToken(
|
|
123
|
+
personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'],
|
|
124
|
+
workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'],
|
|
125
|
+
options: Omit<
|
|
126
|
+
SeamHttpOptionsWithPersonalAccessToken,
|
|
127
|
+
'personalAccessToken' | 'workspaceId'
|
|
128
|
+
> = {},
|
|
129
|
+
): SeamHttpSpaces {
|
|
130
|
+
const constructorOptions = { ...options, personalAccessToken, workspaceId }
|
|
131
|
+
if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) {
|
|
132
|
+
throw new SeamHttpInvalidOptionsError(
|
|
133
|
+
'Missing personalAccessToken or workspaceId',
|
|
134
|
+
)
|
|
135
|
+
}
|
|
136
|
+
return new SeamHttpSpaces(constructorOptions)
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
createPaginator<const TResponse, const TResponseKey extends keyof TResponse>(
|
|
140
|
+
request: SeamHttpRequest<TResponse, TResponseKey>,
|
|
141
|
+
): SeamPaginator<TResponse, TResponseKey> {
|
|
142
|
+
return new SeamPaginator<TResponse, TResponseKey>(this, request)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
async updateClientSessionToken(
|
|
146
|
+
clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
|
|
147
|
+
): Promise<void> {
|
|
148
|
+
const { headers } = this.client.defaults
|
|
149
|
+
const authHeaders = getAuthHeadersForClientSessionToken({
|
|
150
|
+
clientSessionToken,
|
|
151
|
+
})
|
|
152
|
+
for (const key of Object.keys(authHeaders)) {
|
|
153
|
+
if (headers[key] == null) {
|
|
154
|
+
throw new Error(
|
|
155
|
+
'Cannot update a clientSessionToken on a client created without a clientSessionToken',
|
|
156
|
+
)
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
this.client.defaults.headers = { ...headers, ...authHeaders }
|
|
160
|
+
const clientSessions = SeamHttpClientSessions.fromClient(this.client)
|
|
161
|
+
await clientSessions.get()
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
addAcsEntrances(
|
|
165
|
+
body?: SpacesAddAcsEntrancesBody,
|
|
166
|
+
): SeamHttpRequest<void, undefined> {
|
|
167
|
+
return new SeamHttpRequest(this, {
|
|
168
|
+
pathname: '/spaces/add_acs_entrances',
|
|
169
|
+
method: 'post',
|
|
170
|
+
body,
|
|
171
|
+
responseKey: undefined,
|
|
172
|
+
})
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
addDevices(body?: SpacesAddDevicesBody): SeamHttpRequest<void, undefined> {
|
|
176
|
+
return new SeamHttpRequest(this, {
|
|
177
|
+
pathname: '/spaces/add_devices',
|
|
178
|
+
method: 'post',
|
|
179
|
+
body,
|
|
180
|
+
responseKey: undefined,
|
|
181
|
+
})
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
create(
|
|
185
|
+
body?: SpacesCreateBody,
|
|
186
|
+
): SeamHttpRequest<SpacesCreateResponse, 'space'> {
|
|
187
|
+
return new SeamHttpRequest(this, {
|
|
188
|
+
pathname: '/spaces/create',
|
|
189
|
+
method: 'post',
|
|
190
|
+
body,
|
|
191
|
+
responseKey: 'space',
|
|
192
|
+
})
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
delete(body?: SpacesDeleteParams): SeamHttpRequest<void, undefined> {
|
|
196
|
+
return new SeamHttpRequest(this, {
|
|
197
|
+
pathname: '/spaces/delete',
|
|
198
|
+
method: 'post',
|
|
199
|
+
body,
|
|
200
|
+
responseKey: undefined,
|
|
201
|
+
})
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
get(body?: SpacesGetParams): SeamHttpRequest<SpacesGetResponse, 'space'> {
|
|
205
|
+
return new SeamHttpRequest(this, {
|
|
206
|
+
pathname: '/spaces/get',
|
|
207
|
+
method: 'post',
|
|
208
|
+
body,
|
|
209
|
+
responseKey: 'space',
|
|
210
|
+
})
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
list(body?: SpacesListParams): SeamHttpRequest<SpacesListResponse, 'spaces'> {
|
|
214
|
+
return new SeamHttpRequest(this, {
|
|
215
|
+
pathname: '/spaces/list',
|
|
216
|
+
method: 'post',
|
|
217
|
+
body,
|
|
218
|
+
responseKey: 'spaces',
|
|
219
|
+
})
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
removeAcsEntrances(
|
|
223
|
+
body?: SpacesRemoveAcsEntrancesParams,
|
|
224
|
+
): SeamHttpRequest<void, undefined> {
|
|
225
|
+
return new SeamHttpRequest(this, {
|
|
226
|
+
pathname: '/spaces/remove_acs_entrances',
|
|
227
|
+
method: 'post',
|
|
228
|
+
body,
|
|
229
|
+
responseKey: undefined,
|
|
230
|
+
})
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
removeDevices(
|
|
234
|
+
body?: SpacesRemoveDevicesParams,
|
|
235
|
+
): SeamHttpRequest<void, undefined> {
|
|
236
|
+
return new SeamHttpRequest(this, {
|
|
237
|
+
pathname: '/spaces/remove_devices',
|
|
238
|
+
method: 'post',
|
|
239
|
+
body,
|
|
240
|
+
responseKey: undefined,
|
|
241
|
+
})
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
update(
|
|
245
|
+
body?: SpacesUpdateBody,
|
|
246
|
+
): SeamHttpRequest<SpacesUpdateResponse, 'space'> {
|
|
247
|
+
return new SeamHttpRequest(this, {
|
|
248
|
+
pathname: '/spaces/update',
|
|
249
|
+
method: 'post',
|
|
250
|
+
body,
|
|
251
|
+
responseKey: 'space',
|
|
252
|
+
})
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export type SpacesAddAcsEntrancesBody =
|
|
257
|
+
RouteRequestBody<'/spaces/add_acs_entrances'>
|
|
258
|
+
|
|
259
|
+
export type SpacesAddAcsEntrancesResponse = SetNonNullable<
|
|
260
|
+
Required<RouteResponse<'/spaces/add_acs_entrances'>>
|
|
261
|
+
>
|
|
262
|
+
|
|
263
|
+
export type SpacesAddAcsEntrancesOptions = never
|
|
264
|
+
|
|
265
|
+
export type SpacesAddDevicesBody = RouteRequestBody<'/spaces/add_devices'>
|
|
266
|
+
|
|
267
|
+
export type SpacesAddDevicesResponse = SetNonNullable<
|
|
268
|
+
Required<RouteResponse<'/spaces/add_devices'>>
|
|
269
|
+
>
|
|
270
|
+
|
|
271
|
+
export type SpacesAddDevicesOptions = never
|
|
272
|
+
|
|
273
|
+
export type SpacesCreateBody = RouteRequestBody<'/spaces/create'>
|
|
274
|
+
|
|
275
|
+
export type SpacesCreateResponse = SetNonNullable<
|
|
276
|
+
Required<RouteResponse<'/spaces/create'>>
|
|
277
|
+
>
|
|
278
|
+
|
|
279
|
+
export type SpacesCreateOptions = never
|
|
280
|
+
|
|
281
|
+
export type SpacesDeleteParams = RouteRequestBody<'/spaces/delete'>
|
|
282
|
+
|
|
283
|
+
export type SpacesDeleteResponse = SetNonNullable<
|
|
284
|
+
Required<RouteResponse<'/spaces/delete'>>
|
|
285
|
+
>
|
|
286
|
+
|
|
287
|
+
export type SpacesDeleteOptions = never
|
|
288
|
+
|
|
289
|
+
export type SpacesGetParams = RouteRequestBody<'/spaces/get'>
|
|
290
|
+
|
|
291
|
+
export type SpacesGetResponse = SetNonNullable<
|
|
292
|
+
Required<RouteResponse<'/spaces/get'>>
|
|
293
|
+
>
|
|
294
|
+
|
|
295
|
+
export type SpacesGetOptions = never
|
|
296
|
+
|
|
297
|
+
export type SpacesListParams = RouteRequestBody<'/spaces/list'>
|
|
298
|
+
|
|
299
|
+
export type SpacesListResponse = SetNonNullable<
|
|
300
|
+
Required<RouteResponse<'/spaces/list'>>
|
|
301
|
+
>
|
|
302
|
+
|
|
303
|
+
export type SpacesListOptions = never
|
|
304
|
+
|
|
305
|
+
export type SpacesRemoveAcsEntrancesParams =
|
|
306
|
+
RouteRequestBody<'/spaces/remove_acs_entrances'>
|
|
307
|
+
|
|
308
|
+
export type SpacesRemoveAcsEntrancesResponse = SetNonNullable<
|
|
309
|
+
Required<RouteResponse<'/spaces/remove_acs_entrances'>>
|
|
310
|
+
>
|
|
311
|
+
|
|
312
|
+
export type SpacesRemoveAcsEntrancesOptions = never
|
|
313
|
+
|
|
314
|
+
export type SpacesRemoveDevicesParams =
|
|
315
|
+
RouteRequestBody<'/spaces/remove_devices'>
|
|
316
|
+
|
|
317
|
+
export type SpacesRemoveDevicesResponse = SetNonNullable<
|
|
318
|
+
Required<RouteResponse<'/spaces/remove_devices'>>
|
|
319
|
+
>
|
|
320
|
+
|
|
321
|
+
export type SpacesRemoveDevicesOptions = never
|
|
322
|
+
|
|
323
|
+
export type SpacesUpdateBody = RouteRequestBody<'/spaces/update'>
|
|
324
|
+
|
|
325
|
+
export type SpacesUpdateResponse = SetNonNullable<
|
|
326
|
+
Required<RouteResponse<'/spaces/update'>>
|
|
327
|
+
>
|
|
328
|
+
|
|
329
|
+
export type SpacesUpdateOptions = never
|
|
@@ -0,0 +1,234 @@
|
|
|
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
|
+
|
|
8
|
+
import {
|
|
9
|
+
getAuthHeadersForClientSessionToken,
|
|
10
|
+
warnOnInsecureuserIdentifierKey,
|
|
11
|
+
} from 'lib/seam/connect/auth.js'
|
|
12
|
+
import { type Client, createClient } from 'lib/seam/connect/client.js'
|
|
13
|
+
import {
|
|
14
|
+
isSeamHttpOptionsWithApiKey,
|
|
15
|
+
isSeamHttpOptionsWithClient,
|
|
16
|
+
isSeamHttpOptionsWithClientSessionToken,
|
|
17
|
+
isSeamHttpOptionsWithConsoleSessionToken,
|
|
18
|
+
isSeamHttpOptionsWithPersonalAccessToken,
|
|
19
|
+
type SeamHttpFromPublishableKeyOptions,
|
|
20
|
+
SeamHttpInvalidOptionsError,
|
|
21
|
+
type SeamHttpOptions,
|
|
22
|
+
type SeamHttpOptionsWithApiKey,
|
|
23
|
+
type SeamHttpOptionsWithClient,
|
|
24
|
+
type SeamHttpOptionsWithClientSessionToken,
|
|
25
|
+
type SeamHttpOptionsWithConsoleSessionToken,
|
|
26
|
+
type SeamHttpOptionsWithPersonalAccessToken,
|
|
27
|
+
type SeamHttpRequestOptions,
|
|
28
|
+
} from 'lib/seam/connect/options.js'
|
|
29
|
+
import {
|
|
30
|
+
limitToSeamHttpRequestOptions,
|
|
31
|
+
parseOptions,
|
|
32
|
+
} from 'lib/seam/connect/parse-options.js'
|
|
33
|
+
import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js'
|
|
34
|
+
import { SeamPaginator } from 'lib/seam/connect/seam-paginator.js'
|
|
35
|
+
import type { SetNonNullable } from 'lib/types.js'
|
|
36
|
+
|
|
37
|
+
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
38
|
+
|
|
39
|
+
export class SeamHttpThermostatsDailyPrograms {
|
|
40
|
+
client: Client
|
|
41
|
+
readonly defaults: Required<SeamHttpRequestOptions>
|
|
42
|
+
|
|
43
|
+
constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
|
|
44
|
+
const options = parseOptions(apiKeyOrOptions)
|
|
45
|
+
this.client = 'client' in options ? options.client : createClient(options)
|
|
46
|
+
this.defaults = limitToSeamHttpRequestOptions(options)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static fromClient(
|
|
50
|
+
client: SeamHttpOptionsWithClient['client'],
|
|
51
|
+
options: Omit<SeamHttpOptionsWithClient, 'client'> = {},
|
|
52
|
+
): SeamHttpThermostatsDailyPrograms {
|
|
53
|
+
const constructorOptions = { ...options, client }
|
|
54
|
+
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
55
|
+
throw new SeamHttpInvalidOptionsError('Missing client')
|
|
56
|
+
}
|
|
57
|
+
return new SeamHttpThermostatsDailyPrograms(constructorOptions)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
static fromApiKey(
|
|
61
|
+
apiKey: SeamHttpOptionsWithApiKey['apiKey'],
|
|
62
|
+
options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
|
|
63
|
+
): SeamHttpThermostatsDailyPrograms {
|
|
64
|
+
const constructorOptions = { ...options, apiKey }
|
|
65
|
+
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
66
|
+
throw new SeamHttpInvalidOptionsError('Missing apiKey')
|
|
67
|
+
}
|
|
68
|
+
return new SeamHttpThermostatsDailyPrograms(constructorOptions)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
static fromClientSessionToken(
|
|
72
|
+
clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
|
|
73
|
+
options: Omit<
|
|
74
|
+
SeamHttpOptionsWithClientSessionToken,
|
|
75
|
+
'clientSessionToken'
|
|
76
|
+
> = {},
|
|
77
|
+
): SeamHttpThermostatsDailyPrograms {
|
|
78
|
+
const constructorOptions = { ...options, clientSessionToken }
|
|
79
|
+
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
80
|
+
throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
|
|
81
|
+
}
|
|
82
|
+
return new SeamHttpThermostatsDailyPrograms(constructorOptions)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
static async fromPublishableKey(
|
|
86
|
+
publishableKey: string,
|
|
87
|
+
userIdentifierKey: string,
|
|
88
|
+
options: SeamHttpFromPublishableKeyOptions = {},
|
|
89
|
+
): Promise<SeamHttpThermostatsDailyPrograms> {
|
|
90
|
+
warnOnInsecureuserIdentifierKey(userIdentifierKey)
|
|
91
|
+
const clientOptions = parseOptions({ ...options, publishableKey })
|
|
92
|
+
if (isSeamHttpOptionsWithClient(clientOptions)) {
|
|
93
|
+
throw new SeamHttpInvalidOptionsError(
|
|
94
|
+
'The client option cannot be used with SeamHttp.fromPublishableKey',
|
|
95
|
+
)
|
|
96
|
+
}
|
|
97
|
+
const client = createClient(clientOptions)
|
|
98
|
+
const clientSessions = SeamHttpClientSessions.fromClient(client)
|
|
99
|
+
const { token } = await clientSessions.getOrCreate({
|
|
100
|
+
user_identifier_key: userIdentifierKey,
|
|
101
|
+
})
|
|
102
|
+
return SeamHttpThermostatsDailyPrograms.fromClientSessionToken(
|
|
103
|
+
token,
|
|
104
|
+
options,
|
|
105
|
+
)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
static fromConsoleSessionToken(
|
|
109
|
+
consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'],
|
|
110
|
+
workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'],
|
|
111
|
+
options: Omit<
|
|
112
|
+
SeamHttpOptionsWithConsoleSessionToken,
|
|
113
|
+
'consoleSessionToken' | 'workspaceId'
|
|
114
|
+
> = {},
|
|
115
|
+
): SeamHttpThermostatsDailyPrograms {
|
|
116
|
+
const constructorOptions = { ...options, consoleSessionToken, workspaceId }
|
|
117
|
+
if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) {
|
|
118
|
+
throw new SeamHttpInvalidOptionsError(
|
|
119
|
+
'Missing consoleSessionToken or workspaceId',
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
return new SeamHttpThermostatsDailyPrograms(constructorOptions)
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
static fromPersonalAccessToken(
|
|
126
|
+
personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'],
|
|
127
|
+
workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'],
|
|
128
|
+
options: Omit<
|
|
129
|
+
SeamHttpOptionsWithPersonalAccessToken,
|
|
130
|
+
'personalAccessToken' | 'workspaceId'
|
|
131
|
+
> = {},
|
|
132
|
+
): SeamHttpThermostatsDailyPrograms {
|
|
133
|
+
const constructorOptions = { ...options, personalAccessToken, workspaceId }
|
|
134
|
+
if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) {
|
|
135
|
+
throw new SeamHttpInvalidOptionsError(
|
|
136
|
+
'Missing personalAccessToken or workspaceId',
|
|
137
|
+
)
|
|
138
|
+
}
|
|
139
|
+
return new SeamHttpThermostatsDailyPrograms(constructorOptions)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
createPaginator<const TResponse, const TResponseKey extends keyof TResponse>(
|
|
143
|
+
request: SeamHttpRequest<TResponse, TResponseKey>,
|
|
144
|
+
): SeamPaginator<TResponse, TResponseKey> {
|
|
145
|
+
return new SeamPaginator<TResponse, TResponseKey>(this, request)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
async updateClientSessionToken(
|
|
149
|
+
clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
|
|
150
|
+
): Promise<void> {
|
|
151
|
+
const { headers } = this.client.defaults
|
|
152
|
+
const authHeaders = getAuthHeadersForClientSessionToken({
|
|
153
|
+
clientSessionToken,
|
|
154
|
+
})
|
|
155
|
+
for (const key of Object.keys(authHeaders)) {
|
|
156
|
+
if (headers[key] == null) {
|
|
157
|
+
throw new Error(
|
|
158
|
+
'Cannot update a clientSessionToken on a client created without a clientSessionToken',
|
|
159
|
+
)
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
this.client.defaults.headers = { ...headers, ...authHeaders }
|
|
163
|
+
const clientSessions = SeamHttpClientSessions.fromClient(this.client)
|
|
164
|
+
await clientSessions.get()
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
create(
|
|
168
|
+
body?: ThermostatsDailyProgramsCreateBody,
|
|
169
|
+
): SeamHttpRequest<
|
|
170
|
+
ThermostatsDailyProgramsCreateResponse,
|
|
171
|
+
'thermostat_daily_program'
|
|
172
|
+
> {
|
|
173
|
+
return new SeamHttpRequest(this, {
|
|
174
|
+
pathname: '/thermostats/daily_programs/create',
|
|
175
|
+
method: 'post',
|
|
176
|
+
body,
|
|
177
|
+
responseKey: 'thermostat_daily_program',
|
|
178
|
+
})
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
delete(
|
|
182
|
+
body?: ThermostatsDailyProgramsDeleteParams,
|
|
183
|
+
): SeamHttpRequest<void, undefined> {
|
|
184
|
+
return new SeamHttpRequest(this, {
|
|
185
|
+
pathname: '/thermostats/daily_programs/delete',
|
|
186
|
+
method: 'post',
|
|
187
|
+
body,
|
|
188
|
+
responseKey: undefined,
|
|
189
|
+
})
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
update(
|
|
193
|
+
body?: ThermostatsDailyProgramsUpdateBody,
|
|
194
|
+
options: Pick<SeamHttpRequestOptions, 'waitForActionAttempt'> = {},
|
|
195
|
+
): SeamHttpRequest<ThermostatsDailyProgramsUpdateResponse, 'action_attempt'> {
|
|
196
|
+
return new SeamHttpRequest(this, {
|
|
197
|
+
pathname: '/thermostats/daily_programs/update',
|
|
198
|
+
method: 'post',
|
|
199
|
+
body,
|
|
200
|
+
responseKey: 'action_attempt',
|
|
201
|
+
options,
|
|
202
|
+
})
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export type ThermostatsDailyProgramsCreateBody =
|
|
207
|
+
RouteRequestBody<'/thermostats/daily_programs/create'>
|
|
208
|
+
|
|
209
|
+
export type ThermostatsDailyProgramsCreateResponse = SetNonNullable<
|
|
210
|
+
Required<RouteResponse<'/thermostats/daily_programs/create'>>
|
|
211
|
+
>
|
|
212
|
+
|
|
213
|
+
export type ThermostatsDailyProgramsCreateOptions = never
|
|
214
|
+
|
|
215
|
+
export type ThermostatsDailyProgramsDeleteParams =
|
|
216
|
+
RouteRequestBody<'/thermostats/daily_programs/delete'>
|
|
217
|
+
|
|
218
|
+
export type ThermostatsDailyProgramsDeleteResponse = SetNonNullable<
|
|
219
|
+
Required<RouteResponse<'/thermostats/daily_programs/delete'>>
|
|
220
|
+
>
|
|
221
|
+
|
|
222
|
+
export type ThermostatsDailyProgramsDeleteOptions = never
|
|
223
|
+
|
|
224
|
+
export type ThermostatsDailyProgramsUpdateBody =
|
|
225
|
+
RouteRequestBody<'/thermostats/daily_programs/update'>
|
|
226
|
+
|
|
227
|
+
export type ThermostatsDailyProgramsUpdateResponse = SetNonNullable<
|
|
228
|
+
Required<RouteResponse<'/thermostats/daily_programs/update'>>
|
|
229
|
+
>
|
|
230
|
+
|
|
231
|
+
export type ThermostatsDailyProgramsUpdateOptions = Pick<
|
|
232
|
+
SeamHttpRequestOptions,
|
|
233
|
+
'waitForActionAttempt'
|
|
234
|
+
>
|
|
@@ -35,6 +35,7 @@ import { SeamPaginator } from 'lib/seam/connect/seam-paginator.js'
|
|
|
35
35
|
import type { SetNonNullable } from 'lib/types.js'
|
|
36
36
|
|
|
37
37
|
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
38
|
+
import { SeamHttpThermostatsDailyPrograms } from './thermostats-daily-programs.js'
|
|
38
39
|
import { SeamHttpThermostatsSchedules } from './thermostats-schedules.js'
|
|
39
40
|
import { SeamHttpThermostatsSimulate } from './thermostats-simulate.js'
|
|
40
41
|
|
|
@@ -171,6 +172,13 @@ export class SeamHttpThermostats {
|
|
|
171
172
|
return SeamHttpThermostatsSimulate.fromClient(this.client, this.defaults)
|
|
172
173
|
}
|
|
173
174
|
|
|
175
|
+
get dailyPrograms(): SeamHttpThermostatsDailyPrograms {
|
|
176
|
+
return SeamHttpThermostatsDailyPrograms.fromClient(
|
|
177
|
+
this.client,
|
|
178
|
+
this.defaults,
|
|
179
|
+
)
|
|
180
|
+
}
|
|
181
|
+
|
|
174
182
|
activateClimatePreset(
|
|
175
183
|
body?: ThermostatsActivateClimatePresetBody,
|
|
176
184
|
options: Pick<SeamHttpRequestOptions, 'waitForActionAttempt'> = {},
|
|
@@ -330,6 +338,19 @@ export class SeamHttpThermostats {
|
|
|
330
338
|
responseKey: undefined,
|
|
331
339
|
})
|
|
332
340
|
}
|
|
341
|
+
|
|
342
|
+
updateWeeklyProgram(
|
|
343
|
+
body?: ThermostatsUpdateWeeklyProgramBody,
|
|
344
|
+
options: Pick<SeamHttpRequestOptions, 'waitForActionAttempt'> = {},
|
|
345
|
+
): SeamHttpRequest<ThermostatsUpdateWeeklyProgramResponse, 'action_attempt'> {
|
|
346
|
+
return new SeamHttpRequest(this, {
|
|
347
|
+
pathname: '/thermostats/update_weekly_program',
|
|
348
|
+
method: 'post',
|
|
349
|
+
body,
|
|
350
|
+
responseKey: 'action_attempt',
|
|
351
|
+
options,
|
|
352
|
+
})
|
|
353
|
+
}
|
|
333
354
|
}
|
|
334
355
|
|
|
335
356
|
export type ThermostatsActivateClimatePresetBody =
|
|
@@ -464,3 +485,15 @@ export type ThermostatsUpdateClimatePresetResponse = SetNonNullable<
|
|
|
464
485
|
>
|
|
465
486
|
|
|
466
487
|
export type ThermostatsUpdateClimatePresetOptions = never
|
|
488
|
+
|
|
489
|
+
export type ThermostatsUpdateWeeklyProgramBody =
|
|
490
|
+
RouteRequestBody<'/thermostats/update_weekly_program'>
|
|
491
|
+
|
|
492
|
+
export type ThermostatsUpdateWeeklyProgramResponse = SetNonNullable<
|
|
493
|
+
Required<RouteResponse<'/thermostats/update_weekly_program'>>
|
|
494
|
+
>
|
|
495
|
+
|
|
496
|
+
export type ThermostatsUpdateWeeklyProgramOptions = Pick<
|
|
497
|
+
SeamHttpRequestOptions,
|
|
498
|
+
'waitForActionAttempt'
|
|
499
|
+
>
|