@seamapi/http 0.5.0 → 0.7.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.
Files changed (51) hide show
  1. package/README.md +2 -2
  2. package/dist/connect.cjs +307 -124
  3. package/dist/connect.cjs.map +1 -1
  4. package/dist/connect.d.cts +76 -12
  5. package/lib/seam/connect/auth.js +13 -9
  6. package/lib/seam/connect/auth.js.map +1 -1
  7. package/lib/seam/connect/index.d.ts +2 -0
  8. package/lib/seam/connect/index.js +2 -0
  9. package/lib/seam/connect/index.js.map +1 -1
  10. package/lib/seam/connect/options.d.ts +15 -0
  11. package/lib/seam/connect/options.js +23 -8
  12. package/lib/seam/connect/options.js.map +1 -1
  13. package/lib/seam/connect/parse-options.d.ts +3 -3
  14. package/lib/seam/connect/parse-options.js +3 -1
  15. package/lib/seam/connect/parse-options.js.map +1 -1
  16. package/lib/seam/connect/routes/acs-access-groups.d.ts +0 -9
  17. package/lib/seam/connect/routes/acs-access-groups.js +0 -22
  18. package/lib/seam/connect/routes/acs-access-groups.js.map +1 -1
  19. package/lib/seam/connect/routes/acs-credentials.d.ts +6 -0
  20. package/lib/seam/connect/routes/acs-credentials.js +14 -0
  21. package/lib/seam/connect/routes/acs-credentials.js.map +1 -1
  22. package/lib/seam/connect/routes/client-sessions.d.ts +3 -0
  23. package/lib/seam/connect/routes/client-sessions.js +7 -0
  24. package/lib/seam/connect/routes/client-sessions.js.map +1 -1
  25. package/lib/seam/connect/routes/index.d.ts +1 -0
  26. package/lib/seam/connect/routes/index.js +1 -0
  27. package/lib/seam/connect/routes/index.js.map +1 -1
  28. package/lib/seam/connect/routes/user-identities.d.ts +38 -0
  29. package/lib/seam/connect/routes/user-identities.js +121 -0
  30. package/lib/seam/connect/routes/user-identities.js.map +1 -0
  31. package/lib/seam/connect/seam-http-multi-workspace.d.ts +11 -0
  32. package/lib/seam/connect/seam-http-multi-workspace.js +35 -0
  33. package/lib/seam/connect/seam-http-multi-workspace.js.map +1 -0
  34. package/lib/seam/connect/seam-http.d.ts +2 -1
  35. package/lib/seam/connect/seam-http.js +4 -1
  36. package/lib/seam/connect/seam-http.js.map +1 -1
  37. package/lib/version.d.ts +1 -1
  38. package/lib/version.js +1 -1
  39. package/package.json +2 -2
  40. package/src/lib/seam/connect/auth.ts +28 -10
  41. package/src/lib/seam/connect/index.ts +2 -0
  42. package/src/lib/seam/connect/options.ts +63 -17
  43. package/src/lib/seam/connect/parse-options.ts +6 -1
  44. package/src/lib/seam/connect/routes/acs-access-groups.ts +0 -48
  45. package/src/lib/seam/connect/routes/acs-credentials.ts +30 -0
  46. package/src/lib/seam/connect/routes/client-sessions.ts +15 -0
  47. package/src/lib/seam/connect/routes/index.ts +1 -0
  48. package/src/lib/seam/connect/routes/user-identities.ts +261 -0
  49. package/src/lib/seam/connect/seam-http-multi-workspace.ts +77 -0
  50. package/src/lib/seam/connect/seam-http.ts +5 -0
  51. package/src/lib/version.ts +1 -1
package/README.md CHANGED
@@ -38,7 +38,7 @@ $ npm install @seamapi/http
38
38
  ## Usage
39
39
 
40
40
  ```ts
41
- import { SeamHttp } from '@seamapi/http'
41
+ import { SeamHttp } from '@seamapi/http/connect'
42
42
 
43
43
  const seam = new SeamHttp('your-api-key')
44
44
  const devices = await seam.devices.list()
@@ -213,7 +213,7 @@ Options are deep merged with the default options.
213
213
  The Axios client is exposed and may be used or configured directly:
214
214
 
215
215
  ```ts
