@seamapi/http 0.8.0 → 0.9.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 +14 -1
- package/dist/connect.cjs +314 -141
- package/dist/connect.cjs.map +1 -1
- package/dist/connect.d.cts +89 -75
- package/lib/seam/connect/client.d.ts +0 -1
- package/lib/seam/connect/client.js +0 -2
- package/lib/seam/connect/client.js.map +1 -1
- package/lib/seam/connect/options.d.ts +7 -3
- package/lib/seam/connect/options.js +2 -1
- package/lib/seam/connect/options.js.map +1 -1
- package/lib/seam/connect/parse-options.d.ts +9 -3
- package/lib/seam/connect/parse-options.js +25 -2
- package/lib/seam/connect/parse-options.js.map +1 -1
- package/lib/seam/connect/routes/access-codes-unmanaged.d.ts +2 -1
- package/lib/seam/connect/routes/access-codes-unmanaged.js +7 -3
- package/lib/seam/connect/routes/access-codes-unmanaged.js.map +1 -1
- package/lib/seam/connect/routes/access-codes.d.ts +2 -1
- package/lib/seam/connect/routes/access-codes.js +8 -4
- package/lib/seam/connect/routes/access-codes.js.map +1 -1
- package/lib/seam/connect/routes/acs-access-groups.d.ts +2 -1
- package/lib/seam/connect/routes/acs-access-groups.js +7 -3
- package/lib/seam/connect/routes/acs-access-groups.js.map +1 -1
- package/lib/seam/connect/routes/acs-credentials.d.ts +2 -1
- package/lib/seam/connect/routes/acs-credentials.js +7 -3
- package/lib/seam/connect/routes/acs-credentials.js.map +1 -1
- package/lib/seam/connect/routes/acs-systems.d.ts +2 -1
- package/lib/seam/connect/routes/acs-systems.js +7 -3
- package/lib/seam/connect/routes/acs-systems.js.map +1 -1
- package/lib/seam/connect/routes/acs-users.d.ts +2 -1
- package/lib/seam/connect/routes/acs-users.js +7 -3
- package/lib/seam/connect/routes/acs-users.js.map +1 -1
- package/lib/seam/connect/routes/acs.d.ts +2 -1
- package/lib/seam/connect/routes/acs.js +11 -7
- package/lib/seam/connect/routes/acs.js.map +1 -1
- package/lib/seam/connect/routes/action-attempts.d.ts +4 -8
- package/lib/seam/connect/routes/action-attempts.js +15 -7
- package/lib/seam/connect/routes/action-attempts.js.map +1 -1
- package/lib/seam/connect/routes/client-sessions.d.ts +2 -1
- package/lib/seam/connect/routes/client-sessions.js +7 -3
- package/lib/seam/connect/routes/client-sessions.js.map +1 -1
- package/lib/seam/connect/routes/connect-webviews.d.ts +2 -1
- package/lib/seam/connect/routes/connect-webviews.js +7 -3
- package/lib/seam/connect/routes/connect-webviews.js.map +1 -1
- package/lib/seam/connect/routes/connected-accounts.d.ts +2 -1
- package/lib/seam/connect/routes/connected-accounts.js +7 -3
- package/lib/seam/connect/routes/connected-accounts.js.map +1 -1
- package/lib/seam/connect/routes/devices-unmanaged.d.ts +2 -1
- package/lib/seam/connect/routes/devices-unmanaged.js +7 -3
- package/lib/seam/connect/routes/devices-unmanaged.js.map +1 -1
- package/lib/seam/connect/routes/devices.d.ts +2 -1
- package/lib/seam/connect/routes/devices.js +8 -4
- package/lib/seam/connect/routes/devices.js.map +1 -1
- package/lib/seam/connect/routes/events.d.ts +2 -1
- package/lib/seam/connect/routes/events.js +7 -3
- package/lib/seam/connect/routes/events.js.map +1 -1
- package/lib/seam/connect/routes/locks.d.ts +6 -14
- package/lib/seam/connect/routes/locks.js +22 -10
- package/lib/seam/connect/routes/locks.js.map +1 -1
- package/lib/seam/connect/routes/noise-sensors-noise-thresholds.d.ts +2 -1
- package/lib/seam/connect/routes/noise-sensors-noise-thresholds.js +7 -3
- package/lib/seam/connect/routes/noise-sensors-noise-thresholds.js.map +1 -1
- package/lib/seam/connect/routes/noise-sensors.d.ts +2 -1
- package/lib/seam/connect/routes/noise-sensors.js +8 -4
- package/lib/seam/connect/routes/noise-sensors.js.map +1 -1
- package/lib/seam/connect/routes/thermostats-climate-setting-schedules.d.ts +2 -1
- package/lib/seam/connect/routes/thermostats-climate-setting-schedules.js +7 -3
- package/lib/seam/connect/routes/thermostats-climate-setting-schedules.js.map +1 -1
- package/lib/seam/connect/routes/thermostats.d.ts +2 -1
- package/lib/seam/connect/routes/thermostats.js +8 -4
- package/lib/seam/connect/routes/thermostats.js.map +1 -1
- package/lib/seam/connect/routes/user-identities.d.ts +2 -1
- package/lib/seam/connect/routes/user-identities.js +7 -3
- package/lib/seam/connect/routes/user-identities.js.map +1 -1
- package/lib/seam/connect/routes/webhooks.d.ts +2 -1
- package/lib/seam/connect/routes/webhooks.js +7 -3
- package/lib/seam/connect/routes/webhooks.js.map +1 -1
- package/lib/seam/connect/routes/workspaces.d.ts +2 -1
- package/lib/seam/connect/routes/workspaces.js +7 -3
- package/lib/seam/connect/routes/workspaces.js.map +1 -1
- package/lib/seam/connect/seam-http-multi-workspace.d.ts +2 -1
- package/lib/seam/connect/seam-http-multi-workspace.js +5 -4
- package/lib/seam/connect/seam-http-multi-workspace.js.map +1 -1
- package/lib/seam/connect/seam-http.d.ts +2 -1
- package/lib/seam/connect/seam-http.js +21 -17
- 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 +17 -7
- package/src/lib/seam/connect/client.ts +0 -3
- package/src/lib/seam/connect/options.ts +11 -4
- package/src/lib/seam/connect/parse-options.ts +43 -4
- package/src/lib/seam/connect/routes/access-codes-unmanaged.ts +14 -3
- package/src/lib/seam/connect/routes/access-codes.ts +15 -4
- package/src/lib/seam/connect/routes/acs-access-groups.ts +14 -3
- package/src/lib/seam/connect/routes/acs-credentials.ts +14 -3
- package/src/lib/seam/connect/routes/acs-systems.ts +14 -3
- package/src/lib/seam/connect/routes/acs-users.ts +14 -3
- package/src/lib/seam/connect/routes/acs.ts +18 -7
- package/src/lib/seam/connect/routes/action-attempts.ts +26 -16
- package/src/lib/seam/connect/routes/client-sessions.ts +14 -3
- package/src/lib/seam/connect/routes/connect-webviews.ts +14 -3
- package/src/lib/seam/connect/routes/connected-accounts.ts +14 -3
- package/src/lib/seam/connect/routes/devices-unmanaged.ts +14 -3
- package/src/lib/seam/connect/routes/devices.ts +15 -4
- package/src/lib/seam/connect/routes/events.ts +14 -3
- package/src/lib/seam/connect/routes/locks.ts +38 -26
- package/src/lib/seam/connect/routes/noise-sensors-noise-thresholds.ts +14 -3
- package/src/lib/seam/connect/routes/noise-sensors.ts +18 -4
- package/src/lib/seam/connect/routes/thermostats-climate-setting-schedules.ts +14 -3
- package/src/lib/seam/connect/routes/thermostats.ts +18 -4
- package/src/lib/seam/connect/routes/user-identities.ts +14 -3
- package/src/lib/seam/connect/routes/webhooks.ts +14 -3
- package/src/lib/seam/connect/routes/workspaces.ts +14 -3
- package/src/lib/seam/connect/seam-http-multi-workspace.ts +7 -4
- package/src/lib/seam/connect/seam-http.ts +25 -17
- package/src/lib/version.ts +1 -1
|
@@ -22,17 +22,23 @@ import {
|
|
|
22
22
|
type SeamHttpOptionsWithClientSessionToken,
|
|
23
23
|
type SeamHttpOptionsWithConsoleSessionToken,
|
|
24
24
|
type SeamHttpOptionsWithPersonalAccessToken,
|
|
25
|
+
type SeamHttpRequestOptions,
|
|
25
26
|
} from 'lib/seam/connect/options.js'
|
|
26
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
limitToSeamHttpRequestOptions,
|
|
29
|
+
parseOptions,
|
|
30
|
+
} from 'lib/seam/connect/parse-options.js'
|
|
27
31
|
|
|
28
32
|
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
29
33
|
|
|
30
34
|
export class SeamHttpDevicesUnmanaged {
|
|
31
35
|
client: Client
|
|
36
|
+
readonly defaults: Required<SeamHttpRequestOptions>
|
|
32
37
|
|
|
33
38
|
constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
|
|
34
|
-
const
|
|
35
|
-
this.client = createClient(
|
|
39
|
+
const options = parseOptions(apiKeyOrOptions)
|
|
40
|
+
this.client = 'client' in options ? options.client : createClient(options)
|
|
41
|
+
this.defaults = limitToSeamHttpRequestOptions(options)
|
|
36
42
|
}
|
|
37
43
|
|
|
38
44
|
static fromClient(
|
|
@@ -78,6 +84,11 @@ export class SeamHttpDevicesUnmanaged {
|
|
|
78
84
|
): Promise<SeamHttpDevicesUnmanaged> {
|
|
79
85
|
warnOnInsecureuserIdentifierKey(userIdentifierKey)
|
|
80
86
|
const clientOptions = parseOptions({ ...options, publishableKey })
|
|
87
|
+
if (isSeamHttpOptionsWithClient(clientOptions)) {
|
|
88
|
+
throw new SeamHttpInvalidOptionsError(
|
|
89
|
+
'The client option cannot be used with SeamHttp.fromPublishableKey',
|
|
90
|
+
)
|
|
91
|
+
}
|
|
81
92
|
const client = createClient(clientOptions)
|
|
82
93
|
const clientSessions = SeamHttpClientSessions.fromClient(client)
|
|
83
94
|
const { token } = await clientSessions.getOrCreate({
|
|
@@ -22,18 +22,24 @@ import {
|
|
|
22
22
|
type SeamHttpOptionsWithClientSessionToken,
|
|
23
23
|
type SeamHttpOptionsWithConsoleSessionToken,
|
|
24
24
|
type SeamHttpOptionsWithPersonalAccessToken,
|
|
25
|
+
type SeamHttpRequestOptions,
|
|
25
26
|
} from 'lib/seam/connect/options.js'
|
|
26
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
limitToSeamHttpRequestOptions,
|
|
29
|
+
parseOptions,
|
|
30
|
+
} from 'lib/seam/connect/parse-options.js'
|
|
27
31
|
|
|
28
32
|
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
29
33
|
import { SeamHttpDevicesUnmanaged } from './devices-unmanaged.js'
|
|
30
34
|
|
|
31
35
|
export class SeamHttpDevices {
|
|
32
36
|
client: Client
|
|
37
|
+
readonly defaults: Required<SeamHttpRequestOptions>
|
|
33
38
|
|
|
34
39
|
constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
|
|
35
|
-
const
|
|
36
|
-
this.client = createClient(
|
|
40
|
+
const options = parseOptions(apiKeyOrOptions)
|
|
41
|
+
this.client = 'client' in options ? options.client : createClient(options)
|
|
42
|
+
this.defaults = limitToSeamHttpRequestOptions(options)
|
|
37
43
|
}
|
|
38
44
|
|
|
39
45
|
static fromClient(
|
|
@@ -79,6 +85,11 @@ export class SeamHttpDevices {
|
|
|
79
85
|
): Promise<SeamHttpDevices> {
|
|
80
86
|
warnOnInsecureuserIdentifierKey(userIdentifierKey)
|
|
81
87
|
const clientOptions = parseOptions({ ...options, publishableKey })
|
|
88
|
+
if (isSeamHttpOptionsWithClient(clientOptions)) {
|
|
89
|
+
throw new SeamHttpInvalidOptionsError(
|
|
90
|
+
'The client option cannot be used with SeamHttp.fromPublishableKey',
|
|
91
|
+
)
|
|
92
|
+
}
|
|
82
93
|
const client = createClient(clientOptions)
|
|
83
94
|
const clientSessions = SeamHttpClientSessions.fromClient(client)
|
|
84
95
|
const { token } = await clientSessions.getOrCreate({
|
|
@@ -122,7 +133,7 @@ export class SeamHttpDevices {
|
|
|
122
133
|
}
|
|
123
134
|
|
|
124
135
|
get unmanaged(): SeamHttpDevicesUnmanaged {
|
|
125
|
-
return SeamHttpDevicesUnmanaged.fromClient(this.client)
|
|
136
|
+
return SeamHttpDevicesUnmanaged.fromClient(this.client, this.defaults)
|
|
126
137
|
}
|
|
127
138
|
|
|
128
139
|
async delete(body?: DevicesDeleteBody): Promise<void> {
|
|
@@ -22,17 +22,23 @@ import {
|
|
|
22
22
|
type SeamHttpOptionsWithClientSessionToken,
|
|
23
23
|
type SeamHttpOptionsWithConsoleSessionToken,
|
|
24
24
|
type SeamHttpOptionsWithPersonalAccessToken,
|
|
25
|
+
type SeamHttpRequestOptions,
|
|
25
26
|
} from 'lib/seam/connect/options.js'
|
|
26
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
limitToSeamHttpRequestOptions,
|
|
29
|
+
parseOptions,
|
|
30
|
+
} from 'lib/seam/connect/parse-options.js'
|
|
27
31
|
|
|
28
32
|
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
29
33
|
|
|
30
34
|
export class SeamHttpEvents {
|
|
31
35
|
client: Client
|
|
36
|
+
readonly defaults: Required<SeamHttpRequestOptions>
|
|
32
37
|
|
|
33
38
|
constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
|
|
34
|
-
const
|
|
35
|
-
this.client = createClient(
|
|
39
|
+
const options = parseOptions(apiKeyOrOptions)
|
|
40
|
+
this.client = 'client' in options ? options.client : createClient(options)
|
|
41
|
+
this.defaults = limitToSeamHttpRequestOptions(options)
|
|
36
42
|
}
|
|
37
43
|
|
|
38
44
|
static fromClient(
|
|
@@ -78,6 +84,11 @@ export class SeamHttpEvents {
|
|
|
78
84
|
): Promise<SeamHttpEvents> {
|
|
79
85
|
warnOnInsecureuserIdentifierKey(userIdentifierKey)
|
|
80
86
|
const clientOptions = parseOptions({ ...options, publishableKey })
|
|
87
|
+
if (isSeamHttpOptionsWithClient(clientOptions)) {
|
|
88
|
+
throw new SeamHttpInvalidOptionsError(
|
|
89
|
+
'The client option cannot be used with SeamHttp.fromPublishableKey',
|
|
90
|
+
)
|
|
91
|
+
}
|
|
81
92
|
const client = createClient(clientOptions)
|
|
82
93
|
const clientSessions = SeamHttpClientSessions.fromClient(client)
|
|
83
94
|
const { token } = await clientSessions.getOrCreate({
|
|
@@ -22,22 +22,25 @@ import {
|
|
|
22
22
|
type SeamHttpOptionsWithClientSessionToken,
|
|
23
23
|
type SeamHttpOptionsWithConsoleSessionToken,
|
|
24
24
|
type SeamHttpOptionsWithPersonalAccessToken,
|
|
25
|
+
type SeamHttpRequestOptions,
|
|
25
26
|
} from 'lib/seam/connect/options.js'
|
|
26
|
-
import { parseOptions } from 'lib/seam/connect/parse-options.js'
|
|
27
27
|
import {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
} from 'lib/seam/connect/
|
|
28
|
+
limitToSeamHttpRequestOptions,
|
|
29
|
+
parseOptions,
|
|
30
|
+
} from 'lib/seam/connect/parse-options.js'
|
|
31
|
+
import { resolveActionAttempt } from 'lib/seam/connect/resolve-action-attempt.js'
|
|
31
32
|
|
|
32
33
|
import { SeamHttpActionAttempts } from './action-attempts.js'
|
|
33
34
|
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
34
35
|
|
|
35
36
|
export class SeamHttpLocks {
|
|
36
37
|
client: Client
|
|
38
|
+
readonly defaults: Required<SeamHttpRequestOptions>
|
|
37
39
|
|
|
38
40
|
constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
|
|
39
|
-
const
|
|
40
|
-
this.client = createClient(
|
|
41
|
+
const options = parseOptions(apiKeyOrOptions)
|
|
42
|
+
this.client = 'client' in options ? options.client : createClient(options)
|
|
43
|
+
this.defaults = limitToSeamHttpRequestOptions(options)
|
|
41
44
|
}
|
|
42
45
|
|
|
43
46
|
static fromClient(
|
|
@@ -83,6 +86,11 @@ export class SeamHttpLocks {
|
|
|
83
86
|
): Promise<SeamHttpLocks> {
|
|
84
87
|
warnOnInsecureuserIdentifierKey(userIdentifierKey)
|
|
85
88
|
const clientOptions = parseOptions({ ...options, publishableKey })
|
|
89
|
+
if (isSeamHttpOptionsWithClient(clientOptions)) {
|
|
90
|
+
throw new SeamHttpInvalidOptionsError(
|
|
91
|
+
'The client option cannot be used with SeamHttp.fromPublishableKey',
|
|
92
|
+
)
|
|
93
|
+
}
|
|
86
94
|
const client = createClient(clientOptions)
|
|
87
95
|
const clientSessions = SeamHttpClientSessions.fromClient(client)
|
|
88
96
|
const { token } = await clientSessions.getOrCreate({
|
|
@@ -147,21 +155,22 @@ export class SeamHttpLocks {
|
|
|
147
155
|
|
|
148
156
|
async lockDoor(
|
|
149
157
|
body?: LocksLockDoorBody,
|
|
150
|
-
{
|
|
151
|
-
waitForActionAttempt = false,
|
|
152
|
-
}: {
|
|
153
|
-
waitForActionAttempt?: boolean | Partial<ResolveActionAttemptOptions>
|
|
154
|
-
} = {},
|
|
158
|
+
options: Pick<SeamHttpRequestOptions, 'waitForActionAttempt'> = {},
|
|
155
159
|
): Promise<LocksLockDoorResponse['action_attempt']> {
|
|
156
160
|
const { data } = await this.client.request<LocksLockDoorResponse>({
|
|
157
161
|
url: '/locks/lock_door',
|
|
158
162
|
method: 'post',
|
|
159
163
|
data: body,
|
|
160
164
|
})
|
|
161
|
-
|
|
165
|
+
const waitForActionAttempt =
|
|
166
|
+
options.waitForActionAttempt ?? this.defaults.waitForActionAttempt
|
|
167
|
+
if (waitForActionAttempt !== false) {
|
|
162
168
|
return await resolveActionAttempt(
|
|
163
169
|
data.action_attempt,
|
|
164
|
-
SeamHttpActionAttempts.fromClient(this.client
|
|
170
|
+
SeamHttpActionAttempts.fromClient(this.client, {
|
|
171
|
+
...this.defaults,
|
|
172
|
+
waitForActionAttempt: false,
|
|
173
|
+
}),
|
|
165
174
|
typeof waitForActionAttempt === 'boolean' ? {} : waitForActionAttempt,
|
|
166
175
|
)
|
|
167
176
|
}
|
|
@@ -170,21 +179,22 @@ export class SeamHttpLocks {
|
|
|
170
179
|
|
|
171
180
|
async unlockDoor(
|
|
172
181
|
body?: LocksUnlockDoorBody,
|
|
173
|
-
{
|
|
174
|
-
waitForActionAttempt = false,
|
|
175
|
-
}: {
|
|
176
|
-
waitForActionAttempt?: boolean | Partial<ResolveActionAttemptOptions>
|
|
177
|
-
} = {},
|
|
182
|
+
options: Pick<SeamHttpRequestOptions, 'waitForActionAttempt'> = {},
|
|
178
183
|
): Promise<LocksUnlockDoorResponse['action_attempt']> {
|
|
179
184
|
const { data } = await this.client.request<LocksUnlockDoorResponse>({
|
|
180
185
|
url: '/locks/unlock_door',
|
|
181
186
|
method: 'post',
|
|
182
187
|
data: body,
|
|
183
188
|
})
|
|
184
|
-
|
|
189
|
+
const waitForActionAttempt =
|
|
190
|
+
options.waitForActionAttempt ?? this.defaults.waitForActionAttempt
|
|
191
|
+
if (waitForActionAttempt !== false) {
|
|
185
192
|
return await resolveActionAttempt(
|
|
186
193
|
data.action_attempt,
|
|
187
|
-
SeamHttpActionAttempts.fromClient(this.client
|
|
194
|
+
SeamHttpActionAttempts.fromClient(this.client, {
|
|
195
|
+
...this.defaults,
|
|
196
|
+
waitForActionAttempt: false,
|
|
197
|
+
}),
|
|
188
198
|
typeof waitForActionAttempt === 'boolean' ? {} : waitForActionAttempt,
|
|
189
199
|
)
|
|
190
200
|
}
|
|
@@ -214,9 +224,10 @@ export type LocksLockDoorResponse = SetNonNullable<
|
|
|
214
224
|
Required<RouteResponse<'/locks/lock_door'>>
|
|
215
225
|
>
|
|
216
226
|
|
|
217
|
-
export
|
|
218
|
-
|
|
219
|
-
|
|
227
|
+
export type LocksLockDoorOptions = Pick<
|
|
228
|
+
SeamHttpRequestOptions,
|
|
229
|
+
'waitForActionAttempt'
|
|
230
|
+
>
|
|
220
231
|
|
|
221
232
|
export type LocksUnlockDoorBody = RouteRequestBody<'/locks/unlock_door'>
|
|
222
233
|
|
|
@@ -224,6 +235,7 @@ export type LocksUnlockDoorResponse = SetNonNullable<
|
|
|
224
235
|
Required<RouteResponse<'/locks/unlock_door'>>
|
|
225
236
|
>
|
|
226
237
|
|
|
227
|
-
export
|
|
228
|
-
|
|
229
|
-
|
|
238
|
+
export type LocksUnlockDoorOptions = Pick<
|
|
239
|
+
SeamHttpRequestOptions,
|
|
240
|
+
'waitForActionAttempt'
|
|
241
|
+
>
|
|
@@ -22,17 +22,23 @@ import {
|
|
|
22
22
|
type SeamHttpOptionsWithClientSessionToken,
|
|
23
23
|
type SeamHttpOptionsWithConsoleSessionToken,
|
|
24
24
|
type SeamHttpOptionsWithPersonalAccessToken,
|
|
25
|
+
type SeamHttpRequestOptions,
|
|
25
26
|
} from 'lib/seam/connect/options.js'
|
|
26
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
limitToSeamHttpRequestOptions,
|
|
29
|
+
parseOptions,
|
|
30
|
+
} from 'lib/seam/connect/parse-options.js'
|
|
27
31
|
|
|
28
32
|
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
29
33
|
|
|
30
34
|
export class SeamHttpNoiseSensorsNoiseThresholds {
|
|
31
35
|
client: Client
|
|
36
|
+
readonly defaults: Required<SeamHttpRequestOptions>
|
|
32
37
|
|
|
33
38
|
constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
|
|
34
|
-
const
|
|
35
|
-
this.client = createClient(
|
|
39
|
+
const options = parseOptions(apiKeyOrOptions)
|
|
40
|
+
this.client = 'client' in options ? options.client : createClient(options)
|
|
41
|
+
this.defaults = limitToSeamHttpRequestOptions(options)
|
|
36
42
|
}
|
|
37
43
|
|
|
38
44
|
static fromClient(
|
|
@@ -78,6 +84,11 @@ export class SeamHttpNoiseSensorsNoiseThresholds {
|
|
|
78
84
|
): Promise<SeamHttpNoiseSensorsNoiseThresholds> {
|
|
79
85
|
warnOnInsecureuserIdentifierKey(userIdentifierKey)
|
|
80
86
|
const clientOptions = parseOptions({ ...options, publishableKey })
|
|
87
|
+
if (isSeamHttpOptionsWithClient(clientOptions)) {
|
|
88
|
+
throw new SeamHttpInvalidOptionsError(
|
|
89
|
+
'The client option cannot be used with SeamHttp.fromPublishableKey',
|
|
90
|
+
)
|
|
91
|
+
}
|
|
81
92
|
const client = createClient(clientOptions)
|
|
82
93
|
const clientSessions = SeamHttpClientSessions.fromClient(client)
|
|
83
94
|
const { token } = await clientSessions.getOrCreate({
|
|
@@ -19,18 +19,24 @@ import {
|
|
|
19
19
|
type SeamHttpOptionsWithClientSessionToken,
|
|
20
20
|
type SeamHttpOptionsWithConsoleSessionToken,
|
|
21
21
|
type SeamHttpOptionsWithPersonalAccessToken,
|
|
22
|
+
type SeamHttpRequestOptions,
|
|
22
23
|
} from 'lib/seam/connect/options.js'
|
|
23
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
limitToSeamHttpRequestOptions,
|
|
26
|
+
parseOptions,
|
|
27
|
+
} from 'lib/seam/connect/parse-options.js'
|
|
24
28
|
|
|
25
29
|
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
26
30
|
import { SeamHttpNoiseSensorsNoiseThresholds } from './noise-sensors-noise-thresholds.js'
|
|
27
31
|
|
|
28
32
|
export class SeamHttpNoiseSensors {
|
|
29
33
|
client: Client
|
|
34
|
+
readonly defaults: Required<SeamHttpRequestOptions>
|
|
30
35
|
|
|
31
36
|
constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
|
|
32
|
-
const
|
|
33
|
-
this.client = createClient(
|
|
37
|
+
const options = parseOptions(apiKeyOrOptions)
|
|
38
|
+
this.client = 'client' in options ? options.client : createClient(options)
|
|
39
|
+
this.defaults = limitToSeamHttpRequestOptions(options)
|
|
34
40
|
}
|
|
35
41
|
|
|
36
42
|
static fromClient(
|
|
@@ -76,6 +82,11 @@ export class SeamHttpNoiseSensors {
|
|
|
76
82
|
): Promise<SeamHttpNoiseSensors> {
|
|
77
83
|
warnOnInsecureuserIdentifierKey(userIdentifierKey)
|
|
78
84
|
const clientOptions = parseOptions({ ...options, publishableKey })
|
|
85
|
+
if (isSeamHttpOptionsWithClient(clientOptions)) {
|
|
86
|
+
throw new SeamHttpInvalidOptionsError(
|
|
87
|
+
'The client option cannot be used with SeamHttp.fromPublishableKey',
|
|
88
|
+
)
|
|
89
|
+
}
|
|
79
90
|
const client = createClient(clientOptions)
|
|
80
91
|
const clientSessions = SeamHttpClientSessions.fromClient(client)
|
|
81
92
|
const { token } = await clientSessions.getOrCreate({
|
|
@@ -119,6 +130,9 @@ export class SeamHttpNoiseSensors {
|
|
|
119
130
|
}
|
|
120
131
|
|
|
121
132
|
get noiseThresholds(): SeamHttpNoiseSensorsNoiseThresholds {
|
|
122
|
-
return SeamHttpNoiseSensorsNoiseThresholds.fromClient(
|
|
133
|
+
return SeamHttpNoiseSensorsNoiseThresholds.fromClient(
|
|
134
|
+
this.client,
|
|
135
|
+
this.defaults,
|
|
136
|
+
)
|
|
123
137
|
}
|
|
124
138
|
}
|
|
@@ -22,17 +22,23 @@ import {
|
|
|
22
22
|
type SeamHttpOptionsWithClientSessionToken,
|
|
23
23
|
type SeamHttpOptionsWithConsoleSessionToken,
|
|
24
24
|
type SeamHttpOptionsWithPersonalAccessToken,
|
|
25
|
+
type SeamHttpRequestOptions,
|
|
25
26
|
} from 'lib/seam/connect/options.js'
|
|
26
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
limitToSeamHttpRequestOptions,
|
|
29
|
+
parseOptions,
|
|
30
|
+
} from 'lib/seam/connect/parse-options.js'
|
|
27
31
|
|
|
28
32
|
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
29
33
|
|
|
30
34
|
export class SeamHttpThermostatsClimateSettingSchedules {
|
|
31
35
|
client: Client
|
|
36
|
+
readonly defaults: Required<SeamHttpRequestOptions>
|
|
32
37
|
|
|
33
38
|
constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
|
|
34
|
-
const
|
|
35
|
-
this.client = createClient(
|
|
39
|
+
const options = parseOptions(apiKeyOrOptions)
|
|
40
|
+
this.client = 'client' in options ? options.client : createClient(options)
|
|
41
|
+
this.defaults = limitToSeamHttpRequestOptions(options)
|
|
36
42
|
}
|
|
37
43
|
|
|
38
44
|
static fromClient(
|
|
@@ -78,6 +84,11 @@ export class SeamHttpThermostatsClimateSettingSchedules {
|
|
|
78
84
|
): Promise<SeamHttpThermostatsClimateSettingSchedules> {
|
|
79
85
|
warnOnInsecureuserIdentifierKey(userIdentifierKey)
|
|
80
86
|
const clientOptions = parseOptions({ ...options, publishableKey })
|
|
87
|
+
if (isSeamHttpOptionsWithClient(clientOptions)) {
|
|
88
|
+
throw new SeamHttpInvalidOptionsError(
|
|
89
|
+
'The client option cannot be used with SeamHttp.fromPublishableKey',
|
|
90
|
+
)
|
|
91
|
+
}
|
|
81
92
|
const client = createClient(clientOptions)
|
|
82
93
|
const clientSessions = SeamHttpClientSessions.fromClient(client)
|
|
83
94
|
const { token } = await clientSessions.getOrCreate({
|
|
@@ -22,18 +22,24 @@ import {
|
|
|
22
22
|
type SeamHttpOptionsWithClientSessionToken,
|
|
23
23
|
type SeamHttpOptionsWithConsoleSessionToken,
|
|
24
24
|
type SeamHttpOptionsWithPersonalAccessToken,
|
|
25
|
+
type SeamHttpRequestOptions,
|
|
25
26
|
} from 'lib/seam/connect/options.js'
|
|
26
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
limitToSeamHttpRequestOptions,
|
|
29
|
+
parseOptions,
|
|
30
|
+
} from 'lib/seam/connect/parse-options.js'
|
|
27
31
|
|
|
28
32
|
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
29
33
|
import { SeamHttpThermostatsClimateSettingSchedules } from './thermostats-climate-setting-schedules.js'
|
|
30
34
|
|
|
31
35
|
export class SeamHttpThermostats {
|
|
32
36
|
client: Client
|
|
37
|
+
readonly defaults: Required<SeamHttpRequestOptions>
|
|
33
38
|
|
|
34
39
|
constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
|
|
35
|
-
const
|
|
36
|
-
this.client = createClient(
|
|
40
|
+
const options = parseOptions(apiKeyOrOptions)
|
|
41
|
+
this.client = 'client' in options ? options.client : createClient(options)
|
|
42
|
+
this.defaults = limitToSeamHttpRequestOptions(options)
|
|
37
43
|
}
|
|
38
44
|
|
|
39
45
|
static fromClient(
|
|
@@ -79,6 +85,11 @@ export class SeamHttpThermostats {
|
|
|
79
85
|
): Promise<SeamHttpThermostats> {
|
|
80
86
|
warnOnInsecureuserIdentifierKey(userIdentifierKey)
|
|
81
87
|
const clientOptions = parseOptions({ ...options, publishableKey })
|
|
88
|
+
if (isSeamHttpOptionsWithClient(clientOptions)) {
|
|
89
|
+
throw new SeamHttpInvalidOptionsError(
|
|
90
|
+
'The client option cannot be used with SeamHttp.fromPublishableKey',
|
|
91
|
+
)
|
|
92
|
+
}
|
|
82
93
|
const client = createClient(clientOptions)
|
|
83
94
|
const clientSessions = SeamHttpClientSessions.fromClient(client)
|
|
84
95
|
const { token } = await clientSessions.getOrCreate({
|
|
@@ -122,7 +133,10 @@ export class SeamHttpThermostats {
|
|
|
122
133
|
}
|
|
123
134
|
|
|
124
135
|
get climateSettingSchedules(): SeamHttpThermostatsClimateSettingSchedules {
|
|
125
|
-
return SeamHttpThermostatsClimateSettingSchedules.fromClient(
|
|
136
|
+
return SeamHttpThermostatsClimateSettingSchedules.fromClient(
|
|
137
|
+
this.client,
|
|
138
|
+
this.defaults,
|
|
139
|
+
)
|
|
126
140
|
}
|
|
127
141
|
|
|
128
142
|
async cool(body?: ThermostatsCoolBody): Promise<void> {
|
|
@@ -22,17 +22,23 @@ import {
|
|
|
22
22
|
type SeamHttpOptionsWithClientSessionToken,
|
|
23
23
|
type SeamHttpOptionsWithConsoleSessionToken,
|
|
24
24
|
type SeamHttpOptionsWithPersonalAccessToken,
|
|
25
|
+
type SeamHttpRequestOptions,
|
|
25
26
|
} from 'lib/seam/connect/options.js'
|
|
26
|
-
import {
|
|
27
|
+
import {
|
|
28
|
+
limitToSeamHttpRequestOptions,
|
|
29
|
+
parseOptions,
|
|
30
|
+
} from 'lib/seam/connect/parse-options.js'
|
|
27
31
|
|
|
28
32
|
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
29
33
|
|
|
30
34
|
export class SeamHttpUserIdentities {
|
|
31
35
|
client: Client
|
|
36
|
+
readonly defaults: Required<SeamHttpRequestOptions>
|
|
32
37
|
|
|
33
38
|
constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
|
|
34
|
-
const
|
|
35
|
-
this.client = createClient(
|
|
39
|
+
const options = parseOptions(apiKeyOrOptions)
|
|
40
|
+
this.client = 'client' in options ? options.client : createClient(options)
|
|
41
|
+
this.defaults = limitToSeamHttpRequestOptions(options)
|
|
36
42
|
}
|
|
37
43
|
|
|
38
44
|
static fromClient(
|
|
@@ -78,6 +84,11 @@ export class SeamHttpUserIdentities {
|
|
|
78
84
|
): Promise<SeamHttpUserIdentities> {
|
|
79
85
|
warnOnInsecureuserIdentifierKey(userIdentifierKey)
|
|
80
86
|
const clientOptions = parseOptions({ ...options, publishableKey })
|
|
87
|
+
if (isSeamHttpOptionsWithClient(clientOptions)) {
|
|
88
|
+
throw new SeamHttpInvalidOptionsError(
|
|
89
|
+
'The client option cannot be used with SeamHttp.fromPublishableKey',
|
|
90
|
+
)
|
|
91
|
+
}
|
|
81
92
|
const client = createClient(clientOptions)
|
|
82
93
|
const clientSessions = SeamHttpClientSessions.fromClient(client)
|
|
83
94
|
const { token } = await clientSessions.getOrCreate({
|
|
@@ -26,17 +26,23 @@ import {
|
|
|
26
26
|
type SeamHttpOptionsWithClientSessionToken,
|
|
27
27
|
type SeamHttpOptionsWithConsoleSessionToken,
|
|
28
28
|
type SeamHttpOptionsWithPersonalAccessToken,
|
|
29
|
+
type SeamHttpRequestOptions,
|
|
29
30
|
} from 'lib/seam/connect/options.js'
|
|
30
|
-
import {
|
|
31
|
+
import {
|
|
32
|
+
limitToSeamHttpRequestOptions,
|
|
33
|
+
parseOptions,
|
|
34
|
+
} from 'lib/seam/connect/parse-options.js'
|
|
31
35
|
|
|
32
36
|
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
33
37
|
|
|
34
38
|
export class SeamHttpWebhooks {
|
|
35
39
|
client: Client
|
|
40
|
+
readonly defaults: Required<SeamHttpRequestOptions>
|
|
36
41
|
|
|
37
42
|
constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
|
|
38
|
-
const
|
|
39
|
-
this.client = createClient(
|
|
43
|
+
const options = parseOptions(apiKeyOrOptions)
|
|
44
|
+
this.client = 'client' in options ? options.client : createClient(options)
|
|
45
|
+
this.defaults = limitToSeamHttpRequestOptions(options)
|
|
40
46
|
}
|
|
41
47
|
|
|
42
48
|
static fromClient(
|
|
@@ -82,6 +88,11 @@ export class SeamHttpWebhooks {
|
|
|
82
88
|
): Promise<SeamHttpWebhooks> {
|
|
83
89
|
warnOnInsecureuserIdentifierKey(userIdentifierKey)
|
|
84
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
|
+
}
|
|
85
96
|
const client = createClient(clientOptions)
|
|
86
97
|
const clientSessions = SeamHttpClientSessions.fromClient(client)
|
|
87
98
|
const { token } = await clientSessions.getOrCreate({
|
|
@@ -26,17 +26,23 @@ import {
|
|
|
26
26
|
type SeamHttpOptionsWithClientSessionToken,
|
|
27
27
|
type SeamHttpOptionsWithConsoleSessionToken,
|
|
28
28
|
type SeamHttpOptionsWithPersonalAccessToken,
|
|
29
|
+
type SeamHttpRequestOptions,
|
|
29
30
|
} from 'lib/seam/connect/options.js'
|
|
30
|
-
import {
|
|
31
|
+
import {
|
|
32
|
+
limitToSeamHttpRequestOptions,
|
|
33
|
+
parseOptions,
|
|
34
|
+
} from 'lib/seam/connect/parse-options.js'
|
|
31
35
|
|
|
32
36
|
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
33
37
|
|
|
34
38
|
export class SeamHttpWorkspaces {
|
|
35
39
|
client: Client
|
|
40
|
+
readonly defaults: Required<SeamHttpRequestOptions>
|
|
36
41
|
|
|
37
42
|
constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
|
|
38
|
-
const
|
|
39
|
-
this.client = createClient(
|
|
43
|
+
const options = parseOptions(apiKeyOrOptions)
|
|
44
|
+
this.client = 'client' in options ? options.client : createClient(options)
|
|
45
|
+
this.defaults = limitToSeamHttpRequestOptions(options)
|
|
40
46
|
}
|
|
41
47
|
|
|
42
48
|
static fromClient(
|
|
@@ -82,6 +88,11 @@ export class SeamHttpWorkspaces {
|
|
|
82
88
|
): Promise<SeamHttpWorkspaces> {
|
|
83
89
|
warnOnInsecureuserIdentifierKey(userIdentifierKey)
|
|
84
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
|
+
}
|
|
85
96
|
const client = createClient(clientOptions)
|
|
86
97
|
const clientSessions = SeamHttpClientSessions.fromClient(client)
|
|
87
98
|
const { token } = await clientSessions.getOrCreate({
|
|
@@ -8,16 +8,19 @@ import {
|
|
|
8
8
|
type SeamHttpMultiWorkspaceOptionsWithClient,
|
|
9
9
|
type SeamHttpMultiWorkspaceOptionsWithConsoleSessionToken,
|
|
10
10
|
type SeamHttpMultiWorkspaceOptionsWithPersonalAccessToken,
|
|
11
|
+
type SeamHttpRequestOptions,
|
|
11
12
|
} from './options.js'
|
|
12
|
-
import { parseOptions } from './parse-options.js'
|
|
13
|
+
import { limitToSeamHttpRequestOptions, parseOptions } from './parse-options.js'
|
|
13
14
|
import { SeamHttpWorkspaces } from './routes/index.js'
|
|
14
15
|
|
|
15
16
|
export class SeamHttpMultiWorkspace {
|
|
16
17
|
client: Client
|
|
18
|
+
readonly defaults: Required<SeamHttpRequestOptions>
|
|
17
19
|
|
|
18
20
|
constructor(options: SeamHttpMultiWorkspaceOptions) {
|
|
19
|
-
const
|
|
20
|
-
this.client = createClient(
|
|
21
|
+
const opts = parseOptions(options)
|
|
22
|
+
this.client = 'client' in opts ? opts.client : createClient(opts)
|
|
23
|
+
this.defaults = limitToSeamHttpRequestOptions(opts)
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
static fromClient(
|
|
@@ -72,6 +75,6 @@ export class SeamHttpMultiWorkspace {
|
|
|
72
75
|
}
|
|
73
76
|
|
|
74
77
|
get workspaces(): SeamHttpWorkspaces {
|
|
75
|
-
return SeamHttpWorkspaces.fromClient(this.client)
|
|
78
|
+
return SeamHttpWorkspaces.fromClient(this.client, this.defaults)
|
|
76
79
|
}
|
|
77
80
|
}
|