@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 CHANGED
@@ -1362,6 +1362,226 @@ var SeamHttpAccessCodes = class _SeamHttpAccessCodes {
1362
1362
  }
1363
1363
  };
1364
1364
 
1365
+ // src/lib/seam/connect/routes/access-grants.ts
1366
+ var SeamHttpAccessGrants = class _SeamHttpAccessGrants {
1367
+ constructor(apiKeyOrOptions = {}) {
1368
+ const options = parseOptions(apiKeyOrOptions);
1369
+ this.client = "client" in options ? options.client : createClient(options);
1370
+ this.defaults = limitToSeamHttpRequestOptions(options);
1371
+ }
1372
+ static fromClient(client, options = {}) {
1373
+ const constructorOptions = { ...options, client };
1374
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
1375
+ throw new SeamHttpInvalidOptionsError("Missing client");
1376
+ }
1377
+ return new _SeamHttpAccessGrants(constructorOptions);
1378
+ }
1379
+ static fromApiKey(apiKey, options = {}) {
1380
+ const constructorOptions = { ...options, apiKey };
1381
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
1382
+ throw new SeamHttpInvalidOptionsError("Missing apiKey");
1383
+ }
1384
+ return new _SeamHttpAccessGrants(constructorOptions);
1385
+ }
1386
+ static fromClientSessionToken(clientSessionToken, options = {}) {
1387
+ const constructorOptions = { ...options, clientSessionToken };
1388
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
1389
+ throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
1390
+ }
1391
+ return new _SeamHttpAccessGrants(constructorOptions);
1392
+ }
1393
+ static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
1394
+ warnOnInsecureuserIdentifierKey(userIdentifierKey);
1395
+ const clientOptions = parseOptions({ ...options, publishableKey });
1396
+ if (isSeamHttpOptionsWithClient(clientOptions)) {
1397
+ throw new SeamHttpInvalidOptionsError(
1398
+ "The client option cannot be used with SeamHttp.fromPublishableKey"
1399
+ );
1400
+ }
1401
+ const client = createClient(clientOptions);
1402
+ const clientSessions = SeamHttpClientSessions.fromClient(client);
1403
+ const { token } = await clientSessions.getOrCreate({
1404
+ user_identifier_key: userIdentifierKey
1405
+ });
1406
+ return _SeamHttpAccessGrants.fromClientSessionToken(token, options);
1407
+ }
1408
+ static fromConsoleSessionToken(consoleSessionToken, workspaceId, options = {}) {
1409
+ const constructorOptions = { ...options, consoleSessionToken, workspaceId };
1410
+ if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) {
1411
+ throw new SeamHttpInvalidOptionsError(
1412
+ "Missing consoleSessionToken or workspaceId"
1413
+ );
1414
+ }
1415
+ return new _SeamHttpAccessGrants(constructorOptions);
1416
+ }
1417
+ static fromPersonalAccessToken(personalAccessToken, workspaceId, options = {}) {
1418
+ const constructorOptions = { ...options, personalAccessToken, workspaceId };
1419
+ if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) {
1420
+ throw new SeamHttpInvalidOptionsError(
1421
+ "Missing personalAccessToken or workspaceId"
1422
+ );
1423
+ }
1424
+ return new _SeamHttpAccessGrants(constructorOptions);
1425
+ }
1426
+ createPaginator(request) {
1427
+ return new SeamPaginator(this, request);
1428
+ }
1429
+ async updateClientSessionToken(clientSessionToken) {
1430
+ const { headers } = this.client.defaults;
1431
+ const authHeaders = getAuthHeadersForClientSessionToken({
1432
+ clientSessionToken
1433
+ });
1434
+ for (const key of Object.keys(authHeaders)) {
1435
+ if (headers[key] == null) {
1436
+ throw new Error(
1437
+ "Cannot update a clientSessionToken on a client created without a clientSessionToken"
1438
+ );
1439
+ }
1440
+ }
1441
+ this.client.defaults.headers = { ...headers, ...authHeaders };
1442
+ const clientSessions = SeamHttpClientSessions.fromClient(this.client);
1443
+ await clientSessions.get();
1444
+ }
1445
+ create(body) {
1446
+ return new SeamHttpRequest(this, {
1447
+ pathname: "/access_grants/create",
1448
+ method: "post",
1449
+ body,
1450
+ responseKey: "access_grant"
1451
+ });
1452
+ }
1453
+ delete(body) {
1454
+ return new SeamHttpRequest(this, {
1455
+ pathname: "/access_grants/delete",
1456
+ method: "post",
1457
+ body,
1458
+ responseKey: void 0
1459
+ });
1460
+ }
1461
+ get(body) {
1462
+ return new SeamHttpRequest(this, {
1463
+ pathname: "/access_grants/get",
1464
+ method: "post",
1465
+ body,
1466
+ responseKey: "access_grant"
1467
+ });
1468
+ }
1469
+ list(body) {
1470
+ return new SeamHttpRequest(this, {
1471
+ pathname: "/access_grants/list",
1472
+ method: "post",
1473
+ body,
1474
+ responseKey: "access_grants"
1475
+ });
1476
+ }
1477
+ };
1478
+
1479
+ // src/lib/seam/connect/routes/access-methods.ts
1480
+ var SeamHttpAccessMethods = class _SeamHttpAccessMethods {
1481
+ constructor(apiKeyOrOptions = {}) {
1482
+ const options = parseOptions(apiKeyOrOptions);
1483
+ this.client = "client" in options ? options.client : createClient(options);
1484
+ this.defaults = limitToSeamHttpRequestOptions(options);
1485
+ }
1486
+ static fromClient(client, options = {}) {
1487
+ const constructorOptions = { ...options, client };
1488
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
1489
+ throw new SeamHttpInvalidOptionsError("Missing client");
1490
+ }
1491
+ return new _SeamHttpAccessMethods(constructorOptions);
1492
+ }
1493
+ static fromApiKey(apiKey, options = {}) {
1494
+ const constructorOptions = { ...options, apiKey };
1495
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
1496
+ throw new SeamHttpInvalidOptionsError("Missing apiKey");
1497
+ }
1498
+ return new _SeamHttpAccessMethods(constructorOptions);
1499
+ }
1500
+ static fromClientSessionToken(clientSessionToken, options = {}) {
1501
+ const constructorOptions = { ...options, clientSessionToken };
1502
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
1503
+ throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
1504
+ }
1505
+ return new _SeamHttpAccessMethods(constructorOptions);
1506
+ }
1507
+ static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
1508
+ warnOnInsecureuserIdentifierKey(userIdentifierKey);
1509
+ const clientOptions = parseOptions({ ...options, publishableKey });
1510
+ if (isSeamHttpOptionsWithClient(clientOptions)) {
1511
+ throw new SeamHttpInvalidOptionsError(
1512
+ "The client option cannot be used with SeamHttp.fromPublishableKey"
1513
+ );
1514
+ }
1515
+ const client = createClient(clientOptions);
1516
+ const clientSessions = SeamHttpClientSessions.fromClient(client);
1517
+ const { token } = await clientSessions.getOrCreate({
1518
+ user_identifier_key: userIdentifierKey
1519
+ });
1520
+ return _SeamHttpAccessMethods.fromClientSessionToken(token, options);
1521
+ }
1522
+ static fromConsoleSessionToken(consoleSessionToken, workspaceId, options = {}) {
1523
+ const constructorOptions = { ...options, consoleSessionToken, workspaceId };
1524
+ if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) {
1525
+ throw new SeamHttpInvalidOptionsError(
1526
+ "Missing consoleSessionToken or workspaceId"
1527
+ );
1528
+ }
1529
+ return new _SeamHttpAccessMethods(constructorOptions);
1530
+ }
1531
+ static fromPersonalAccessToken(personalAccessToken, workspaceId, options = {}) {
1532
+ const constructorOptions = { ...options, personalAccessToken, workspaceId };
1533
+ if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) {
1534
+ throw new SeamHttpInvalidOptionsError(
1535
+ "Missing personalAccessToken or workspaceId"
1536
+ );
1537
+ }
1538
+ return new _SeamHttpAccessMethods(constructorOptions);
1539
+ }
1540
+ createPaginator(request) {
1541
+ return new SeamPaginator(this, request);
1542
+ }
1543
+ async updateClientSessionToken(clientSessionToken) {
1544
+ const { headers } = this.client.defaults;
1545
+ const authHeaders = getAuthHeadersForClientSessionToken({
1546
+ clientSessionToken
1547
+ });
1548
+ for (const key of Object.keys(authHeaders)) {
1549
+ if (headers[key] == null) {
1550
+ throw new Error(
1551
+ "Cannot update a clientSessionToken on a client created without a clientSessionToken"
1552
+ );
1553
+ }
1554
+ }
1555
+ this.client.defaults.headers = { ...headers, ...authHeaders };
1556
+ const clientSessions = SeamHttpClientSessions.fromClient(this.client);
1557
+ await clientSessions.get();
1558
+ }
1559
+ delete(body) {
1560
+ return new SeamHttpRequest(this, {
1561
+ pathname: "/access_methods/delete",
1562
+ method: "post",
1563
+ body,
1564
+ responseKey: void 0
1565
+ });
1566
+ }
1567
+ get(body) {
1568
+ return new SeamHttpRequest(this, {
1569
+ pathname: "/access_methods/get",
1570
+ method: "post",
1571
+ body,
1572
+ responseKey: "access_method"
1573
+ });
1574
+ }
1575
+ list(body) {
1576
+ return new SeamHttpRequest(this, {
1577
+ pathname: "/access_methods/list",
1578
+ method: "post",
1579
+ body,
1580
+ responseKey: "access_methods"
1581
+ });
1582
+ }
1583
+ };
1584
+
1365
1585
  // src/lib/seam/connect/routes/acs-access-groups.ts
