@seamapi/http 0.0.2 → 0.2.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 +1807 -96
- package/dist/connect.cjs.map +1 -1
- package/dist/connect.d.cts +472 -15
- package/lib/params-serializer.d.ts +5 -0
- package/lib/params-serializer.js +42 -0
- package/lib/params-serializer.js.map +1 -0
- package/lib/seam/connect/auth.d.ts +4 -3
- package/lib/seam/connect/auth.js +59 -8
- package/lib/seam/connect/auth.js.map +1 -1
- package/lib/seam/connect/client.d.ts +10 -10
- package/lib/seam/connect/client.js +16 -49
- package/lib/seam/connect/client.js.map +1 -1
- package/lib/seam/connect/index.d.ts +2 -1
- package/lib/seam/connect/index.js +2 -1
- package/lib/seam/connect/index.js.map +1 -1
- package/lib/seam/connect/options.d.ts +23 -0
- package/lib/seam/connect/options.js +39 -0
- package/lib/seam/connect/options.js.map +1 -0
- package/lib/seam/connect/parse-options.d.ts +6 -2
- package/lib/seam/connect/parse-options.js +35 -10
- package/lib/seam/connect/parse-options.js.map +1 -1
- package/lib/seam/connect/routes/access-codes-unmanaged.d.ts +27 -0
- package/lib/seam/connect/routes/access-codes-unmanaged.js +84 -0
- package/lib/seam/connect/routes/access-codes-unmanaged.js.map +1 -0
- package/lib/seam/connect/routes/access-codes.d.ts +38 -0
- package/lib/seam/connect/routes/access-codes.js +113 -0
- package/lib/seam/connect/routes/access-codes.js.map +1 -0
- package/lib/seam/connect/routes/acs-access-groups.d.ts +36 -0
- package/lib/seam/connect/routes/acs-access-groups.js +107 -0
- package/lib/seam/connect/routes/acs-access-groups.js.map +1 -0
- package/lib/seam/connect/routes/acs-credentials.d.ts +24 -0
- package/lib/seam/connect/routes/acs-credentials.js +78 -0
- package/lib/seam/connect/routes/acs-credentials.js.map +1 -0
- package/lib/seam/connect/routes/acs-systems.d.ts +18 -0
- package/lib/seam/connect/routes/acs-systems.js +63 -0
- package/lib/seam/connect/routes/acs-systems.js.map +1 -0
- package/lib/seam/connect/routes/acs-users.d.ts +39 -0
- package/lib/seam/connect/routes/acs-users.js +113 -0
- package/lib/seam/connect/routes/acs-users.js.map +1 -0
- package/lib/seam/connect/routes/acs.d.ts +18 -0
- package/lib/seam/connect/routes/acs.js +63 -0
- package/lib/seam/connect/routes/acs.js.map +1 -0
- package/lib/seam/connect/routes/action-attempts.d.ts +18 -0
- package/lib/seam/connect/routes/action-attempts.js +63 -0
- package/lib/seam/connect/routes/action-attempts.js.map +1 -0
- package/lib/seam/connect/routes/client-sessions.d.ts +30 -0
- package/lib/seam/connect/routes/client-sessions.js +93 -0
- package/lib/seam/connect/routes/client-sessions.js.map +1 -0
- package/lib/seam/connect/routes/connect-webviews.d.ts +27 -0
- package/lib/seam/connect/routes/connect-webviews.js +85 -0
- package/lib/seam/connect/routes/connect-webviews.js.map +1 -0
- package/lib/seam/connect/routes/connected-accounts.d.ts +21 -0
- package/lib/seam/connect/routes/connected-accounts.js +70 -0
- package/lib/seam/connect/routes/connected-accounts.js.map +1 -0
- package/lib/seam/connect/routes/devices-unmanaged.d.ts +21 -0
- package/lib/seam/connect/routes/devices-unmanaged.js +70 -0
- package/lib/seam/connect/routes/devices-unmanaged.js.map +1 -0
- package/lib/seam/connect/routes/devices.d.ts +29 -0
- package/lib/seam/connect/routes/devices.js +89 -0
- package/lib/seam/connect/routes/devices.js.map +1 -0
- package/lib/seam/connect/routes/events.d.ts +18 -0
- package/lib/seam/connect/routes/events.js +63 -0
- package/lib/seam/connect/routes/events.js.map +1 -0
- package/lib/seam/connect/routes/index.d.ts +21 -0
- package/lib/seam/connect/routes/index.js +22 -0
- package/lib/seam/connect/routes/index.js.map +1 -0
- package/lib/seam/connect/routes/locks.d.ts +24 -0
- package/lib/seam/connect/routes/locks.js +79 -0
- package/lib/seam/connect/routes/locks.js.map +1 -0
- package/lib/seam/connect/routes/noise-sensors-noise-thresholds.d.ts +27 -0
- package/lib/seam/connect/routes/noise-sensors-noise-thresholds.js +84 -0
- package/lib/seam/connect/routes/noise-sensors-noise-thresholds.js.map +1 -0
- package/lib/seam/connect/routes/noise-sensors.d.ts +12 -0
- package/lib/seam/connect/routes/noise-sensors.js +51 -0
- package/lib/seam/connect/routes/noise-sensors.js.map +1 -0
- package/lib/seam/connect/routes/thermostats-climate-setting-schedules.d.ts +27 -0
- package/lib/seam/connect/routes/thermostats-climate-setting-schedules.js +85 -0
- package/lib/seam/connect/routes/thermostats-climate-setting-schedules.js.map +1 -0
- package/lib/seam/connect/routes/thermostats.d.ts +38 -0
- package/lib/seam/connect/routes/thermostats.js +109 -0
- package/lib/seam/connect/routes/thermostats.js.map +1 -0
- package/lib/seam/connect/routes/webhooks.d.ts +24 -0
- package/lib/seam/connect/routes/webhooks.js +78 -0
- package/lib/seam/connect/routes/webhooks.js.map +1 -0
- package/lib/seam/connect/routes/workspaces.d.ts +17 -7
- package/lib/seam/connect/routes/workspaces.js +61 -11
- package/lib/seam/connect/routes/workspaces.js.map +1 -1
- package/lib/seam/connect/seam-http.d.ts +24 -0
- package/lib/seam/connect/seam-http.js +82 -0
- package/lib/seam/connect/seam-http.js.map +1 -0
- package/package.json +9 -3
- package/src/lib/params-serializer.ts +55 -0
- package/src/lib/seam/connect/auth.ts +101 -13
- package/src/lib/seam/connect/client.ts +30 -62
- package/src/lib/seam/connect/env.d.ts +11 -0
- package/src/lib/seam/connect/index.ts +2 -1
- package/src/lib/seam/connect/{client-options.ts → options.ts} +37 -15
- package/src/lib/seam/connect/parse-options.ts +55 -14
- package/src/lib/seam/connect/routes/access-codes-unmanaged.ts +170 -0
- package/src/lib/seam/connect/routes/access-codes.ts +226 -0
- package/src/lib/seam/connect/routes/acs-access-groups.ts +216 -0
- package/src/lib/seam/connect/routes/acs-credentials.ts +151 -0
- package/src/lib/seam/connect/routes/acs-systems.ts +118 -0
- package/src/lib/seam/connect/routes/acs-users.ts +221 -0
- package/src/lib/seam/connect/routes/acs.ts +101 -0
- package/src/lib/seam/connect/routes/action-attempts.ts +118 -0
- package/src/lib/seam/connect/routes/client-sessions.ts +187 -0
- package/src/lib/seam/connect/routes/connect-webviews.ts +170 -0
- package/src/lib/seam/connect/routes/connected-accounts.ts +139 -0
- package/src/lib/seam/connect/routes/devices-unmanaged.ts +134 -0
- package/src/lib/seam/connect/routes/devices.ts +166 -0
- package/src/lib/seam/connect/routes/events.ts +114 -0
- package/src/lib/seam/connect/routes/index.ts +21 -0
- package/src/lib/seam/connect/routes/locks.ts +148 -0
- package/src/lib/seam/connect/routes/noise-sensors-noise-thresholds.ts +170 -0
- package/src/lib/seam/connect/routes/noise-sensors.ts +86 -0
- package/src/lib/seam/connect/routes/thermostats-climate-setting-schedules.ts +192 -0
- package/src/lib/seam/connect/routes/thermostats.ts +208 -0
- package/src/lib/seam/connect/routes/webhooks.ts +151 -0
- package/src/lib/seam/connect/routes/workspaces.ts +118 -22
- package/src/lib/seam/connect/seam-http.ts +141 -0
- package/lib/seam/connect/axios.d.ts +0 -3
- package/lib/seam/connect/axios.js +0 -17
- package/lib/seam/connect/axios.js.map +0 -1
- package/lib/seam/connect/client-options.d.ts +0 -19
- package/lib/seam/connect/client-options.js +0 -29
- package/lib/seam/connect/client-options.js.map +0 -1
- package/lib/seam/connect/legacy/workspaces.d.ts +0 -8
- package/lib/seam/connect/legacy/workspaces.js +0 -10
- package/lib/seam/connect/legacy/workspaces.js.map +0 -1
- package/src/lib/seam/connect/axios.ts +0 -23
- package/src/lib/seam/connect/legacy/workspaces.ts +0 -26
|
@@ -0,0 +1,134 @@
|
|
|
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 { warnOnInsecureuserIdentifierKey } from 'lib/seam/connect/auth.js'
|
|
10
|
+
import { type Client, createClient } from 'lib/seam/connect/client.js'
|
|
11
|
+
import {
|
|
12
|
+
isSeamHttpOptionsWithApiKey,
|
|
13
|
+
isSeamHttpOptionsWithClient,
|
|
14
|
+
isSeamHttpOptionsWithClientSessionToken,
|
|
15
|
+
type SeamHttpFromPublishableKeyOptions,
|
|
16
|
+
SeamHttpInvalidOptionsError,
|
|
17
|
+
type SeamHttpOptions,
|
|
18
|
+
type SeamHttpOptionsWithApiKey,
|
|
19
|
+
type SeamHttpOptionsWithClient,
|
|
20
|
+
type SeamHttpOptionsWithClientSessionToken,
|
|
21
|
+
} from 'lib/seam/connect/options.js'
|
|
22
|
+
import { parseOptions } from 'lib/seam/connect/parse-options.js'
|
|
23
|
+
|
|
24
|
+
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
25
|
+
|
|
26
|
+
export class SeamHttpDevicesUnmanaged {
|
|
27
|
+
client: Client
|
|
28
|
+
|
|
29
|
+
constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
|
|
30
|
+
const clientOptions = parseOptions(apiKeyOrOptions)
|
|
31
|
+
this.client = createClient(clientOptions)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static fromClient(
|
|
35
|
+
client: SeamHttpOptionsWithClient['client'],
|
|
36
|
+
options: Omit<SeamHttpOptionsWithClient, 'client'> = {},
|
|
37
|
+
): SeamHttpDevicesUnmanaged {
|
|
38
|
+
const constructorOptions = { ...options, client }
|
|
39
|
+
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
40
|
+
throw new SeamHttpInvalidOptionsError('Missing client')
|
|
41
|
+
}
|
|
42
|
+
return new SeamHttpDevicesUnmanaged(constructorOptions)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static fromApiKey(
|
|
46
|
+
apiKey: SeamHttpOptionsWithApiKey['apiKey'],
|
|
47
|
+
options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
|
|
48
|
+
): SeamHttpDevicesUnmanaged {
|
|
49
|
+
const constructorOptions = { ...options, apiKey }
|
|
50
|
+
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
51
|
+
throw new SeamHttpInvalidOptionsError('Missing apiKey')
|
|
52
|
+
}
|
|
53
|
+
return new SeamHttpDevicesUnmanaged(constructorOptions)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
static fromClientSessionToken(
|
|
57
|
+
clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
|
|
58
|
+
options: Omit<
|
|
59
|
+
SeamHttpOptionsWithClientSessionToken,
|
|
60
|
+
'clientSessionToken'
|
|
61
|
+
> = {},
|
|
62
|
+
): SeamHttpDevicesUnmanaged {
|
|
63
|
+
const constructorOptions = { ...options, clientSessionToken }
|
|
64
|
+
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
65
|
+
throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
|
|
66
|
+
}
|
|
67
|
+
return new SeamHttpDevicesUnmanaged(constructorOptions)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
static async fromPublishableKey(
|
|
71
|
+
publishableKey: string,
|
|
72
|
+
userIdentifierKey: string,
|
|
73
|
+
options: SeamHttpFromPublishableKeyOptions = {},
|
|
74
|
+
): Promise<SeamHttpDevicesUnmanaged> {
|
|
75
|
+
warnOnInsecureuserIdentifierKey(userIdentifierKey)
|
|
76
|
+
const clientOptions = parseOptions({ ...options, publishableKey })
|
|
77
|
+
const client = createClient(clientOptions)
|
|
78
|
+
const clientSessions = SeamHttpClientSessions.fromClient(client)
|
|
79
|
+
const { token } = await clientSessions.getOrCreate({
|
|
80
|
+
user_identifier_key: userIdentifierKey,
|
|
81
|
+
})
|
|
82
|
+
return SeamHttpDevicesUnmanaged.fromClientSessionToken(token, options)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async get(
|
|
86
|
+
body: DevicesUnmanagedGetBody,
|
|
87
|
+
): Promise<DevicesUnmanagedGetResponse['device']> {
|
|
88
|
+
const { data } = await this.client.request<DevicesUnmanagedGetResponse>({
|
|
89
|
+
url: '/devices/unmanaged/get',
|
|
90
|
+
method: 'post',
|
|
91
|
+
data: body,
|
|
92
|
+
})
|
|
93
|
+
return data.device
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
async list(
|
|
97
|
+
body: DevicesUnmanagedListBody,
|
|
98
|
+
): Promise<DevicesUnmanagedListResponse['devices']> {
|
|
99
|
+
const { data } = await this.client.request<DevicesUnmanagedListResponse>({
|
|
100
|
+
url: '/devices/unmanaged/list',
|
|
101
|
+
method: 'post',
|
|
102
|
+
data: body,
|
|
103
|
+
})
|
|
104
|
+
return data.devices
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async update(body: DevicesUnmanagedUpdateBody): Promise<void> {
|
|
108
|
+
await this.client.request<DevicesUnmanagedUpdateResponse>({
|
|
109
|
+
url: '/devices/unmanaged/update',
|
|
110
|
+
method: 'post',
|
|
111
|
+
data: body,
|
|
112
|
+
})
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export type DevicesUnmanagedGetBody = RouteRequestBody<'/devices/unmanaged/get'>
|
|
117
|
+
|
|
118
|
+
export type DevicesUnmanagedGetResponse = SetNonNullable<
|
|
119
|
+
Required<RouteResponse<'/devices/unmanaged/get'>>
|
|
120
|
+
>
|
|
121
|
+
|
|
122
|
+
export type DevicesUnmanagedListBody =
|
|
123
|
+
RouteRequestBody<'/devices/unmanaged/list'>
|
|
124
|
+
|
|
125
|
+
export type DevicesUnmanagedListResponse = SetNonNullable<
|
|
126
|
+
Required<RouteResponse<'/devices/unmanaged/list'>>
|
|
127
|
+
>
|
|
128
|
+
|
|
129
|
+
export type DevicesUnmanagedUpdateBody =
|
|
130
|
+
RouteRequestBody<'/devices/unmanaged/update'>
|
|
131
|
+
|
|
132
|
+
export type DevicesUnmanagedUpdateResponse = SetNonNullable<
|
|
133
|
+
Required<RouteResponse<'/devices/unmanaged/update'>>
|
|
134
|
+
>
|
|
@@ -0,0 +1,166 @@
|
|
|
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 { warnOnInsecureuserIdentifierKey } from 'lib/seam/connect/auth.js'
|
|
10
|
+
import { type Client, createClient } from 'lib/seam/connect/client.js'
|
|
11
|
+
import {
|
|
12
|
+
isSeamHttpOptionsWithApiKey,
|
|
13
|
+
isSeamHttpOptionsWithClient,
|
|
14
|
+
isSeamHttpOptionsWithClientSessionToken,
|
|
15
|
+
type SeamHttpFromPublishableKeyOptions,
|
|
16
|
+
SeamHttpInvalidOptionsError,
|
|
17
|
+
type SeamHttpOptions,
|
|
18
|
+
type SeamHttpOptionsWithApiKey,
|
|
19
|
+
type SeamHttpOptionsWithClient,
|
|
20
|
+
type SeamHttpOptionsWithClientSessionToken,
|
|
21
|
+
} from 'lib/seam/connect/options.js'
|
|
22
|
+
import { parseOptions } from 'lib/seam/connect/parse-options.js'
|
|
23
|
+
|
|
24
|
+
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
25
|
+
import { SeamHttpDevicesUnmanaged } from './devices-unmanaged.js'
|
|
26
|
+
|
|
27
|
+
export class SeamHttpDevices {
|
|
28
|
+
client: Client
|
|
29
|
+
|
|
30
|
+
constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
|
|
31
|
+
const clientOptions = parseOptions(apiKeyOrOptions)
|
|
32
|
+
this.client = createClient(clientOptions)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
static fromClient(
|
|
36
|
+
client: SeamHttpOptionsWithClient['client'],
|
|
37
|
+
options: Omit<SeamHttpOptionsWithClient, 'client'> = {},
|
|
38
|
+
): SeamHttpDevices {
|
|
39
|
+
const constructorOptions = { ...options, client }
|
|
40
|
+
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
41
|
+
throw new SeamHttpInvalidOptionsError('Missing client')
|
|
42
|
+
}
|
|
43
|
+
return new SeamHttpDevices(constructorOptions)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
static fromApiKey(
|
|
47
|
+
apiKey: SeamHttpOptionsWithApiKey['apiKey'],
|
|
48
|
+
options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
|
|
49
|
+
): SeamHttpDevices {
|
|
50
|
+
const constructorOptions = { ...options, apiKey }
|
|
51
|
+
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
52
|
+
throw new SeamHttpInvalidOptionsError('Missing apiKey')
|
|
53
|
+
}
|
|
54
|
+
return new SeamHttpDevices(constructorOptions)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static fromClientSessionToken(
|
|
58
|
+
clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
|
|
59
|
+
options: Omit<
|
|
60
|
+
SeamHttpOptionsWithClientSessionToken,
|
|
61
|
+
'clientSessionToken'
|
|
62
|
+
> = {},
|
|
63
|
+
): SeamHttpDevices {
|
|
64
|
+
const constructorOptions = { ...options, clientSessionToken }
|
|
65
|
+
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
66
|
+
throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
|
|
67
|
+
}
|
|
68
|
+
return new SeamHttpDevices(constructorOptions)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
static async fromPublishableKey(
|
|
72
|
+
publishableKey: string,
|
|
73
|
+
userIdentifierKey: string,
|
|
74
|
+
options: SeamHttpFromPublishableKeyOptions = {},
|
|
75
|
+
): Promise<SeamHttpDevices> {
|
|
76
|
+
warnOnInsecureuserIdentifierKey(userIdentifierKey)
|
|
77
|
+
const clientOptions = parseOptions({ ...options, publishableKey })
|
|
78
|
+
const client = createClient(clientOptions)
|
|
79
|
+
const clientSessions = SeamHttpClientSessions.fromClient(client)
|
|
80
|
+
const { token } = await clientSessions.getOrCreate({
|
|
81
|
+
user_identifier_key: userIdentifierKey,
|
|
82
|
+
})
|
|
83
|
+
return SeamHttpDevices.fromClientSessionToken(token, options)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
get unmanaged(): SeamHttpDevicesUnmanaged {
|
|
87
|
+
return SeamHttpDevicesUnmanaged.fromClient(this.client)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
async delete(body: DevicesDeleteBody): Promise<void> {
|
|
91
|
+
await this.client.request<DevicesDeleteResponse>({
|
|
92
|
+
url: '/devices/delete',
|
|
93
|
+
method: 'post',
|
|
94
|
+
data: body,
|
|
95
|
+
})
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async get(body: DevicesGetBody): Promise<DevicesGetResponse['device']> {
|
|
99
|
+
const { data } = await this.client.request<DevicesGetResponse>({
|
|
100
|
+
url: '/devices/get',
|
|
101
|
+
method: 'post',
|
|
102
|
+
data: body,
|
|
103
|
+
})
|
|
104
|
+
return data.device
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
async list(body: DevicesListBody): Promise<DevicesListResponse['devices']> {
|
|
108
|
+
const { data } = await this.client.request<DevicesListResponse>({
|
|
109
|
+
url: '/devices/list',
|
|
110
|
+
method: 'post',
|
|
111
|
+
data: body,
|
|
112
|
+
})
|
|
113
|
+
return data.devices
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
async listDeviceProviders(
|
|
117
|
+
body: DevicesListDeviceProvidersBody,
|
|
118
|
+
): Promise<DevicesListDeviceProvidersResponse['device_providers']> {
|
|
119
|
+
const { data } =
|
|
120
|
+
await this.client.request<DevicesListDeviceProvidersResponse>({
|
|
121
|
+
url: '/devices/list_device_providers',
|
|
122
|
+
method: 'post',
|
|
123
|
+
data: body,
|
|
124
|
+
})
|
|
125
|
+
return data.device_providers
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
async update(body: DevicesUpdateBody): Promise<void> {
|
|
129
|
+
await this.client.request<DevicesUpdateResponse>({
|
|
130
|
+
url: '/devices/update',
|
|
131
|
+
method: 'post',
|
|
132
|
+
data: body,
|
|
133
|
+
})
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export type DevicesDeleteBody = RouteRequestBody<'/devices/delete'>
|
|
138
|
+
|
|
139
|
+
export type DevicesDeleteResponse = SetNonNullable<
|
|
140
|
+
Required<RouteResponse<'/devices/delete'>>
|
|
141
|
+
>
|
|
142
|
+
|
|
143
|
+
export type DevicesGetBody = RouteRequestBody<'/devices/get'>
|
|
144
|
+
|
|
145
|
+
export type DevicesGetResponse = SetNonNullable<
|
|
146
|
+
Required<RouteResponse<'/devices/get'>>
|
|
147
|
+
>
|
|
148
|
+
|
|
149
|
+
export type DevicesListBody = RouteRequestBody<'/devices/list'>
|
|
150
|
+
|
|
151
|
+
export type DevicesListResponse = SetNonNullable<
|
|
152
|
+
Required<RouteResponse<'/devices/list'>>
|
|
153
|
+
>
|
|
154
|
+
|
|
155
|
+
export type DevicesListDeviceProvidersBody =
|
|
156
|
+
RouteRequestBody<'/devices/list_device_providers'>
|
|
157
|
+
|
|
158
|
+
export type DevicesListDeviceProvidersResponse = SetNonNullable<
|
|
159
|
+
Required<RouteResponse<'/devices/list_device_providers'>>
|
|
160
|
+
>
|
|
161
|
+
|
|
162
|
+
export type DevicesUpdateBody = RouteRequestBody<'/devices/update'>
|
|
163
|
+
|
|
164
|
+
export type DevicesUpdateResponse = SetNonNullable<
|
|
165
|
+
Required<RouteResponse<'/devices/update'>>
|
|
166
|
+
>
|
|
@@ -0,0 +1,114 @@
|
|
|
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 { warnOnInsecureuserIdentifierKey } from 'lib/seam/connect/auth.js'
|
|
10
|
+
import { type Client, createClient } from 'lib/seam/connect/client.js'
|
|
11
|
+
import {
|
|
12
|
+
isSeamHttpOptionsWithApiKey,
|
|
13
|
+
isSeamHttpOptionsWithClient,
|
|
14
|
+
isSeamHttpOptionsWithClientSessionToken,
|
|
15
|
+
type SeamHttpFromPublishableKeyOptions,
|
|
16
|
+
SeamHttpInvalidOptionsError,
|
|
17
|
+
type SeamHttpOptions,
|
|
18
|
+
type SeamHttpOptionsWithApiKey,
|
|
19
|
+
type SeamHttpOptionsWithClient,
|
|
20
|
+
type SeamHttpOptionsWithClientSessionToken,
|
|
21
|
+
} from 'lib/seam/connect/options.js'
|
|
22
|
+
import { parseOptions } from 'lib/seam/connect/parse-options.js'
|
|
23
|
+
|
|
24
|
+
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
25
|
+
|
|
26
|
+
export class SeamHttpEvents {
|
|
27
|
+
client: Client
|
|
28
|
+
|
|
29
|
+
constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
|
|
30
|
+
const clientOptions = parseOptions(apiKeyOrOptions)
|
|
31
|
+
this.client = createClient(clientOptions)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static fromClient(
|
|
35
|
+
client: SeamHttpOptionsWithClient['client'],
|
|
36
|
+
options: Omit<SeamHttpOptionsWithClient, 'client'> = {},
|
|
37
|
+
): SeamHttpEvents {
|
|
38
|
+
const constructorOptions = { ...options, client }
|
|
39
|
+
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
40
|
+
throw new SeamHttpInvalidOptionsError('Missing client')
|
|
41
|
+
}
|
|
42
|
+
return new SeamHttpEvents(constructorOptions)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static fromApiKey(
|
|
46
|
+
apiKey: SeamHttpOptionsWithApiKey['apiKey'],
|
|
47
|
+
options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
|
|
48
|
+
): SeamHttpEvents {
|
|
49
|
+
const constructorOptions = { ...options, apiKey }
|
|
50
|
+
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
51
|
+
throw new SeamHttpInvalidOptionsError('Missing apiKey')
|
|
52
|
+
}
|
|
53
|
+
return new SeamHttpEvents(constructorOptions)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
static fromClientSessionToken(
|
|
57
|
+
clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
|
|
58
|
+
options: Omit<
|
|
59
|
+
SeamHttpOptionsWithClientSessionToken,
|
|
60
|
+
'clientSessionToken'
|
|
61
|
+
> = {},
|
|
62
|
+
): SeamHttpEvents {
|
|
63
|
+
const constructorOptions = { ...options, clientSessionToken }
|
|
64
|
+
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
65
|
+
throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
|
|
66
|
+
}
|
|
67
|
+
return new SeamHttpEvents(constructorOptions)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
static async fromPublishableKey(
|
|
71
|
+
publishableKey: string,
|
|
72
|
+
userIdentifierKey: string,
|
|
73
|
+
options: SeamHttpFromPublishableKeyOptions = {},
|
|
74
|
+
): Promise<SeamHttpEvents> {
|
|
75
|
+
warnOnInsecureuserIdentifierKey(userIdentifierKey)
|
|
76
|
+
const clientOptions = parseOptions({ ...options, publishableKey })
|
|
77
|
+
const client = createClient(clientOptions)
|
|
78
|
+
const clientSessions = SeamHttpClientSessions.fromClient(client)
|
|
79
|
+
const { token } = await clientSessions.getOrCreate({
|
|
80
|
+
user_identifier_key: userIdentifierKey,
|
|
81
|
+
})
|
|
82
|
+
return SeamHttpEvents.fromClientSessionToken(token, options)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async get(body: EventsGetBody): Promise<EventsGetResponse['event']> {
|
|
86
|
+
const { data } = await this.client.request<EventsGetResponse>({
|
|
87
|
+
url: '/events/get',
|
|
88
|
+
method: 'post',
|
|
89
|
+
data: body,
|
|
90
|
+
})
|
|
91
|
+
return data.event
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async list(body: EventsListBody): Promise<EventsListResponse['events']> {
|
|
95
|
+
const { data } = await this.client.request<EventsListResponse>({
|
|
96
|
+
url: '/events/list',
|
|
97
|
+
method: 'post',
|
|
98
|
+
data: body,
|
|
99
|
+
})
|
|
100
|
+
return data.events
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export type EventsGetBody = RouteRequestBody<'/events/get'>
|
|
105
|
+
|
|
106
|
+
export type EventsGetResponse = SetNonNullable<
|
|
107
|
+
Required<RouteResponse<'/events/get'>>
|
|
108
|
+
>
|
|
109
|
+
|
|
110
|
+
export type EventsListBody = RouteRequestBody<'/events/list'>
|
|
111
|
+
|
|
112
|
+
export type EventsListResponse = SetNonNullable<
|
|
113
|
+
Required<RouteResponse<'/events/list'>>
|
|
114
|
+
>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export * from './access-codes.js'
|
|
2
|
+
export * from './access-codes-unmanaged.js'
|
|
3
|
+
export * from './acs.js'
|
|
4
|
+
export * from './acs-access-groups.js'
|
|
5
|
+
export * from './acs-credentials.js'
|
|
6
|
+
export * from './acs-systems.js'
|
|
7
|
+
export * from './acs-users.js'
|
|
8
|
+
export * from './action-attempts.js'
|
|
9
|
+
export * from './client-sessions.js'
|
|
10
|
+
export * from './connect-webviews.js'
|
|
11
|
+
export * from './connected-accounts.js'
|
|
12
|
+
export * from './devices.js'
|
|
13
|
+
export * from './devices-unmanaged.js'
|
|
14
|
+
export * from './events.js'
|
|
15
|
+
export * from './locks.js'
|
|
16
|
+
export * from './noise-sensors.js'
|
|
17
|
+
export * from './noise-sensors-noise-thresholds.js'
|
|
18
|
+
export * from './thermostats.js'
|
|
19
|
+
export * from './thermostats-climate-setting-schedules.js'
|
|
20
|
+
export * from './webhooks.js'
|
|
21
|
+
export * from './workspaces.js'
|
|
@@ -0,0 +1,148 @@
|
|
|
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 { warnOnInsecureuserIdentifierKey } from 'lib/seam/connect/auth.js'
|
|
10
|
+
import { type Client, createClient } from 'lib/seam/connect/client.js'
|
|
11
|
+
import {
|
|
12
|
+
isSeamHttpOptionsWithApiKey,
|
|
13
|
+
isSeamHttpOptionsWithClient,
|
|
14
|
+
isSeamHttpOptionsWithClientSessionToken,
|
|
15
|
+
type SeamHttpFromPublishableKeyOptions,
|
|
16
|
+
SeamHttpInvalidOptionsError,
|
|
17
|
+
type SeamHttpOptions,
|
|
18
|
+
type SeamHttpOptionsWithApiKey,
|
|
19
|
+
type SeamHttpOptionsWithClient,
|
|
20
|
+
type SeamHttpOptionsWithClientSessionToken,
|
|
21
|
+
} from 'lib/seam/connect/options.js'
|
|
22
|
+
import { parseOptions } from 'lib/seam/connect/parse-options.js'
|
|
23
|
+
|
|
24
|
+
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
25
|
+
|
|
26
|
+
export class SeamHttpLocks {
|
|
27
|
+
client: Client
|
|
28
|
+
|
|
29
|
+
constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
|
|
30
|
+
const clientOptions = parseOptions(apiKeyOrOptions)
|
|
31
|
+
this.client = createClient(clientOptions)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static fromClient(
|
|
35
|
+
client: SeamHttpOptionsWithClient['client'],
|
|
36
|
+
options: Omit<SeamHttpOptionsWithClient, 'client'> = {},
|
|
37
|
+
): SeamHttpLocks {
|
|
38
|
+
const constructorOptions = { ...options, client }
|
|
39
|
+
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
40
|
+
throw new SeamHttpInvalidOptionsError('Missing client')
|
|
41
|
+
}
|
|
42
|
+
return new SeamHttpLocks(constructorOptions)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static fromApiKey(
|
|
46
|
+
apiKey: SeamHttpOptionsWithApiKey['apiKey'],
|
|
47
|
+
options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
|
|
48
|
+
): SeamHttpLocks {
|
|
49
|
+
const constructorOptions = { ...options, apiKey }
|
|
50
|
+
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
51
|
+
throw new SeamHttpInvalidOptionsError('Missing apiKey')
|
|
52
|
+
}
|
|
53
|
+
return new SeamHttpLocks(constructorOptions)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
static fromClientSessionToken(
|
|
57
|
+
clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
|
|
58
|
+
options: Omit<
|
|
59
|
+
SeamHttpOptionsWithClientSessionToken,
|
|
60
|
+
'clientSessionToken'
|
|
61
|
+
> = {},
|
|
62
|
+
): SeamHttpLocks {
|
|
63
|
+
const constructorOptions = { ...options, clientSessionToken }
|
|
64
|
+
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
65
|
+
throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
|
|
66
|
+
}
|
|
67
|
+
return new SeamHttpLocks(constructorOptions)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
static async fromPublishableKey(
|
|
71
|
+
publishableKey: string,
|
|
72
|
+
userIdentifierKey: string,
|
|
73
|
+
options: SeamHttpFromPublishableKeyOptions = {},
|
|
74
|
+
): Promise<SeamHttpLocks> {
|
|
75
|
+
warnOnInsecureuserIdentifierKey(userIdentifierKey)
|
|
76
|
+
const clientOptions = parseOptions({ ...options, publishableKey })
|
|
77
|
+
const client = createClient(clientOptions)
|
|
78
|
+
const clientSessions = SeamHttpClientSessions.fromClient(client)
|
|
79
|
+
const { token } = await clientSessions.getOrCreate({
|
|
80
|
+
user_identifier_key: userIdentifierKey,
|
|
81
|
+
})
|
|
82
|
+
return SeamHttpLocks.fromClientSessionToken(token, options)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async get(body: LocksGetBody): Promise<LocksGetResponse['device']> {
|
|
86
|
+
const { data } = await this.client.request<LocksGetResponse>({
|
|
87
|
+
url: '/locks/get',
|
|
88
|
+
method: 'post',
|
|
89
|
+
data: body,
|
|
90
|
+
})
|
|
91
|
+
return data.device
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async list(body: LocksListBody): Promise<LocksListResponse['devices']> {
|
|
95
|
+
const { data } = await this.client.request<LocksListResponse>({
|
|
96
|
+
url: '/locks/list',
|
|
97
|
+
method: 'post',
|
|
98
|
+
data: body,
|
|
99
|
+
})
|
|
100
|
+
return data.devices
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
async lockDoor(
|
|
104
|
+
body: LocksLockDoorBody,
|
|
105
|
+
): Promise<LocksLockDoorResponse['action_attempt']> {
|
|
106
|
+
const { data } = await this.client.request<LocksLockDoorResponse>({
|
|
107
|
+
url: '/locks/lock_door',
|
|
108
|
+
method: 'post',
|
|
109
|
+
data: body,
|
|
110
|
+
})
|
|
111
|
+
return data.action_attempt
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
async unlockDoor(
|
|
115
|
+
body: LocksUnlockDoorBody,
|
|
116
|
+
): Promise<LocksUnlockDoorResponse['action_attempt']> {
|
|
117
|
+
const { data } = await this.client.request<LocksUnlockDoorResponse>({
|
|
118
|
+
url: '/locks/unlock_door',
|
|
119
|
+
method: 'post',
|
|
120
|
+
data: body,
|
|
121
|
+
})
|
|
122
|
+
return data.action_attempt
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export type LocksGetBody = RouteRequestBody<'/locks/get'>
|
|
127
|
+
|
|
128
|
+
export type LocksGetResponse = SetNonNullable<
|
|
129
|
+
Required<RouteResponse<'/locks/get'>>
|
|
130
|
+
>
|
|
131
|
+
|
|
132
|
+
export type LocksListBody = RouteRequestBody<'/locks/list'>
|
|
133
|
+
|
|
134
|
+
export type LocksListResponse = SetNonNullable<
|
|
135
|
+
Required<RouteResponse<'/locks/list'>>
|
|
136
|
+
>
|
|
137
|
+
|
|
138
|
+
export type LocksLockDoorBody = RouteRequestBody<'/locks/lock_door'>
|
|
139
|
+
|
|
140
|
+
export type LocksLockDoorResponse = SetNonNullable<
|
|
141
|
+
Required<RouteResponse<'/locks/lock_door'>>
|
|
142
|
+
>
|
|
143
|
+
|
|
144
|
+
export type LocksUnlockDoorBody = RouteRequestBody<'/locks/unlock_door'>
|
|
145
|
+
|
|
146
|
+
export type LocksUnlockDoorResponse = SetNonNullable<
|
|
147
|
+
Required<RouteResponse<'/locks/unlock_door'>>
|
|
148
|
+
>
|