@seamapi/http 0.22.0 → 0.24.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 +1 -1
- package/dist/connect.cjs +160 -10
- package/dist/connect.cjs.map +1 -1
- package/dist/connect.d.cts +29 -11
- package/lib/seam/connect/routes/devices-simulate.d.ts +20 -0
- package/lib/seam/connect/routes/devices-simulate.js +86 -0
- package/lib/seam/connect/routes/devices-simulate.js.map +1 -0
- package/lib/seam/connect/routes/devices.d.ts +2 -0
- package/lib/seam/connect/routes/devices.js +4 -0
- package/lib/seam/connect/routes/devices.js.map +1 -1
- package/lib/seam/connect/routes/index.d.ts +1 -0
- package/lib/seam/connect/routes/index.js +1 -0
- package/lib/seam/connect/routes/index.js.map +1 -1
- package/lib/seam/connect/routes/thermostats.d.ts +10 -10
- package/lib/seam/connect/routes/thermostats.js +52 -10
- package/lib/seam/connect/routes/thermostats.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/devices-simulate.ts +172 -0
- package/src/lib/seam/connect/routes/devices.ts +5 -0
- package/src/lib/seam/connect/routes/index.ts +1 -0
- package/src/lib/seam/connect/routes/thermostats.ts +112 -15
- package/src/lib/version.ts +1 -1
package/README.md
CHANGED
|
@@ -366,7 +366,7 @@ Either pass the `endpoint` option, or set the `SEAM_ENDPOINT` environment variab
|
|
|
366
366
|
#### Configuring the Axios Client
|
|
367
367
|
|
|
368
368
|
The Axios client and retry behavior may be configured with custom initiation options
|
|
369
|
-
via [`axiosOptions`] and [`axiosRetryOptions`][axiosRetryOptions].
|
|
369
|
+
via [`axiosOptions`][axiosOptions] and [`axiosRetryOptions`][axiosRetryOptions].
|
|
370
370
|
Options are deep merged with the default options.
|
|
371
371
|
|
|
372
372
|
[axiosOptions]: https://axios-http.com/docs/config_defaults
|
package/dist/connect.cjs
CHANGED
|
@@ -2265,6 +2265,92 @@ var SeamHttpConnectedAccounts = class _SeamHttpConnectedAccounts {
|
|
|
2265
2265
|
}
|
|
2266
2266
|
};
|
|
2267
2267
|
|
|
2268
|
+
// src/lib/seam/connect/routes/devices-simulate.ts
|
|
2269
|
+
var SeamHttpDevicesSimulate = class _SeamHttpDevicesSimulate {
|
|
2270
|
+
constructor(apiKeyOrOptions = {}) {
|
|
2271
|
+
const options = parseOptions(apiKeyOrOptions);
|
|
2272
|
+
this.client = "client" in options ? options.client : createClient(options);
|
|
2273
|
+
this.defaults = limitToSeamHttpRequestOptions(options);
|
|
2274
|
+
}
|
|
2275
|
+
static fromClient(client, options = {}) {
|
|
2276
|
+
const constructorOptions = { ...options, client };
|
|
2277
|
+
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
2278
|
+
throw new SeamHttpInvalidOptionsError("Missing client");
|
|
2279
|
+
}
|
|
2280
|
+
return new _SeamHttpDevicesSimulate(constructorOptions);
|
|
2281
|
+
}
|
|
2282
|
+
static fromApiKey(apiKey, options = {}) {
|
|
2283
|
+
const constructorOptions = { ...options, apiKey };
|
|
2284
|
+
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
2285
|
+
throw new SeamHttpInvalidOptionsError("Missing apiKey");
|
|
2286
|
+
}
|
|
2287
|
+
return new _SeamHttpDevicesSimulate(constructorOptions);
|
|
2288
|
+
}
|
|
2289
|
+
static fromClientSessionToken(clientSessionToken, options = {}) {
|
|
2290
|
+
const constructorOptions = { ...options, clientSessionToken };
|
|
2291
|
+
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
2292
|
+
throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
|
|
2293
|
+
}
|
|
2294
|
+
return new _SeamHttpDevicesSimulate(constructorOptions);
|
|
2295
|
+
}
|
|
2296
|
+
static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
|
|
2297
|
+
warnOnInsecureuserIdentifierKey(userIdentifierKey);
|
|
2298
|
+
const clientOptions = parseOptions({ ...options, publishableKey });
|
|
2299
|
+
if (isSeamHttpOptionsWithClient(clientOptions)) {
|
|
2300
|
+
throw new SeamHttpInvalidOptionsError(
|
|
2301
|
+
"The client option cannot be used with SeamHttp.fromPublishableKey"
|
|
2302
|
+
);
|
|
2303
|
+
}
|
|
2304
|
+
const client = createClient(clientOptions);
|
|
2305
|
+
const clientSessions = SeamHttpClientSessions.fromClient(client);
|
|
2306
|
+
const { token } = await clientSessions.getOrCreate({
|
|
2307
|
+
user_identifier_key: userIdentifierKey
|
|
2308
|
+
});
|
|
2309
|
+
return _SeamHttpDevicesSimulate.fromClientSessionToken(token, options);
|
|
2310
|
+
}
|
|
2311
|
+
static fromConsoleSessionToken(consoleSessionToken, workspaceId, options = {}) {
|
|
2312
|
+
const constructorOptions = { ...options, consoleSessionToken, workspaceId };
|
|
2313
|
+
if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) {
|
|
2314
|
+
throw new SeamHttpInvalidOptionsError(
|
|
2315
|
+
"Missing consoleSessionToken or workspaceId"
|
|
2316
|
+
);
|
|
2317
|
+
}
|
|
2318
|
+
return new _SeamHttpDevicesSimulate(constructorOptions);
|
|
2319
|
+
}
|
|
2320
|
+
static fromPersonalAccessToken(personalAccessToken, workspaceId, options = {}) {
|
|
2321
|
+
const constructorOptions = { ...options, personalAccessToken, workspaceId };
|
|
2322
|
+
if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) {
|
|
2323
|
+
throw new SeamHttpInvalidOptionsError(
|
|
2324
|
+
"Missing personalAccessToken or workspaceId"
|
|
2325
|
+
);
|
|
2326
|
+
}
|
|
2327
|
+
return new _SeamHttpDevicesSimulate(constructorOptions);
|
|
2328
|
+
}
|
|
2329
|
+
async updateClientSessionToken(clientSessionToken) {
|
|
2330
|
+
const { headers } = this.client.defaults;
|
|
2331
|
+
const authHeaders = getAuthHeadersForClientSessionToken({
|
|
2332
|
+
clientSessionToken
|
|
2333
|
+
});
|
|
2334
|
+
for (const key of Object.keys(authHeaders)) {
|
|
2335
|
+
if (headers[key] == null) {
|
|
2336
|
+
throw new Error(
|
|
2337
|
+
"Cannot update a clientSessionToken on a client created without a clientSessionToken"
|
|
2338
|
+
);
|
|
2339
|
+
}
|
|
2340
|
+
}
|
|
2341
|
+
this.client.defaults.headers = { ...headers, ...authHeaders };
|
|
2342
|
+
const clientSessions = SeamHttpClientSessions.fromClient(this.client);
|
|
2343
|
+
await clientSessions.get();
|
|
2344
|
+
}
|
|
2345
|
+
async remove(body) {
|
|
2346
|
+
await this.client.request({
|
|
2347
|
+
url: "/devices/simulate/remove",
|
|
2348
|
+
method: "post",
|
|
2349
|
+
data: body
|
|
2350
|
+
});
|
|
2351
|
+
}
|
|
2352
|
+
};
|
|
2353
|
+
|
|
2268
2354
|
// src/lib/seam/connect/routes/devices-unmanaged.ts
|
|
2269
2355
|
var SeamHttpDevicesUnmanaged = class _SeamHttpDevicesUnmanaged {
|
|
2270
2356
|
constructor(apiKeyOrOptions = {}) {
|
|
@@ -2447,6 +2533,9 @@ var SeamHttpDevices = class _SeamHttpDevices {
|
|
|
2447
2533
|
get unmanaged() {
|
|
2448
2534
|
return SeamHttpDevicesUnmanaged.fromClient(this.client, this.defaults);
|
|
2449
2535
|
}
|
|
2536
|
+
get simulate() {
|
|
2537
|
+
return SeamHttpDevicesSimulate.fromClient(this.client, this.defaults);
|
|
2538
|
+
}
|
|
2450
2539
|
async delete(body) {
|
|
2451
2540
|
await this.client.request({
|
|
2452
2541
|
url: "/devices/delete",
|
|
@@ -3410,12 +3499,24 @@ var SeamHttpThermostats = class _SeamHttpThermostats {
|
|
|
3410
3499
|
this.defaults
|
|
3411
3500
|
);
|
|
3412
3501
|
}
|
|
3413
|
-
async cool(body) {
|
|
3414
|
-
await this.client.request({
|
|
3502
|
+
async cool(body, options = {}) {
|
|
3503
|
+
const { data } = await this.client.request({
|
|
3415
3504
|
url: "/thermostats/cool",
|
|
3416
3505
|
method: "post",
|
|
3417
3506
|
data: body
|
|
3418
3507
|
});
|
|
3508
|
+
const waitForActionAttempt = options.waitForActionAttempt ?? this.defaults.waitForActionAttempt;
|
|
3509
|
+
if (waitForActionAttempt !== false) {
|
|
3510
|
+
return await resolveActionAttempt(
|
|
3511
|
+
data.action_attempt,
|
|
3512
|
+
SeamHttpActionAttempts.fromClient(this.client, {
|
|
3513
|
+
...this.defaults,
|
|
3514
|
+
waitForActionAttempt: false
|
|
3515
|
+
}),
|
|
3516
|
+
typeof waitForActionAttempt === "boolean" ? {} : waitForActionAttempt
|
|
3517
|
+
);
|
|
3518
|
+
}
|
|
3519
|
+
return data.action_attempt;
|
|
3419
3520
|
}
|
|
3420
3521
|
async get(body) {
|
|
3421
3522
|
const { data } = await this.client.request({
|
|
@@ -3425,19 +3526,43 @@ var SeamHttpThermostats = class _SeamHttpThermostats {
|
|
|
3425
3526
|
});
|
|
3426
3527
|
return data.thermostat;
|
|
3427
3528
|
}
|
|
3428
|
-
async heat(body) {
|
|
3429
|
-
await this.client.request({
|
|
3529
|
+
async heat(body, options = {}) {
|
|
3530
|
+
const { data } = await this.client.request({
|
|
3430
3531
|
url: "/thermostats/heat",
|
|
3431
3532
|
method: "post",
|
|
3432
3533
|
data: body
|
|
3433
3534
|
});
|
|
3535
|
+
const waitForActionAttempt = options.waitForActionAttempt ?? this.defaults.waitForActionAttempt;
|
|
3536
|
+
if (waitForActionAttempt !== false) {
|
|
3537
|
+
return await resolveActionAttempt(
|
|
3538
|
+
data.action_attempt,
|
|
3539
|
+
SeamHttpActionAttempts.fromClient(this.client, {
|
|
3540
|
+
...this.defaults,
|
|
3541
|
+
waitForActionAttempt: false
|
|
3542
|
+
}),
|
|
3543
|
+
typeof waitForActionAttempt === "boolean" ? {} : waitForActionAttempt
|
|
3544
|
+
);
|
|
3545
|
+
}
|
|
3546
|
+
return data.action_attempt;
|
|
3434
3547
|
}
|
|
3435
|
-
async heatCool(body) {
|
|
3436
|
-
await this.client.request({
|
|
3548
|
+
async heatCool(body, options = {}) {
|
|
3549
|
+
const { data } = await this.client.request({
|
|
3437
3550
|
url: "/thermostats/heat_cool",
|
|
3438
3551
|
method: "post",
|
|
3439
3552
|
data: body
|
|
3440
3553
|
});
|
|
3554
|
+
const waitForActionAttempt = options.waitForActionAttempt ?? this.defaults.waitForActionAttempt;
|
|
3555
|
+
if (waitForActionAttempt !== false) {
|
|
3556
|
+
return await resolveActionAttempt(
|
|
3557
|
+
data.action_attempt,
|
|
3558
|
+
SeamHttpActionAttempts.fromClient(this.client, {
|
|
3559
|
+
...this.defaults,
|
|
3560
|
+
waitForActionAttempt: false
|
|
3561
|
+
}),
|
|
3562
|
+
typeof waitForActionAttempt === "boolean" ? {} : waitForActionAttempt
|
|
3563
|
+
);
|
|
3564
|
+
}
|
|
3565
|
+
return data.action_attempt;
|
|
3441
3566
|
}
|
|
3442
3567
|
async list(body) {
|
|
3443
3568
|
const { data } = await this.client.request({
|
|
@@ -3447,19 +3572,43 @@ var SeamHttpThermostats = class _SeamHttpThermostats {
|
|
|
3447
3572
|
});
|
|
3448
3573
|
return data.thermostats;
|
|
3449
3574
|
}
|
|
3450
|
-
async off(body) {
|
|
3451
|
-
await this.client.request({
|
|
3575
|
+
async off(body, options = {}) {
|
|
3576
|
+
const { data } = await this.client.request({
|
|
3452
3577
|
url: "/thermostats/off",
|
|
3453
3578
|
method: "post",
|
|
3454
3579
|
data: body
|
|
3455
3580
|
});
|
|
3581
|
+
const waitForActionAttempt = options.waitForActionAttempt ?? this.defaults.waitForActionAttempt;
|
|
3582
|
+
if (waitForActionAttempt !== false) {
|
|
3583
|
+
return await resolveActionAttempt(
|
|
3584
|
+
data.action_attempt,
|
|
3585
|
+
SeamHttpActionAttempts.fromClient(this.client, {
|
|
3586
|
+
...this.defaults,
|
|
3587
|
+
waitForActionAttempt: false
|
|
3588
|
+
}),
|
|
3589
|
+
typeof waitForActionAttempt === "boolean" ? {} : waitForActionAttempt
|
|
3590
|
+
);
|
|
3591
|
+
}
|
|
3592
|
+
return data.action_attempt;
|
|
3456
3593
|
}
|
|
3457
|
-
async setFanMode(body) {
|
|
3458
|
-
await this.client.request({
|
|
3594
|
+
async setFanMode(body, options = {}) {
|
|
3595
|
+
const { data } = await this.client.request({
|
|
3459
3596
|
url: "/thermostats/set_fan_mode",
|
|
3460
3597
|
method: "post",
|
|
3461
3598
|
data: body
|
|
3462
3599
|
});
|
|
3600
|
+
const waitForActionAttempt = options.waitForActionAttempt ?? this.defaults.waitForActionAttempt;
|
|
3601
|
+
if (waitForActionAttempt !== false) {
|
|
3602
|
+
return await resolveActionAttempt(
|
|
3603
|
+
data.action_attempt,
|
|
3604
|
+
SeamHttpActionAttempts.fromClient(this.client, {
|
|
3605
|
+
...this.defaults,
|
|
3606
|
+
waitForActionAttempt: false
|
|
3607
|
+
}),
|
|
3608
|
+
typeof waitForActionAttempt === "boolean" ? {} : waitForActionAttempt
|
|
3609
|
+
);
|
|
3610
|
+
}
|
|
3611
|
+
return data.action_attempt;
|
|
3463
3612
|
}
|
|
3464
3613
|
async update(body) {
|
|
3465
3614
|
await this.client.request({
|
|
@@ -4184,6 +4333,7 @@ exports.SeamHttpClientSessions = SeamHttpClientSessions;
|
|
|
4184
4333
|
exports.SeamHttpConnectWebviews = SeamHttpConnectWebviews;
|
|
4185
4334
|
exports.SeamHttpConnectedAccounts = SeamHttpConnectedAccounts;
|
|
4186
4335
|
exports.SeamHttpDevices = SeamHttpDevices;
|
|
4336
|
+
exports.SeamHttpDevicesSimulate = SeamHttpDevicesSimulate;
|
|
4187
4337
|
exports.SeamHttpDevicesUnmanaged = SeamHttpDevicesUnmanaged;
|
|
4188
4338
|
exports.SeamHttpEvents = SeamHttpEvents;
|
|
4189
4339
|
exports.SeamHttpInvalidInputError = SeamHttpInvalidInputError;
|