216
- import { SeamHttp, DevicesListResponse } from '@seamapi/http'
216
+ import { SeamHttp, DevicesListResponse } from '@seamapi/http/connect'
217
217
 
218
218
  const seam = new SeamHttp()
219
219
 
package/dist/connect.cjs CHANGED
@@ -10,90 +10,8 @@ var axios__default = /*#__PURE__*/_interopDefault(axios);
10
10
  var axiosBetterStacktrace__default = /*#__PURE__*/_interopDefault(axiosBetterStacktrace);
11
11
  var axiosRetry__default = /*#__PURE__*/_interopDefault(axiosRetry);
12
12
 
13
- // src/lib/seam/connect/error-interceptor.ts
14
-
15
- // src/lib/seam/connect/seam-http-error.ts
16
- var SeamHttpApiError = class extends Error {
17
- constructor(error, statusCode, requestId) {
18
- const { type, message, data } = error;
19
- super(message);
20
- this.name = this.constructor.name;
21
- Error.captureStackTrace(this, this.constructor);
22
- this.code = type;
23
- this.statusCode = statusCode;
24
- this.requestId = requestId;
25
- if (data != null)
26
- this.data = data;
27
- }
28
- };
29
- var isSeamHttpApiError = (error) => {
30
- return error instanceof SeamHttpApiError;
31
- };
32
- var SeamHttpUnauthorizedError = class extends SeamHttpApiError {
33
- constructor(requestId) {
34
- const type = "unauthorized";
35
- const status = 401;
36
- super({ type, message: "Unauthorized" }, status, requestId);
37
- this.name = this.constructor.name;
38
- Error.captureStackTrace(this, this.constructor);
39
- this.code = type;
40
- this.statusCode = status;
41
- this.requestId = requestId;
42
- }
43
- };
44
- var isSeamHttpUnauthorizedError = (error) => {
45
- return error instanceof SeamHttpUnauthorizedError;
46
- };
47
- var SeamHttpInvalidInputError = class extends SeamHttpApiError {
48
- constructor(error, statusCode, requestId) {
49
- super(error, statusCode, requestId);
50
- this.name = this.constructor.name;
51
- Error.captureStackTrace(this, this.constructor);
52
- this.code = "invalid_input";
53
- }
54
- };
55
- var isSeamHttpInvalidInputError = (error) => {
56
- return error instanceof SeamHttpInvalidInputError;
57
- };
58
-
59
- // src/lib/seam/connect/error-interceptor.ts
60
- var errorInterceptor = async (err) => {
61
- if (!axios.isAxiosError(err))
62
- throw err;
63
- const { response } = err;
64
- const status = response?.status;
65
- const headers = response?.headers;
66
- const requestId = headers?.["seam-request-id"] ?? "";
67
- if (status == null)
68
- throw err;
69
- if (status === 401) {
70
- throw new SeamHttpUnauthorizedError(requestId);
71
- }
72
- if (!isApiErrorResponse(response))
73
- throw err;
74
- const { type } = response.data.error;
75
- const args = [response.data.error, status, requestId];
76
- if (type === "invalid_input")
77
- throw new SeamHttpInvalidInputError(...args);
78
- throw new SeamHttpApiError(...args);
79
- };
80
- var isApiErrorResponse = (response) => {
81
- if (response == null)
82
- return false;
83
- const { headers, data } = response;
84
- if (headers == null)
85
- return false;
86
- const contentType = headers["content-type"];
87
- if (typeof contentType === "string" && !contentType.startsWith("application/json")) {
88
- return false;
89
- }
90
- if (typeof data === "object" && data != null) {
91
- return "error" in data && typeof data.error === "object" && data.error != null && "type" in data.error && typeof data.error.type === "string";
92
- }
93
- return false;
94
- };
95
-
96
13
  // src/lib/seam/connect/options.ts
14
+ var isSeamHttpMultiWorkspaceOptionsWithClient = (options) => isSeamHttpOptionsWithClient(options);
97
15
  var isSeamHttpOptionsWithClient = (options) => {
98
16
  if (!("client" in options))
99
17
  return false;
@@ -153,16 +71,11 @@ var isSeamHttpOptionsWithClientSessionToken = (options) => {
153
71
  }
154
72
  return true;
155
73
  };
