@seamapi/http 1.33.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 +386 -0
- package/dist/connect.cjs.map +1 -1
- package/dist/connect.d.cts +110 -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/access-methods.d.ts +31 -0
- package/lib/seam/connect/routes/access-methods.js +108 -0
- package/lib/seam/connect/routes/access-methods.js.map +1 -0
- package/lib/seam/connect/routes/index.d.ts +3 -0
- package/lib/seam/connect/routes/index.js +3 -0
- 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/seam-http.d.ts +4 -1
- package/lib/seam/connect/seam-http.js +10 -1
- 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 +3 -3
- package/src/lib/seam/connect/routes/access-grants.ts +237 -0
- package/src/lib/seam/connect/routes/access-methods.ts +219 -0
- package/src/lib/seam/connect/routes/index.ts +3 -0
- package/src/lib/seam/connect/routes/spaces.ts +329 -0
- package/src/lib/seam/connect/seam-http.ts +15 -0
- package/src/lib/version.ts +1 -1
|
@@ -0,0 +1,219 @@
|
|
|
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 SeamHttpAccessMethods {
|
|
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
|
+
): SeamHttpAccessMethods {
|
|
53
|
+
const constructorOptions = { ...options, client }
|
|
54
|
+
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
55
|
+
throw new SeamHttpInvalidOptionsError('Missing client')
|
|
56
|
+
}
|
|
57
|
+
return new SeamHttpAccessMethods(constructorOptions)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
static fromApiKey(
|
|
61
|
+
apiKey: SeamHttpOptionsWithApiKey['apiKey'],
|
|
62
|
+
options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
|
|
63
|
+
): SeamHttpAccessMethods {
|
|
64
|
+
const constructorOptions = { ...options, apiKey }
|
|
65
|
+
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
66
|
+
throw new SeamHttpInvalidOptionsError('Missing apiKey')
|
|
67
|
+
}
|
|
68
|
+
return new SeamHttpAccessMethods(constructorOptions)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
static fromClientSessionToken(
|
|
72
|
+
clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
|
|
73
|
+
options: Omit<
|
|
74
|
+
SeamHttpOptionsWithClientSessionToken,
|
|
75
|
+
'clientSessionToken'
|
|
76
|
+
> = {},
|
|
77
|
+
): SeamHttpAccessMethods {
|
|
78
|
+
const constructorOptions = { ...options, clientSessionToken }
|
|
79
|
+
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
80
|
+
throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
|
|
81
|
+
}
|
|
82
|
+
return new SeamHttpAccessMethods(constructorOptions)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
static async fromPublishableKey(
|
|
86
|
+
publishableKey: string,
|
|
87
|
+
userIdentifierKey: string,
|
|
88
|
+
options: SeamHttpFromPublishableKeyOptions = {},
|
|
89
|
+
): Promise<SeamHttpAccessMethods> {
|
|
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 SeamHttpAccessMethods.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
|
+
): SeamHttpAccessMethods {
|
|
113
|
+
const constructorOptions = { ...options, consoleSessionToken, workspaceId }
|
|
114
|
+
if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) {
|
|
115
|
+
throw new SeamHttpInvalidOptionsError(
|
|
116
|
+
'Missing consoleSessionToken or workspaceId',
|
|
117
|
+
)
|
|
118
|
+
}
|
|
119
|
+
return new SeamHttpAccessMethods(constructorOptions)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
static fromPersonalAccessToken(
|
|
123
|
+
personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'],
|
|
124
|
+
workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'],
|
|
125
|
+
options: Omit<
|
|
126
|
+
SeamHttpOptionsWithPersonalAccessToken,
|
|
127
|
+
'personalAccessToken' | 'workspaceId'
|
|
128
|
+
> = {},
|
|
129
|
+
): SeamHttpAccessMethods {
|
|
130
|
+
const constructorOptions = { ...options, personalAccessToken, workspaceId }
|
|
131
|
+
if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) {
|
|
132
|
+
throw new SeamHttpInvalidOptionsError(
|
|
133
|
+
'Missing personalAccessToken or workspaceId',
|
|
134
|
+
)
|
|
135
|
+
}
|
|
136
|
+
return new SeamHttpAccessMethods(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
|
+
delete(body?: AccessMethodsDeleteParams): SeamHttpRequest<void, undefined> {
|
|
165
|
+
return new SeamHttpRequest(this, {
|
|
166
|
+
pathname: '/access_methods/delete',
|
|
167
|
+
method: 'post',
|
|
168
|
+
body,
|
|
169
|
+
responseKey: undefined,
|
|
170
|
+
})
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
get(
|
|
174
|
+
body?: AccessMethodsGetParams,
|
|
175
|
+
): SeamHttpRequest<AccessMethodsGetResponse, 'access_method'> {
|
|
176
|
+
return new SeamHttpRequest(this, {
|
|
177
|
+
pathname: '/access_methods/get',
|
|
178
|
+
method: 'post',
|
|
179
|
+
body,
|
|
180
|
+
responseKey: 'access_method',
|
|
181
|
+
})
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
list(
|
|
185
|
+
body?: AccessMethodsListParams,
|
|
186
|
+
): SeamHttpRequest<AccessMethodsListResponse, 'access_methods'> {
|
|
187
|
+
return new SeamHttpRequest(this, {
|
|
188
|
+
pathname: '/access_methods/list',
|
|
189
|
+
method: 'post',
|
|
190
|
+
body,
|
|
191
|
+
responseKey: 'access_methods',
|
|
192
|
+
})
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export type AccessMethodsDeleteParams =
|
|
197
|
+
RouteRequestBody<'/access_methods/delete'>
|
|
198
|
+
|
|
199
|
+
export type AccessMethodsDeleteResponse = SetNonNullable<
|
|
200
|
+
Required<RouteResponse<'/access_methods/delete'>>
|
|
201
|
+
>
|
|
202
|
+
|
|
203
|
+
export type AccessMethodsDeleteOptions = never
|
|
204
|
+
|
|
205
|
+
export type AccessMethodsGetParams = RouteRequestBody<'/access_methods/get'>
|
|
206
|
+
|
|
207
|
+
export type AccessMethodsGetResponse = SetNonNullable<
|
|
208
|
+
Required<RouteResponse<'/access_methods/get'>>
|
|
209
|
+
>
|
|
210
|
+
|
|
211
|
+
export type AccessMethodsGetOptions = never
|
|
212
|
+
|
|
213
|
+
export type AccessMethodsListParams = RouteRequestBody<'/access_methods/list'>
|
|
214
|
+
|
|
215
|
+
export type AccessMethodsListResponse = SetNonNullable<
|
|
216
|
+
Required<RouteResponse<'/access_methods/list'>>
|
|
217
|
+
>
|
|
218
|
+
|
|
219
|
+
export type AccessMethodsListOptions = never
|
|
@@ -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'
|
|
@@ -23,6 +25,7 @@ export * from './noise-sensors-noise-thresholds.js'
|
|
|
23
25
|
export * from './noise-sensors-simulate.js'
|
|
24
26
|
export * from './phones.js'
|
|
25
27
|
export * from './phones-simulate.js'
|
|
28
|
+
export * from './spaces.js'
|
|
26
29
|
export * from './thermostats.js'
|
|
27
30
|
export * from './thermostats-daily-programs.js'
|
|
28
31
|
export * from './thermostats-schedules.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
|
|
@@ -24,6 +24,8 @@ import {
|
|
|
24
24
|
import { limitToSeamHttpRequestOptions, parseOptions } from './parse-options.js'
|
|
25
25
|
import {
|
|
26
26
|
SeamHttpAccessCodes,
|
|
27
|
+
SeamHttpAccessGrants,
|
|
28
|
+
SeamHttpAccessMethods,
|
|
27
29
|
SeamHttpAcs,
|
|
28
30
|
SeamHttpActionAttempts,
|
|
29
31
|
SeamHttpClientSessions,
|
|
@@ -34,6 +36,7 @@ import {
|
|
|
34
36
|
SeamHttpLocks,
|
|
35
37
|
SeamHttpNoiseSensors,
|
|
36
38
|
SeamHttpPhones,
|
|
39
|
+
SeamHttpSpaces,
|
|
37
40
|
SeamHttpThermostats,
|
|
38
41
|
SeamHttpUserIdentities,
|
|
39
42
|
SeamHttpWebhooks,
|
|
@@ -173,6 +176,14 @@ export class SeamHttp {
|
|
|
173
176
|
return SeamHttpAccessCodes.fromClient(this.client, this.defaults)
|
|
174
177
|
}
|
|
175
178
|
|
|
179
|
+
get accessGrants(): SeamHttpAccessGrants {
|
|
180
|
+
return SeamHttpAccessGrants.fromClient(this.client, this.defaults)
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
get accessMethods(): SeamHttpAccessMethods {
|
|
184
|
+
return SeamHttpAccessMethods.fromClient(this.client, this.defaults)
|
|
185
|
+
}
|
|
186
|
+
|
|
176
187
|
get acs(): SeamHttpAcs {
|
|
177
188
|
return SeamHttpAcs.fromClient(this.client, this.defaults)
|
|
178
189
|
}
|
|
@@ -213,6 +224,10 @@ export class SeamHttp {
|
|
|
213
224
|
return SeamHttpPhones.fromClient(this.client, this.defaults)
|
|
214
225
|
}
|
|
215
226
|
|
|
227
|
+
get spaces(): SeamHttpSpaces {
|
|
228
|
+
return SeamHttpSpaces.fromClient(this.client, this.defaults)
|
|
229
|
+
}
|
|
230
|
+
|
|
216
231
|
get thermostats(): SeamHttpThermostats {
|
|
217
232
|
return SeamHttpThermostats.fromClient(this.client, this.defaults)
|
|
218
233
|
}
|
package/src/lib/version.ts
CHANGED