1366
1586
  var SeamHttpAcsAccessGroups = class _SeamHttpAcsAccessGroups {
1367
1587
  constructor(apiKeyOrOptions = {}) {
@@ -3764,6 +3984,160 @@ var SeamHttpPhones = class _SeamHttpPhones {
3764
3984
  }
3765
3985
  };
3766
3986
 
3987
+ // src/lib/seam/connect/routes/spaces.ts
3988
+ var SeamHttpSpaces = class _SeamHttpSpaces {
3989
+ constructor(apiKeyOrOptions = {}) {
3990
+ const options = parseOptions(apiKeyOrOptions);
3991
+ this.client = "client" in options ? options.client : createClient(options);
3992
+ this.defaults = limitToSeamHttpRequestOptions(options);
3993
+ }
3994
+ static fromClient(client, options = {}) {
3995
+ const constructorOptions = { ...options, client };
3996
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
3997
+ throw new SeamHttpInvalidOptionsError("Missing client");
3998
+ }
3999
+ return new _SeamHttpSpaces(constructorOptions);
4000
+ }
4001
+ static fromApiKey(apiKey, options = {}) {
4002
+ const constructorOptions = { ...options, apiKey };
4003
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
4004
+ throw new SeamHttpInvalidOptionsError("Missing apiKey");
4005
+ }
4006
+ return new _SeamHttpSpaces(constructorOptions);
4007
+ }
4008
+ static fromClientSessionToken(clientSessionToken, options = {}) {
4009
+ const constructorOptions = { ...options, clientSessionToken };
4010
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
4011
+ throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
4012
+ }
4013
+ return new _SeamHttpSpaces(constructorOptions);
4014
+ }
4015
+ static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
4016
+ warnOnInsecureuserIdentifierKey(userIdentifierKey);
4017
+ const clientOptions = parseOptions({ ...options, publishableKey });
4018
+ if (isSeamHttpOptionsWithClient(clientOptions)) {
4019
+ throw new SeamHttpInvalidOptionsError(
4020
+ "The client option cannot be used with SeamHttp.fromPublishableKey"
4021
+ );
4022
+ }
4023
+ const client = createClient(clientOptions);
4024
+ const clientSessions = SeamHttpClientSessions.fromClient(client);
4025
+ const { token } = await clientSessions.getOrCreate({
4026
+ user_identifier_key: userIdentifierKey
4027
+ });
4028
+ return _SeamHttpSpaces.fromClientSessionToken(token, options);
4029
+ }
4030
+ static fromConsoleSessionToken(consoleSessionToken, workspaceId, options = {}) {
4031
+ const constructorOptions = { ...options, consoleSessionToken, workspaceId };
4032
+ if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) {
4033
+ throw new SeamHttpInvalidOptionsError(
4034
+ "Missing consoleSessionToken or workspaceId"
4035
+ );
4036
+ }
4037
+ return new _SeamHttpSpaces(constructorOptions);
4038
+ }
4039
+ static fromPersonalAccessToken(personalAccessToken, workspaceId, options = {}) {
4040
+ const constructorOptions = { ...options, personalAccessToken, workspaceId };
4041
+ if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) {
4042
+ throw new SeamHttpInvalidOptionsError(
4043
+ "Missing personalAccessToken or workspaceId"
4044
+ );
4045
+ }
4046
+ return new _SeamHttpSpaces(constructorOptions);
4047
+ }
4048
+ createPaginator(request) {
4049
+ return new SeamPaginator(this, request);
4050
+ }
4051
+ async updateClientSessionToken(clientSessionToken) {
4052
+ const { headers } = this.client.defaults;
4053
+ const authHeaders = getAuthHeadersForClientSessionToken({
4054
+ clientSessionToken
4055
+ });
4056
+ for (const key of Object.keys(authHeaders)) {
4057
+ if (headers[key] == null) {
4058
+ throw new Error(
4059
+ "Cannot update a clientSessionToken on a client created without a clientSessionToken"
4060
+ );
4061
+ }
4062
+ }
4063
+ this.client.defaults.headers = { ...headers, ...authHeaders };
4064
+ const clientSessions = SeamHttpClientSessions.fromClient(this.client);
4065
+ await clientSessions.get();
4066
+ }
4067
+ addAcsEntrances(body) {
4068
+ return new SeamHttpRequest(this, {
4069
+ pathname: "/spaces/add_acs_entrances",
4070
+ method: "post",
4071
+ body,
4072
+ responseKey: void 0
4073
+ });
4074
+ }
4075
+ addDevices(body) {
4076
+ return new SeamHttpRequest(this, {
4077
+ pathname: "/spaces/add_devices",
4078
+ method: "post",
4079
+ body,
4080
+ responseKey: void 0
4081
+ });
4082
+ }
4083
+ create(body) {
4084
+ return new SeamHttpRequest(this, {
4085
+ pathname: "/spaces/create",
4086
+ method: "post",
4087
+ body,
4088
+ responseKey: "space"
4089
+ });
4090
+ }
4091
+ delete(body) {
4092
+ return new SeamHttpRequest(this, {
4093
+ pathname: "/spaces/delete",
4094
+ method: "post",
4095
+ body,
4096
+ responseKey: void 0
4097
+ });
4098
+ }
4099
+ get(body) {
4100
+ return new SeamHttpRequest(this, {
4101
+ pathname: "/spaces/get",
4102
+ method: "post",
4103
+ body,
4104
+ responseKey: "space"
4105
+ });
4106
+ }
4107
+ list(body) {
4108
+ return new SeamHttpRequest(this, {
4109
+ pathname: "/spaces/list",
4110
+ method: "post",
4111
+ body,
4112
+ responseKey: "spaces"
4113
+ });
4114
+ }
4115
+ removeAcsEntrances(body) {
4116
+ return new SeamHttpRequest(this, {
4117
+ pathname: "/spaces/remove_acs_entrances",
4118
+ method: "post",
4119
+ body,
4120
+ responseKey: void 0
4121
+ });
4122
+ }
4123
+ removeDevices(body) {
4124
+ return new SeamHttpRequest(this, {
4125
+ pathname: "/spaces/remove_devices",
4126
+ method: "post",
4127
+ body,
4128
+ responseKey: void 0
4129
+ });
4130
+ }
4131
+ update(body) {
4132
+ return new SeamHttpRequest(this, {
4133
+ pathname: "/spaces/update",
4134
+ method: "post",
4135
+ body,
4136
+ responseKey: "space"
4137
+ });
4138
+ }
4139
+ };
4140
+
3767
4141
  // src/lib/seam/connect/routes/thermostats-daily-programs.ts
