@seamapi/http 0.29.0 → 0.30.1
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/LICENSE.txt +1 -1
- package/dist/connect.cjs +40 -66
- package/dist/connect.cjs.map +1 -1
- package/dist/connect.d.cts +47 -43
- package/lib/seam/connect/routes/access-codes-unmanaged.d.ts +2 -2
- package/lib/seam/connect/routes/access-codes-unmanaged.js.map +1 -1
- package/lib/seam/connect/routes/access-codes.d.ts +2 -2
- package/lib/seam/connect/routes/access-codes.js.map +1 -1
- package/lib/seam/connect/routes/acs-access-groups.d.ts +2 -2
- package/lib/seam/connect/routes/acs-access-groups.js.map +1 -1
- package/lib/seam/connect/routes/acs-credentials.d.ts +6 -2
- package/lib/seam/connect/routes/acs-credentials.js +8 -0
- package/lib/seam/connect/routes/acs-credentials.js.map +1 -1
- package/lib/seam/connect/routes/acs-users.d.ts +6 -6
- package/lib/seam/connect/routes/acs-users.js.map +1 -1
- package/lib/seam/connect/routes/client-sessions.d.ts +4 -4
- package/lib/seam/connect/routes/client-sessions.js.map +1 -1
- package/lib/seam/connect/routes/connect-webviews.d.ts +2 -2
- package/lib/seam/connect/routes/connect-webviews.js.map +1 -1
- package/lib/seam/connect/routes/connected-accounts.d.ts +2 -2
- package/lib/seam/connect/routes/connected-accounts.js.map +1 -1
- package/lib/seam/connect/routes/devices-simulate.d.ts +2 -2
- package/lib/seam/connect/routes/devices-simulate.js.map +1 -1
- package/lib/seam/connect/routes/devices.d.ts +2 -2
- package/lib/seam/connect/routes/devices.js.map +1 -1
- package/lib/seam/connect/routes/noise-sensors-noise-thresholds.d.ts +2 -2
- package/lib/seam/connect/routes/noise-sensors-noise-thresholds.js.map +1 -1
- package/lib/seam/connect/routes/phones.d.ts +2 -2
- package/lib/seam/connect/routes/phones.js.map +1 -1
- package/lib/seam/connect/routes/thermostats-climate-setting-schedules.d.ts +2 -2
- package/lib/seam/connect/routes/thermostats-climate-setting-schedules.js.map +1 -1
- package/lib/seam/connect/routes/user-identities-enrollment-automations.d.ts +2 -2
- package/lib/seam/connect/routes/user-identities-enrollment-automations.js.map +1 -1
- package/lib/seam/connect/routes/user-identities.d.ts +6 -6
- package/lib/seam/connect/routes/user-identities.js.map +1 -1
- package/lib/seam/connect/routes/webhooks.d.ts +2 -2
- package/lib/seam/connect/routes/webhooks.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +6 -6
- package/src/lib/seam/connect/routes/access-codes-unmanaged.ts +2 -2
- package/src/lib/seam/connect/routes/access-codes.ts +2 -2
- package/src/lib/seam/connect/routes/acs-access-groups.ts +2 -2
- package/src/lib/seam/connect/routes/acs-credentials.ts +25 -2
- package/src/lib/seam/connect/routes/acs-users.ts +6 -6
- package/src/lib/seam/connect/routes/client-sessions.ts +4 -4
- package/src/lib/seam/connect/routes/connect-webviews.ts +2 -2
- package/src/lib/seam/connect/routes/connected-accounts.ts +4 -2
- package/src/lib/seam/connect/routes/devices-simulate.ts +2 -2
- package/src/lib/seam/connect/routes/devices.ts +2 -2
- package/src/lib/seam/connect/routes/noise-sensors-noise-thresholds.ts +2 -2
- package/src/lib/seam/connect/routes/phones.ts +2 -2
- package/src/lib/seam/connect/routes/thermostats-climate-setting-schedules.ts +2 -2
- package/src/lib/seam/connect/routes/user-identities-enrollment-automations.ts +2 -2
- package/src/lib/seam/connect/routes/user-identities.ts +6 -6
- package/src/lib/seam/connect/routes/webhooks.ts +2 -2
- package/src/lib/version.ts +1 -1
package/LICENSE.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
The MIT License (MIT)
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2021-
|
|
3
|
+
Copyright (c) 2021-2024 Seam Labs, Inc.
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
6
|
this software and associated documentation files (the "Software"), to deal in
|
package/dist/connect.cjs
CHANGED
|
@@ -11,24 +11,13 @@ var axios__default = /*#__PURE__*/_interopDefault(axios);
|
|
|
11
11
|
var axiosBetterStacktrace__default = /*#__PURE__*/_interopDefault(axiosBetterStacktrace);
|
|
12
12
|
var axiosRetry__default = /*#__PURE__*/_interopDefault(axiosRetry);
|
|
13
13
|
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
throw TypeError("Cannot " + msg);
|
|
17
|
-
};
|
|
18
|
-
var __privateGet = (obj, member, getter) => {
|
|
19
|
-
__accessCheck(obj, member, "read from private field");
|
|
20
|
-
return getter ? getter.call(obj) : member.get(obj);
|
|
21
|
-
};
|
|
22
|
-
var __privateAdd = (obj, member, value) => {
|
|
23
|
-
if (member.has(obj))
|
|
24
|
-
throw TypeError("Cannot add the same private member more than once");
|
|
25
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
26
|
-
};
|
|
27
|
-
var __privateSet = (obj, member, value, setter) => {
|
|
28
|
-
__accessCheck(obj, member, "write to private field");
|
|
29
|
-
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
30
|
-
return value;
|
|
14
|
+
var __typeError = (msg) => {
|
|
15
|
+
throw TypeError(msg);
|
|
31
16
|
};
|
|
17
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
18
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
19
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
20
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
|
|
32
21
|
|
|
33
22
|
// src/lib/lts-version.ts
|
|
34
23
|
var seamApiLtsVersion = "1.0.0";
|
|
@@ -46,10 +35,8 @@ var sdkHeaders = {
|
|
|
46
35
|
};
|
|
47
36
|
var parseOptions = (apiKeyOrOptions) => {
|
|
48
37
|
const options = getNormalizedOptions(apiKeyOrOptions);
|
|
49
|
-
if (isSeamHttpOptionsWithClient(options))
|
|
50
|
-
|
|
51
|
-
if (isSeamHttpMultiWorkspaceOptionsWithClient(options))
|
|
52
|
-
return options;
|
|
38
|
+
if (isSeamHttpOptionsWithClient(options)) return options;
|
|
39
|
+
if (isSeamHttpMultiWorkspaceOptionsWithClient(options)) return options;
|
|
53
40
|
return {
|
|
54
41
|
...options,
|
|
55
42
|
axiosOptions: {
|
|
@@ -129,10 +116,8 @@ var isSeamHttpRequestOption = (key) => {
|
|
|
129
116
|
// src/lib/seam/connect/options.ts
|
|
130
117
|
var isSeamHttpMultiWorkspaceOptionsWithClient = (options) => isSeamHttpOptionsWithClient(options);
|
|
131
118
|
var isSeamHttpOptionsWithClient = (options) => {
|
|
132
|
-
if (!("client" in options))
|
|
133
|
-
|
|
134
|
-
if (options.client == null)
|
|
135
|
-
return false;
|
|
119
|
+
if (!("client" in options)) return false;
|
|
120
|
+
if (options.client == null) return false;
|
|
136
121
|
const keys = Object.keys(options).filter((k) => k !== "client");
|
|
137
122
|
if (keys.filter((k) => !isSeamHttpRequestOption(k)).length > 0) {
|
|
138
123
|
throw new SeamHttpInvalidOptionsError(
|
|
@@ -144,10 +129,8 @@ var isSeamHttpOptionsWithClient = (options) => {
|
|
|
144
129
|
return true;
|
|
145
130
|
};
|
|
146
131
|
var isSeamHttpOptionsWithApiKey = (options) => {
|
|
147
|
-
if (!("apiKey" in options))
|
|
148
|
-
|
|
149
|
-
if (options.apiKey == null)
|
|
150
|
-
return false;
|
|
132
|
+
if (!("apiKey" in options)) return false;
|
|
133
|
+
if (options.apiKey == null) return false;
|
|
151
134
|
if ("clientSessionToken" in options && options.clientSessionToken != null) {
|
|
152
135
|
throw new SeamHttpInvalidOptionsError(
|
|
153
136
|
"The clientSessionToken option cannot be used with the apiKey option"
|
|
@@ -166,10 +149,8 @@ var isSeamHttpOptionsWithApiKey = (options) => {
|
|
|
166
149
|
return true;
|
|
167
150
|
};
|
|
168
151
|
var isSeamHttpOptionsWithClientSessionToken = (options) => {
|
|
169
|
-
if (!("clientSessionToken" in options))
|
|
170
|
-
|
|
171
|
-
if (options.clientSessionToken == null)
|
|
172
|
-
return false;
|
|
152
|
+
if (!("clientSessionToken" in options)) return false;
|
|
153
|
+
if (options.clientSessionToken == null) return false;
|
|
173
154
|
if ("apiKey" in options && options.apiKey != null) {
|
|
174
155
|
throw new SeamHttpInvalidOptionsError(
|
|
175
156
|
"The apiKey option cannot be used with the clientSessionToken option"
|
|
@@ -188,10 +169,8 @@ var isSeamHttpOptionsWithClientSessionToken = (options) => {
|
|
|
188
169
|
return true;
|
|
189
170
|
};
|
|
190
171
|
var isSeamHttpMultiWorkspaceOptionsWithConsoleSessionToken = (options) => {
|
|
191
|
-
if (!("consoleSessionToken" in options))
|
|
192
|
-
|
|
193
|
-
if (options.consoleSessionToken == null)
|
|
194
|
-
return false;
|
|
172
|
+
if (!("consoleSessionToken" in options)) return false;
|
|
173
|
+
if (options.consoleSessionToken == null) return false;
|
|
195
174
|
if ("apiKey" in options && options.apiKey != null) {
|
|
196
175
|
throw new SeamHttpInvalidOptionsError(
|
|
197
176
|
"The apiKey option cannot be used with the consoleSessionToken option"
|
|
@@ -221,10 +200,8 @@ var isSeamHttpOptionsWithConsoleSessionToken = (options) => {
|
|
|
221
200
|
return true;
|
|
222
201
|
};
|
|
223
202
|
var isSeamHttpMultiWorkspaceOptionsWithPersonalAccessToken = (options) => {
|
|
224
|
-
if (!("personalAccessToken" in options))
|
|
225
|
-
|
|
226
|
-
if (options.personalAccessToken == null)
|
|
227
|
-
return false;
|
|
203
|
+
if (!("personalAccessToken" in options)) return false;
|
|
204
|
+
if (options.personalAccessToken == null) return false;
|
|
228
205
|
if ("apiKey" in options && options.apiKey != null) {
|
|
229
206
|
throw new SeamHttpInvalidOptionsError(
|
|
230
207
|
"The apiKey option cannot be used with the personalAccessToken option"
|
|
@@ -479,8 +456,7 @@ var SeamHttpApiError = class extends Error {
|
|
|
479
456
|
this.code = type;
|
|
480
457
|
this.statusCode = statusCode;
|
|
481
458
|
this.requestId = requestId;
|
|
482
|
-
if (data != null)
|
|
483
|
-
this.data = data;
|
|
459
|
+
if (data != null) this.data = data;
|
|
484
460
|
}
|
|
485
461
|
};
|
|
486
462
|
var isSeamHttpApiError = (error) => {
|
|
@@ -513,30 +489,24 @@ var isSeamHttpInvalidInputError = (error) => {
|
|
|
513
489
|
|
|
514
490
|
// src/lib/seam/connect/error-interceptor.ts
|
|
515
491
|
var errorInterceptor = async (err) => {
|
|
516
|
-
if (!axios.isAxiosError(err))
|
|
517
|
-
throw err;
|
|
492
|
+
if (!axios.isAxiosError(err)) throw err;
|
|
518
493
|
const { response } = err;
|
|
519
494
|
const status = response?.status;
|
|
520
495
|
const requestId = getRequestId(err);
|
|
521
|
-
if (status == null)
|
|
522
|
-
throw err;
|
|
496
|
+
if (status == null) throw err;
|
|
523
497
|
if (status === 401) {
|
|
524
498
|
throw new SeamHttpUnauthorizedError(requestId);
|
|
525
499
|
}
|
|
526
|
-
if (!isApiErrorResponse(response))
|
|
527
|
-
throw err;
|
|
500
|
+
if (!isApiErrorResponse(response)) throw err;
|
|
528
501
|
const { type } = response.data.error;
|
|
529
502
|
const args = [response.data.error, status, requestId];
|
|
530
|
-
if (type === "invalid_input")
|
|
531
|
-
throw new SeamHttpInvalidInputError(...args);
|
|
503
|
+
if (type === "invalid_input") throw new SeamHttpInvalidInputError(...args);
|
|
532
504
|
throw new SeamHttpApiError(...args);
|
|
533
505
|
};
|
|
534
506
|
var isApiErrorResponse = (response) => {
|
|
535
|
-
if (response == null)
|
|
536
|
-
return false;
|
|
507
|
+
if (response == null) return false;
|
|
537
508
|
const { headers, data } = response;
|
|
538
|
-
if (headers == null)
|
|
539
|
-
return false;
|
|
509
|
+
if (headers == null) return false;
|
|
540
510
|
const contentType = headers["Content-Type"];
|
|
541
511
|
if (typeof contentType === "string" && !contentType.startsWith("application/json")) {
|
|
542
512
|
return false;
|
|
@@ -548,11 +518,9 @@ var isApiErrorResponse = (response) => {
|
|
|
548
518
|
};
|
|
549
519
|
var getRequestId = (err) => {
|
|
550
520
|
const headers = err.response?.headers;
|
|
551
|
-
if (headers == null)
|
|
552
|
-
return "";
|
|
521
|
+
if (headers == null) return "";
|
|
553
522
|
const requestId = headers["seam-request-id"];
|
|
554
|
-
if (requestId == null)
|
|
555
|
-
return "";
|
|
523
|
+
if (requestId == null) return "";
|
|
556
524
|
return requestId;
|
|
557
525
|
};
|
|
558
526
|
var createClient = (options) => {
|
|
@@ -598,8 +566,7 @@ var resolveActionAttempt = async (actionAttempt, actionAttempts, { timeout = 5e3
|
|
|
598
566
|
timeoutPromise
|
|
599
567
|
]);
|
|
600
568
|
} finally {
|
|
601
|
-
if (timeoutRef != null)
|
|
602
|
-
globalThis.clearTimeout(timeoutRef);
|
|
569
|
+
if (timeoutRef != null) globalThis.clearTimeout(timeoutRef);
|
|
603
570
|
}
|
|
604
571
|
};
|
|
605
572
|
var pollActionAttempt = async (actionAttempt, actionAttempts, options) => {
|
|
@@ -654,11 +621,12 @@ var SeamActionAttemptTimeoutError = class extends SeamActionAttemptError {
|
|
|
654
621
|
var isSuccessfulActionAttempt = (actionAttempt) => actionAttempt.status === "success";
|
|
655
622
|
var isFailedActionAttempt = (actionAttempt) => actionAttempt.status === "error";
|
|
656
623
|
var _a, _parent, _config;
|
|
624
|
+
_a = Symbol.toStringTag;
|
|
657
625
|
var SeamHttpRequest = class {
|
|
658
626
|
constructor(parent, config) {
|
|
659
627
|
this[_a] = "SeamHttpRequest";
|
|
660
|
-
__privateAdd(this, _parent
|
|
661
|
-
__privateAdd(this, _config
|
|
628
|
+
__privateAdd(this, _parent);
|
|
629
|
+
__privateAdd(this, _config);
|
|
662
630
|
__privateSet(this, _parent, parent);
|
|
663
631
|
__privateSet(this, _config, config);
|
|
664
632
|
}
|
|
@@ -717,14 +685,12 @@ var SeamHttpRequest = class {
|
|
|
717
685
|
return await this.execute().finally(onfinally);
|
|
718
686
|
}
|
|
719
687
|
};
|
|
720
|
-
_a = Symbol.toStringTag;
|
|
721
688
|
_parent = new WeakMap();
|
|
722
689
|
_config = new WeakMap();
|
|
723
690
|
var getUrlPrefix = (input) => {
|
|
724
691
|
if (canParseUrl(input)) {
|
|
725
692
|
const url = new URL(input).toString();
|
|
726
|
-
if (url.endsWith("/"))
|
|
727
|
-
return url.slice(0, -1);
|
|
693
|
+
if (url.endsWith("/")) return url.slice(0, -1);
|
|
728
694
|
return url;
|
|
729
695
|
}
|
|
730
696
|
if (globalThis.location != null) {
|
|
@@ -1646,6 +1612,14 @@ var SeamHttpAcsCredentials = class _SeamHttpAcsCredentials {
|
|
|
1646
1612
|
responseKey: "acs_credentials"
|
|
1647
1613
|
});
|
|
1648
1614
|
}
|
|
1615
|
+
listAccessibleEntrances(body) {
|
|
1616
|
+
return new SeamHttpRequest(this, {
|
|
1617
|
+
path: "/acs/credentials/list_accessible_entrances",
|
|
1618
|
+
method: "post",
|
|
1619
|
+
body,
|
|
1620
|
+
responseKey: "acs_entrances"
|
|
1621
|
+
});
|
|
1622
|
+
}
|
|
1649
1623
|
unassign(body) {
|
|
1650
1624
|
return new SeamHttpRequest(this, {
|
|
1651
1625
|
path: "/acs/credentials/unassign",
|