156
- var isSeamHttpOptionsWithConsoleSessionToken = (options) => {
74
+ var isSeamHttpMultiWorkspaceOptionsWithConsoleSessionToken = (options) => {
157
75
  if (!("consoleSessionToken" in options))
158
76
  return false;
159
77
  if (options.consoleSessionToken == null)
160
78
  return false;
161
- if (!("workspaceId" in options) || options.workspaceId == null) {
162
- throw new SeamHttpInvalidOptionsError(
163
- "Must pass a workspaceId when using a consoleSessionToken"
164
- );
165
- }
166
79
  if ("apiKey" in options && options.apiKey != null) {
167
80
  throw new SeamHttpInvalidOptionsError(
168
81
  "The apiKey option cannot be used with the consoleSessionToken option"
@@ -180,16 +93,22 @@ var isSeamHttpOptionsWithConsoleSessionToken = (options) => {
180
93
  }
181
94
  return true;
182
95
  };
183
- var isSeamHttpOptionsWithPersonalAccessToken = (options) => {
184
- if (!("personalAccessToken" in options))
185
- return false;
186
- if (options.personalAccessToken == null)
96
+ var isSeamHttpOptionsWithConsoleSessionToken = (options) => {
97
+ if (!isSeamHttpMultiWorkspaceOptionsWithConsoleSessionToken(options)) {
187
98
  return false;
99
+ }
188
100
  if (!("workspaceId" in options) || options.workspaceId == null) {
189
101
  throw new SeamHttpInvalidOptionsError(
190
- "Must pass a workspaceId when using a personalAccessToken"
102
+ "Must pass a workspaceId when using a consoleSessionToken"
191
103
  );
192
104
  }
105
+ return true;
106
+ };
107
+ var isSeamHttpMultiWorkspaceOptionsWithPersonalAccessToken = (options) => {
108
+ if (!("personalAccessToken" in options))
109
+ return false;
110
+ if (options.personalAccessToken == null)
111
+ return false;
193
112
  if ("apiKey" in options && options.apiKey != null) {
194
113
  throw new SeamHttpInvalidOptionsError(
195
114
  "The apiKey option cannot be used with the personalAccessToken option"
@@ -207,6 +126,17 @@ var isSeamHttpOptionsWithPersonalAccessToken = (options) => {
207
126
  }
208
127
  return true;
209
128
  };
129
+ var isSeamHttpOptionsWithPersonalAccessToken = (options) => {
130
+ if (!isSeamHttpMultiWorkspaceOptionsWithPersonalAccessToken(options)) {
131
+ return false;
132
+ }
133
+ if (!("workspaceId" in options) || options.workspaceId == null) {
134
+ throw new SeamHttpInvalidOptionsError(
135
+ "Must pass a workspaceId when using a personalAccessToken"
136
+ );
137
+ }
138
+ return true;
139
+ };
210
140
  var SeamHttpInvalidOptionsError = class extends Error {
211
141
  constructor(message) {
212
142
  super(`SeamHttp received invalid options: ${message}`);
@@ -214,6 +144,8 @@ var SeamHttpInvalidOptionsError = class extends Error {
214
144
  Error.captureStackTrace(this, this.constructor);
215
145
  }
216
146
  };
147
+ var SeamHttpMultiWorkspaceInvalidOptionsError = class extends SeamHttpInvalidOptionsError {
148
+ };
217
149
 
218
150
  // src/lib/seam/connect/auth.ts
219
151
  var getAuthHeaders = (options) => {
@@ -226,10 +158,10 @@ var getAuthHeaders = (options) => {
226
158
  if (isSeamHttpOptionsWithClientSessionToken(options)) {
227
159
  return getAuthHeadersForClientSessionToken(options);
228
160
  }
229
- if (isSeamHttpOptionsWithConsoleSessionToken(options)) {
161
+ if (isSeamHttpMultiWorkspaceOptionsWithConsoleSessionToken(options) || isSeamHttpOptionsWithConsoleSessionToken(options)) {
230
162
  return getAuthHeadersForConsoleSessionToken(options);
231
163
  }
232
- if (isSeamHttpOptionsWithPersonalAccessToken(options)) {
164
+ if (isSeamHttpMultiWorkspaceOptionsWithPersonalAccessToken(options) || isSeamHttpOptionsWithPersonalAccessToken(options)) {
233
165
  return getAuthHeadersForPersonalAccessToken(options);
234
166
  }
235
167
  throw new SeamHttpInvalidOptionsError(
@@ -238,8 +170,8 @@ var getAuthHeaders = (options) => {
238
170
  "an apiKey,",
239
171
  "clientSessionToken,",
240
172
  "publishableKey,",
241
- "consoleSessionToken with a workspaceId",
242
- "or personalAccessToken with a workspaceId"
173
+ "consoleSessionToken",
174
+ "or personalAccessToken"
243
175
  ].join(" ")
244
176
  );
245
177
  };
@@ -303,8 +235,9 @@ var getAuthHeadersForClientSessionToken = ({
303
235
  };
304
236
  var getAuthHeadersForConsoleSessionToken = ({
305
237
  consoleSessionToken,
306
- workspaceId
238
+ ...options
307
239
  }) => {
240
+ const workspaceId = "workspaceId" in options ? options.workspaceId : void 0;
308
241
  if (isAccessToken(consoleSessionToken)) {
309
242
  throw new SeamHttpInvalidTokenError(
310
243
  "An Access Token cannot be used as a consoleSessionToken"
@@ -327,13 +260,14 @@ var getAuthHeadersForConsoleSessionToken = ({
327
260
  }
328
261
  return {
329
262
  authorization: `Bearer ${consoleSessionToken}`,
330
- "seam-workspace-id": workspaceId
263
+ ...workspaceId != null ? { "seam-workspace-id": workspaceId } : {}
331
264
  };
332
265
  };
333
266
  var getAuthHeadersForPersonalAccessToken = ({
334
267
  personalAccessToken,
335
- workspaceId
268
+ ...options
336
269
  }) => {
270
+ const workspaceId = "workspaceId" in options ? options.workspaceId : void 0;
337
271
  if (isJwt(personalAccessToken)) {
338
272
  throw new SeamHttpInvalidTokenError(
339
273
  "A JWT cannot be used as a personalAccessToken"
@@ -356,7 +290,7 @@ var getAuthHeadersForPersonalAccessToken = ({
356
290
  }
357
291
  return {
358
292
  authorization: `Bearer ${personalAccessToken}`,
359
- "seam-workspace-id": workspaceId
293
+ ...workspaceId != null ? { "seam-workspace-id": workspaceId } : {}
360
294
  };
361
295
  };
362
296
  var getAuthHeadersForPublishableKey = (publishableKey) => {
@@ -416,6 +350,87 @@ var isSeamToken = (token) => token.startsWith(tokenPrefix);
416
350
  var isPublishableKey = (token) => token.startsWith(publishableKeyTokenPrefix);
417
351
  var isEmail = (value) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value);
418
352
 
353
+ // src/lib/seam/connect/seam-http-error.ts
354
+ var SeamHttpApiError = class extends Error {
355
+ constructor(error, statusCode, requestId) {
356
+ const { type, message, data } = error;
357
+ super(message);
358
+ this.name = this.constructor.name;
359
+ Error.captureStackTrace(this, this.constructor);
360
+ this.code = type;
361
+ this.statusCode = statusCode;
362
+ this.requestId = requestId;
363
+ if (data != null)
364
+ this.data = data;
365
+ }
366
+ };
367
+ var isSeamHttpApiError = (error) => {
368
+ return error instanceof SeamHttpApiError;
369
+ };
370
+ var SeamHttpUnauthorizedError = class extends SeamHttpApiError {
371
+ constructor(requestId) {
372
+ const type = "unauthorized";
373
+ const status = 401;
374
+ super({ type, message: "Unauthorized" }, status, requestId);
375
+ this.name = this.constructor.name;
376
+ Error.captureStackTrace(this, this.constructor);
377
+ this.code = type;
378
+ this.statusCode = status;
379
+ this.requestId = requestId;
380
+ }
381
+ };
382
+ var isSeamHttpUnauthorizedError = (error) => {
383
+ return error instanceof SeamHttpUnauthorizedError;
384
+ };
385
+ var SeamHttpInvalidInputError = class extends SeamHttpApiError {
386
+ constructor(error, statusCode, requestId) {
387
+ super(error, statusCode, requestId);
388
+ this.name = this.constructor.name;
389
+ Error.captureStackTrace(this, this.constructor);
390
+ this.code = "invalid_input";
391
+ }
392
+ };
393
+ var isSeamHttpInvalidInputError = (error) => {
394
+ return error instanceof SeamHttpInvalidInputError;
395
+ };
396
+
397
+ // src/lib/seam/connect/error-interceptor.ts
398
+ var errorInterceptor = async (err) => {
399
+ if (!axios.isAxiosError(err))
400
+ throw err;
401
+ const { response } = err;
402
+ const status = response?.status;
403
+ const headers = response?.headers;
404
+ const requestId = headers?.["seam-request-id"] ?? "";
405
+ if (status == null)
406
+ throw err;
407
+ if (status === 401) {
408
+ throw new SeamHttpUnauthorizedError(requestId);
409
+ }
410
+ if (!isApiErrorResponse(response))
411
+ throw err;
412
+ const { type } = response.data.error;
413
+ const args = [response.data.error, status, requestId];
414
+ if (type === "invalid_input")
415
+ throw new SeamHttpInvalidInputError(...args);
416
+ throw new SeamHttpApiError(...args);
417
+ };
418
+ var isApiErrorResponse = (response) => {
419
+ if (response == null)
420
+ return false;
421
+ const { headers, data } = response;
422
+ if (headers == null)
423
+ return false;
424
+ const contentType = headers["content-type"];
425
+ if (typeof contentType === "string" && !contentType.startsWith("application/json")) {
426
+ return false;
427
+ }
428
+ if (typeof data === "object" && data != null) {
429
+ return "error" in data && typeof data.error === "object" && data.error != null && "type" in data.error && typeof data.error.type === "string";
430
+ }
431
+ return false;
432
+ };
433
+
419
434
  // src/lib/params-serializer.ts
420
435
  var paramsSerializer = (params) => {
421
436
  const searchParams = new URLSearchParams();
@@ -497,6 +512,8 @@ var parseOptions = (apiKeyOrOptions) => {
497
512
  const options = getNormalizedOptions(apiKeyOrOptions);
498
513
  if (isSeamHttpOptionsWithClient(options))
499
514
  return options;
515
+ if (isSeamHttpMultiWorkspaceOptionsWithClient(options))
516
+ return options;
500
517
  return {
501
518
  axiosOptions: {
502
519
  baseURL: options.endpoint ?? getEndpointFromEnv() ?? defaultEndpoint,
@@ -635,6 +652,13 @@ var SeamHttpClientSessions = class _SeamHttpClientSessions {
635
652
  });
636
653
  return data.client_sessions;
637
654
  }
655
+ async revoke(body) {
656
+ await this.client.request({
657
+ url: "/client_sessions/revoke",
658
+ method: "post",
659
+ data: body
660
+ });
661
+ }
638
662
  };
639
663
 
640
664
  // src/lib/seam/connect/routes/access-codes-unmanaged.ts
@@ -919,21 +943,6 @@ var SeamHttpAcsAccessGroups = class _SeamHttpAcsAccessGroups {
919
943
  data: body
920
944
  });
921
945
  }
922
- async create(body) {
923
- const { data } = await this.client.request({
924
- url: "/acs/access_groups/create",
925
- method: "post",
926
- data: body
927
- });
928
- return data.acs_access_group;
929
- }
930
- async delete(body) {
931
- await this.client.request({
932
- url: "/acs/access_groups/delete",
933
- method: "post",
934
- data: body
935
- });
936
- }
937
946
  async get(body) {
938
947
  const { data } = await this.client.request({
939
948
  url: "/acs/access_groups/get",
@@ -965,13 +974,6 @@ var SeamHttpAcsAccessGroups = class _SeamHttpAcsAccessGroups {
965
974
  data: body
966
975
  });
967
976
  }
968
- async update(body) {
969
- await this.client.request({
970
- url: "/acs/access_groups/update",
971
- method: "post",
972
- data: body
973
- });
974
- }
975
977
  };
976
978
 
977
979
  // src/lib/seam/connect/routes/acs-credentials.ts
@@ -1029,6 +1031,13 @@ var SeamHttpAcsCredentials = class _SeamHttpAcsCredentials {
1029
1031
  }
1030
1032
  return new _SeamHttpAcsCredentials(constructorOptions);
1031
1033
  }
1034
+ async assign(body) {
1035
+ await this.client.request({
1036
+ url: "/acs/credentials/assign",
1037
+ method: "post",
1038
+ data: body
1039
+ });
1040
+ }
1032
1041
  async create(body) {
1033
1042
  const { data } = await this.client.request({
1034
1043
  url: "/acs/credentials/create",
@@ -1060,6 +1069,13 @@ var SeamHttpAcsCredentials = class _SeamHttpAcsCredentials {
1060
1069
  });
1061
1070
  return data.acs_credentials;
1062
1071
  }
1072
+ async unassign(body) {
1073
+ await this.client.request({
1074
+ url: "/acs/credentials/unassign",
1075
+ method: "post",
1076
+ data: body
1077
+ });
1078
+ }
1063
1079
  };
1064
1080
 
1065
1081
  // src/lib/seam/connect/routes/acs-systems.ts
@@ -2296,6 +2312,123 @@ var SeamHttpThermostats = class _SeamHttpThermostats {
2296
2312
  }
2297
2313
  };
2298
2314
 
2315
+ // src/lib/seam/connect/routes/user-identities.ts
2316
+ var SeamHttpUserIdentities = class _SeamHttpUserIdentities {
2317
+ constructor(apiKeyOrOptions = {}) {
2318
+ const clientOptions = parseOptions(apiKeyOrOptions);
2319
+ this.client = createClient(clientOptions);
2320
+ }
2321
+ static fromClient(client, options = {}) {
2322
+ const constructorOptions = { ...options, client };
2323
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
2324
+ throw new SeamHttpInvalidOptionsError("Missing client");
2325
+ }
2326
+ return new _SeamHttpUserIdentities(constructorOptions);
2327
+ }
2328
+ static fromApiKey(apiKey, options = {}) {
2329
+ const constructorOptions = { ...options, apiKey };
2330
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
2331
+ throw new SeamHttpInvalidOptionsError("Missing apiKey");
2332
+ }
2333
+ return new _SeamHttpUserIdentities(constructorOptions);
2334
+ }
2335
+ static fromClientSessionToken(clientSessionToken, options = {}) {
2336
+ const constructorOptions = { ...options, clientSessionToken };
2337
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
2338
+ throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
2339
+ }
2340
+ return new _SeamHttpUserIdentities(constructorOptions);
2341
+ }
2342
+ static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
2343
+ warnOnInsecureuserIdentifierKey(userIdentifierKey);
2344
+ const clientOptions = parseOptions({ ...options, publishableKey });
2345
+ const client = createClient(clientOptions);
2346
+ const clientSessions = SeamHttpClientSessions.fromClient(client);
2347
+ const { token } = await clientSessions.getOrCreate({
2348
+ user_identifier_key: userIdentifierKey
2349
+ });
2350
+ return _SeamHttpUserIdentities.fromClientSessionToken(token, options);
2351
+ }
2352
+ static fromConsoleSessionToken(consoleSessionToken, workspaceId, options = {}) {
2353
+ const constructorOptions = { ...options, consoleSessionToken, workspaceId };
2354
+ if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) {
2355
+ throw new SeamHttpInvalidOptionsError(
2356
+ "Missing consoleSessionToken or workspaceId"
2357
+ );
2358
+ }
2359
+ return new _SeamHttpUserIdentities(constructorOptions);
2360
+ }
2361
+ static fromPersonalAccessToken(personalAccessToken, workspaceId, options = {}) {
2362
+ const constructorOptions = { ...options, personalAccessToken, workspaceId };
2363
+ if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) {
2364
+ throw new SeamHttpInvalidOptionsError(
2365
+ "Missing personalAccessToken or workspaceId"
2366
+ );
2367
+ }
2368
+ return new _SeamHttpUserIdentities(constructorOptions);
2369
+ }
2370
+ async addAcsUser(body) {
2371
+ await this.client.request({
2372
+ url: "/user_identities/add_acs_user",
2373
+ method: "post",
2374
+ data: body
2375
+ });
2376
+ }
2377
+ async create(body) {
2378
+ const { data } = await this.client.request({
2379
+ url: "/user_identities/create",
2380
+ method: "post",
2381
+ data: body
2382
+ });
2383
+ return data.user_identity;
2384
+ }
2385
+ async get(body) {
2386
+ const { data } = await this.client.request({
2387
+ url: "/user_identities/get",
2388
+ method: "post",
2389
+ data: body
2390
+ });
2391
+ return data.user_identity;
2392
+ }
2393
+ async grantAccessToDevice(body) {
2394
+ await this.client.request({
2395
+ url: "/user_identities/grant_access_to_device",
2396
+ method: "post",
2397
+ data: body
2398
+ });
2399
+ }
2400
+ async listAccessibleDevices(body) {
2401
+ const { data } = await this.client.request({
2402
+ url: "/user_identities/list_accessible_devices",
2403
+ method: "post",
2404
+ data: body
2405
+ });
2406
+ return data.accessible_devices;
2407
+ }
2408
+ async listAcsUsers(body) {
2409
+ const { data } = await this.client.request({
2410
+ url: "/user_identities/list_acs_users",
2411
+ method: "post",
2412
+ data: body
2413
+ });
2414
+ return data.acs_users;
2415
+ }
2416
+ async removeAcsUser(body) {
2417
+ await this.client.request({
2418
+ url: "/user_identities/remove_acs_user",
2419
+ method: "post",
2420
+ data: body
2421
+ });
2422
+ }
2423
+ async revokeAccessToDevice(body) {
2424
+ await this.client.request({
2425
+ url: "/user_identities/revoke_access_to_device",
2426
+ method: "post",
2427
+ data: body
2428
+ });
2429
+ }
2430
+ };
2431
+
2299
2432
  // src/lib/seam/connect/routes/webhooks.ts
2300
2433
  var SeamHttpWebhooks = class _SeamHttpWebhooks {
2301
2434
  constructor(apiKeyOrOptions = {}) {
@@ -2552,6 +2685,9 @@ var SeamHttp = class _SeamHttp {
2552
2685
  get thermostats() {
2553
2686
  return SeamHttpThermostats.fromClient(this.client);
2554
2687
  }
2688
+ get userIdentities() {
2689
+ return SeamHttpUserIdentities.fromClient(this.client);
2690
+ }
2555
2691
  get webhooks() {
2556
2692
  return SeamHttpWebhooks.fromClient(this.client);
2557
2693
  }
@@ -2560,6 +2696,46 @@ var SeamHttp = class _SeamHttp {
2560
2696
  }
2561
2697
  };
2562
2698
 
2699
+ // src/lib/seam/connect/seam-http-multi-workspace.ts
2700
+ var SeamHttpMultiWorkspace = class _SeamHttpMultiWorkspace {
2701
+ constructor(options) {
2702
+ const clientOptions = parseOptions(options);
2703
+ this.client = createClient(clientOptions);
2704
+ }
2705
+ static fromClient(client, options = {}) {
2706
+ const constructorOptions = { ...options, client };
2707
+ if (!isSeamHttpMultiWorkspaceOptionsWithClient(constructorOptions)) {
2708
+ throw new SeamHttpMultiWorkspaceInvalidOptionsError("Missing client");
2709
+ }
2710
+ return new _SeamHttpMultiWorkspace(constructorOptions);
2711
+ }
2712
+ static fromConsoleSessionToken(consoleSessionToken, options = {}) {
2713
+ const constructorOptions = { ...options, consoleSessionToken };
2714
+ if (!isSeamHttpMultiWorkspaceOptionsWithConsoleSessionToken(
2715
+ constructorOptions
2716
+ )) {
2717
+ throw new SeamHttpMultiWorkspaceInvalidOptionsError(
2718
+ "Missing consoleSessionToken"
2719
+ );
2720
+ }
2721
+ return new _SeamHttpMultiWorkspace(constructorOptions);
2722
+ }
2723
+ static fromPersonalAccessToken(personalAccessToken, options = {}) {
2724
+ const constructorOptions = { ...options, personalAccessToken };
2725
+ if (!isSeamHttpMultiWorkspaceOptionsWithPersonalAccessToken(
2726
+ constructorOptions
2727
+ )) {
2728
+ throw new SeamHttpMultiWorkspaceInvalidOptionsError(
2729
+ "Missing personalAccessToken"
2730
+ );
2731
+ }
2732
+ return new _SeamHttpMultiWorkspace(constructorOptions);
2733
+ }
2734
+ get workspaces() {
2735
+ return SeamHttpWorkspaces.fromClient(this.client);
2736
+ }
2737
+ };
2738
+
2563
2739
  exports.SeamHttp = SeamHttp;
2564
2740
  exports.SeamHttpAccessCodes = SeamHttpAccessCodes;
2565
2741
  exports.SeamHttpAccessCodesUnmanaged = SeamHttpAccessCodesUnmanaged;
@@ -2578,18 +2754,25 @@ exports.SeamHttpDevicesUnmanaged = SeamHttpDevicesUnmanaged;
2578
2754
  exports.SeamHttpEvents = SeamHttpEvents;
2579
2755
  exports.SeamHttpInvalidInputError = SeamHttpInvalidInputError;
2580
2756
  exports.SeamHttpInvalidOptionsError = SeamHttpInvalidOptionsError;
2757
+ exports.SeamHttpInvalidTokenError = SeamHttpInvalidTokenError;
2581
2758
  exports.SeamHttpLocks = SeamHttpLocks;
2759
+ exports.SeamHttpMultiWorkspace = SeamHttpMultiWorkspace;
2760
+ exports.SeamHttpMultiWorkspaceInvalidOptionsError = SeamHttpMultiWorkspaceInvalidOptionsError;
2582
2761
  exports.SeamHttpNoiseSensors = SeamHttpNoiseSensors;
2583
2762
  exports.SeamHttpNoiseSensorsNoiseThresholds = SeamHttpNoiseSensorsNoiseThresholds;
2584
2763
  exports.SeamHttpThermostats = SeamHttpThermostats;
2585
2764
  exports.SeamHttpThermostatsClimateSettingSchedules = SeamHttpThermostatsClimateSettingSchedules;
2586
2765
  exports.SeamHttpUnauthorizedError = SeamHttpUnauthorizedError;
2766
+ exports.SeamHttpUserIdentities = SeamHttpUserIdentities;
2587
2767
  exports.SeamHttpWebhooks = SeamHttpWebhooks;
2588
2768
  exports.SeamHttpWorkspaces = SeamHttpWorkspaces;
2589
2769
  exports.UnserializableParamError = UnserializableParamError;
2590
2770
  exports.errorInterceptor = errorInterceptor;
2591
2771
  exports.isSeamHttpApiError = isSeamHttpApiError;
2592
2772
  exports.isSeamHttpInvalidInputError = isSeamHttpInvalidInputError;
2773
+ exports.isSeamHttpMultiWorkspaceOptionsWithClient = isSeamHttpMultiWorkspaceOptionsWithClient;
2774
+ exports.isSeamHttpMultiWorkspaceOptionsWithConsoleSessionToken = isSeamHttpMultiWorkspaceOptionsWithConsoleSessionToken;
2775
+ exports.isSeamHttpMultiWorkspaceOptionsWithPersonalAccessToken = isSeamHttpMultiWorkspaceOptionsWithPersonalAccessToken;
2593
2776
  exports.isSeamHttpOptionsWithApiKey = isSeamHttpOptionsWithApiKey;
2594
2777
  exports.isSeamHttpOptionsWithClient = isSeamHttpOptionsWithClient;
2595
2778
  exports.isSeamHttpOptionsWithClientSessionToken = isSeamHttpOptionsWithClientSessionToken;