3768
4142
  var SeamHttpThermostatsDailyPrograms = class _SeamHttpThermostatsDailyPrograms {
3769
4143
  constructor(apiKeyOrOptions = {}) {
@@ -5028,6 +5402,12 @@ var _SeamHttp = class _SeamHttp {
5028
5402
  get accessCodes() {
5029
5403
  return SeamHttpAccessCodes.fromClient(this.client, this.defaults);
5030
5404
  }
5405
+ get accessGrants() {
5406
+ return SeamHttpAccessGrants.fromClient(this.client, this.defaults);
5407
+ }
5408
+ get accessMethods() {
5409
+ return SeamHttpAccessMethods.fromClient(this.client, this.defaults);
5410
+ }
5031
5411
  get acs() {
5032
5412
  return SeamHttpAcs.fromClient(this.client, this.defaults);
5033
5413
  }
@@ -5058,6 +5438,9 @@ var _SeamHttp = class _SeamHttp {
5058
5438
  get phones() {
5059
5439
  return SeamHttpPhones.fromClient(this.client, this.defaults);
5060
5440
  }
5441
+ get spaces() {
5442
+ return SeamHttpSpaces.fromClient(this.client, this.defaults);
5443
+ }
5061
5444
  get thermostats() {
5062
5445
  return SeamHttpThermostats.fromClient(this.client, this.defaults);
5063
5446
  }
@@ -5122,6 +5505,8 @@ exports.SeamHttp = SeamHttp;
5122
5505
  exports.SeamHttpAccessCodes = SeamHttpAccessCodes;
5123
5506
  exports.SeamHttpAccessCodesSimulate = SeamHttpAccessCodesSimulate;
5124
5507
  exports.SeamHttpAccessCodesUnmanaged = SeamHttpAccessCodesUnmanaged;
5508
+ exports.SeamHttpAccessGrants = SeamHttpAccessGrants;
5509
+ exports.SeamHttpAccessMethods = SeamHttpAccessMethods;
5125
5510
  exports.SeamHttpAcs = SeamHttpAcs;
5126
5511
  exports.SeamHttpAcsAccessGroups = SeamHttpAcsAccessGroups;
5127
5512
  exports.SeamHttpAcsCredentials = SeamHttpAcsCredentials;
@@ -5151,6 +5536,7 @@ exports.SeamHttpNoiseSensorsSimulate = SeamHttpNoiseSensorsSimulate;
5151
5536
  exports.SeamHttpPhones = SeamHttpPhones;
5152
5537
  exports.SeamHttpPhonesSimulate = SeamHttpPhonesSimulate;
5153
5538
  exports.SeamHttpRequest = SeamHttpRequest;
5539
+ exports.SeamHttpSpaces = SeamHttpSpaces;
5154
5540
  exports.SeamHttpThermostats = SeamHttpThermostats;
5155
5541
  exports.SeamHttpThermostatsDailyPrograms = SeamHttpThermostatsDailyPrograms;
5156
5542
  exports.SeamHttpThermostatsSchedules = SeamHttpThermostatsSchedules;