@seamapi/http 0.0.2 → 0.1.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 (115) hide show
  1. package/dist/connect.cjs +1386 -61
  2. package/dist/connect.cjs.map +1 -1
  3. package/dist/connect.d.cts +420 -7
  4. package/lib/seam/connect/auth.d.ts +1 -1
  5. package/lib/seam/connect/auth.js +7 -7
  6. package/lib/seam/connect/auth.js.map +1 -1
  7. package/lib/seam/connect/axios.js +3 -1
  8. package/lib/seam/connect/axios.js.map +1 -1
  9. package/lib/seam/connect/client-options.d.ts +7 -3
  10. package/lib/seam/connect/client-options.js +18 -3
  11. package/lib/seam/connect/client-options.js.map +1 -1
  12. package/lib/seam/connect/client.d.ts +16 -4
  13. package/lib/seam/connect/client.js +55 -28
  14. package/lib/seam/connect/client.js.map +1 -1
  15. package/lib/seam/connect/parse-options.d.ts +1 -1
  16. package/lib/seam/connect/parse-options.js +8 -1
  17. package/lib/seam/connect/parse-options.js.map +1 -1
  18. package/lib/seam/connect/routes/access-codes-unmanaged.d.ts +26 -0
  19. package/lib/seam/connect/routes/access-codes-unmanaged.js +72 -0
  20. package/lib/seam/connect/routes/access-codes-unmanaged.js.map +1 -0
  21. package/lib/seam/connect/routes/access-codes.d.ts +37 -0
  22. package/lib/seam/connect/routes/access-codes.js +101 -0
  23. package/lib/seam/connect/routes/access-codes.js.map +1 -0
  24. package/lib/seam/connect/routes/acs-access-groups.d.ts +35 -0
  25. package/lib/seam/connect/routes/acs-access-groups.js +95 -0
  26. package/lib/seam/connect/routes/acs-access-groups.js.map +1 -0
  27. package/lib/seam/connect/routes/acs-credentials.d.ts +23 -0
  28. package/lib/seam/connect/routes/acs-credentials.js +66 -0
  29. package/lib/seam/connect/routes/acs-credentials.js.map +1 -0
  30. package/lib/seam/connect/routes/acs-systems.d.ts +17 -0
  31. package/lib/seam/connect/routes/acs-systems.js +51 -0
  32. package/lib/seam/connect/routes/acs-systems.js.map +1 -0
  33. package/lib/seam/connect/routes/acs-users.d.ts +32 -0
  34. package/lib/seam/connect/routes/acs-users.js +87 -0
  35. package/lib/seam/connect/routes/acs-users.js.map +1 -0
  36. package/lib/seam/connect/routes/acs.d.ts +17 -0
  37. package/lib/seam/connect/routes/acs.js +51 -0
  38. package/lib/seam/connect/routes/acs.js.map +1 -0
  39. package/lib/seam/connect/routes/action-attempts.d.ts +17 -0
  40. package/lib/seam/connect/routes/action-attempts.js +51 -0
  41. package/lib/seam/connect/routes/action-attempts.js.map +1 -0
  42. package/lib/seam/connect/routes/client-sessions.d.ts +26 -0
  43. package/lib/seam/connect/routes/client-sessions.js +74 -0
  44. package/lib/seam/connect/routes/client-sessions.js.map +1 -0
  45. package/lib/seam/connect/routes/connect-webviews.d.ts +26 -0
  46. package/lib/seam/connect/routes/connect-webviews.js +73 -0
  47. package/lib/seam/connect/routes/connect-webviews.js.map +1 -0
  48. package/lib/seam/connect/routes/connected-accounts.d.ts +20 -0
  49. package/lib/seam/connect/routes/connected-accounts.js +58 -0
  50. package/lib/seam/connect/routes/connected-accounts.js.map +1 -0
  51. package/lib/seam/connect/routes/devices-unmanaged.d.ts +20 -0
  52. package/lib/seam/connect/routes/devices-unmanaged.js +58 -0
  53. package/lib/seam/connect/routes/devices-unmanaged.js.map +1 -0
  54. package/lib/seam/connect/routes/devices.d.ts +28 -0
  55. package/lib/seam/connect/routes/devices.js +77 -0
  56. package/lib/seam/connect/routes/devices.js.map +1 -0
  57. package/lib/seam/connect/routes/events.d.ts +17 -0
  58. package/lib/seam/connect/routes/events.js +51 -0
  59. package/lib/seam/connect/routes/events.js.map +1 -0
  60. package/lib/seam/connect/routes/index.d.ts +21 -0
  61. package/lib/seam/connect/routes/index.js +22 -0
  62. package/lib/seam/connect/routes/index.js.map +1 -0
  63. package/lib/seam/connect/routes/locks.d.ts +23 -0
  64. package/lib/seam/connect/routes/locks.js +67 -0
  65. package/lib/seam/connect/routes/locks.js.map +1 -0
  66. package/lib/seam/connect/routes/noise-sensors-noise-thresholds.d.ts +26 -0
  67. package/lib/seam/connect/routes/noise-sensors-noise-thresholds.js +72 -0
  68. package/lib/seam/connect/routes/noise-sensors-noise-thresholds.js.map +1 -0
  69. package/lib/seam/connect/routes/noise-sensors.d.ts +11 -0
  70. package/lib/seam/connect/routes/noise-sensors.js +39 -0
  71. package/lib/seam/connect/routes/noise-sensors.js.map +1 -0
  72. package/lib/seam/connect/routes/thermostats-climate-setting-schedules.d.ts +26 -0
  73. package/lib/seam/connect/routes/thermostats-climate-setting-schedules.js +73 -0
  74. package/lib/seam/connect/routes/thermostats-climate-setting-schedules.js.map +1 -0
  75. package/lib/seam/connect/routes/thermostats.d.ts +37 -0
  76. package/lib/seam/connect/routes/thermostats.js +97 -0
  77. package/lib/seam/connect/routes/thermostats.js.map +1 -0
  78. package/lib/seam/connect/routes/webhooks.d.ts +23 -0
  79. package/lib/seam/connect/routes/webhooks.js +66 -0
  80. package/lib/seam/connect/routes/webhooks.js.map +1 -0
  81. package/lib/seam/connect/routes/workspaces.d.ts +14 -5
  82. package/lib/seam/connect/routes/workspaces.js +48 -10
  83. package/lib/seam/connect/routes/workspaces.js.map +1 -1
  84. package/package.json +4 -1
  85. package/src/lib/seam/connect/auth.ts +7 -7
  86. package/src/lib/seam/connect/axios.ts +2 -0
  87. package/src/lib/seam/connect/client-options.ts +32 -4
  88. package/src/lib/seam/connect/client.ts +88 -15
  89. package/src/lib/seam/connect/parse-options.ts +16 -2
  90. package/src/lib/seam/connect/routes/access-codes-unmanaged.ts +157 -0
  91. package/src/lib/seam/connect/routes/access-codes.ts +226 -0
  92. package/src/lib/seam/connect/routes/acs-access-groups.ts +207 -0
  93. package/src/lib/seam/connect/routes/acs-credentials.ts +139 -0
  94. package/src/lib/seam/connect/routes/acs-systems.ts +108 -0
  95. package/src/lib/seam/connect/routes/acs-users.ts +187 -0
  96. package/src/lib/seam/connect/routes/acs.ts +85 -0
  97. package/src/lib/seam/connect/routes/action-attempts.ts +104 -0
  98. package/src/lib/seam/connect/routes/client-sessions.ts +159 -0
  99. package/src/lib/seam/connect/routes/connect-webviews.ts +159 -0
  100. package/src/lib/seam/connect/routes/connected-accounts.ts +124 -0
  101. package/src/lib/seam/connect/routes/devices-unmanaged.ts +120 -0
  102. package/src/lib/seam/connect/routes/devices.ts +158 -0
  103. package/src/lib/seam/connect/routes/events.ts +100 -0
  104. package/src/lib/seam/connect/routes/index.ts +21 -0
  105. package/src/lib/seam/connect/routes/locks.ts +138 -0
  106. package/src/lib/seam/connect/routes/noise-sensors-noise-thresholds.ts +154 -0
  107. package/src/lib/seam/connect/routes/noise-sensors.ts +70 -0
  108. package/src/lib/seam/connect/routes/thermostats-climate-setting-schedules.ts +176 -0
  109. package/src/lib/seam/connect/routes/thermostats.ts +206 -0
  110. package/src/lib/seam/connect/routes/webhooks.ts +141 -0
  111. package/src/lib/seam/connect/routes/workspaces.ts +100 -17
  112. package/lib/seam/connect/legacy/workspaces.d.ts +0 -8
  113. package/lib/seam/connect/legacy/workspaces.js +0 -10
  114. package/lib/seam/connect/legacy/workspaces.js.map +0 -1
  115. package/src/lib/seam/connect/legacy/workspaces.ts +0 -26
@@ -0,0 +1,141 @@
1
+ /*
2
+ * Automatically generated by generate-routes.ts.
3
+ * Do not edit this file or add other files to this directory.
4
+ */
5
+
6
+ import type {
7
+ RouteRequestBody,
8
+ RouteRequestParams,
9
+ RouteResponse,
10
+ } from '@seamapi/types/connect'
11
+ import type { Axios } from 'axios'
12
+ import type { SetNonNullable } from 'type-fest'
13
+
14
+ import { createAxiosClient } from 'lib/seam/connect/axios.js'
15
+ import {
16
+ isSeamHttpOptionsWithApiKey,
17
+ isSeamHttpOptionsWithClient,
18
+ isSeamHttpOptionsWithClientSessionToken,
19
+ SeamHttpInvalidOptionsError,
20
+ type SeamHttpOptions,
21
+ type SeamHttpOptionsWithApiKey,
22
+ type SeamHttpOptionsWithClient,
23
+ type SeamHttpOptionsWithClientSessionToken,
24
+ } from 'lib/seam/connect/client-options.js'
25
+ import { parseOptions } from 'lib/seam/connect/parse-options.js'
26
+
27
+ export class SeamHttpWebhooks {
28
+ client: Axios
29
+
30
+ constructor(apiKeyOrOptions: string | SeamHttpOptions) {
31
+ const options = parseOptions(apiKeyOrOptions)
32
+ this.client = createAxiosClient(options)
33
+ }
34
+
35
+ static fromClient(
36
+ client: SeamHttpOptionsWithClient['client'],
37
+ options: Omit<SeamHttpOptionsWithClient, 'client'> = {},
38
+ ): SeamHttpWebhooks {
39
+ const opts = { ...options, client }
40
+ if (!isSeamHttpOptionsWithClient(opts)) {
41
+ throw new SeamHttpInvalidOptionsError('Missing client')
42
+ }
43
+ return new SeamHttpWebhooks(opts)
44
+ }
45
+
46
+ static fromApiKey(
47
+ apiKey: SeamHttpOptionsWithApiKey['apiKey'],
48
+ options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
49
+ ): SeamHttpWebhooks {
50
+ const opts = { ...options, apiKey }
51
+ if (!isSeamHttpOptionsWithApiKey(opts)) {
52
+ throw new SeamHttpInvalidOptionsError('Missing apiKey')
53
+ }
54
+ return new SeamHttpWebhooks(opts)
55
+ }
56
+
57
+ static fromClientSessionToken(
58
+ clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
59
+ options: Omit<
60
+ SeamHttpOptionsWithClientSessionToken,
61
+ 'clientSessionToken'
62
+ > = {},
63
+ ): SeamHttpWebhooks {
64
+ const opts = { ...options, clientSessionToken }
65
+ if (!isSeamHttpOptionsWithClientSessionToken(opts)) {
66
+ throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
67
+ }
68
+ return new SeamHttpWebhooks(opts)
69
+ }
70
+
71
+ async create(
72
+ body: WebhooksCreateBody,
73
+ ): Promise<WebhooksCreateResponse['webhook']> {
74
+ const { data } = await this.client.request<WebhooksCreateResponse>({
75
+ url: '/webhooks/create',
76
+ method: 'post',
77
+ data: body,
78
+ })
79
+ return data.webhook
80
+ }
81
+
82
+ async delete(body: WebhooksDeleteBody): Promise<void> {
83
+ await this.client.request<WebhooksDeleteResponse>({
84
+ url: '/webhooks/delete',
85
+ method: 'post',
86
+ data: body,
87
+ })
88
+ }
89
+
90
+ async get(body: WebhooksGetBody): Promise<WebhooksGetResponse['webhook']> {
91
+ const { data } = await this.client.request<WebhooksGetResponse>({
92
+ url: '/webhooks/get',
93
+ method: 'post',
94
+ data: body,
95
+ })
96
+ return data.webhook
97
+ }
98
+
99
+ async list(
100
+ params?: WebhooksListParams,
101
+ ): Promise<WebhooksListResponse['webhooks']> {
102
+ const { data } = await this.client.request<WebhooksListResponse>({
103
+ url: '/webhooks/list',
104
+ method: 'get',
105
+ params,
106
+ })
107
+ return data.webhooks
108
+ }
109
+ }
110
+
111
+ export type WebhooksCreateBody = SetNonNullable<
112
+ Required<RouteRequestBody<'/webhooks/create'>>
113
+ >
114
+
115
+ export type WebhooksCreateResponse = SetNonNullable<
116
+ Required<RouteResponse<'/webhooks/create'>>
117
+ >
118
+
119
+ export type WebhooksDeleteBody = SetNonNullable<
120
+ Required<RouteRequestBody<'/webhooks/delete'>>
121
+ >
122
+
123
+ export type WebhooksDeleteResponse = SetNonNullable<
124
+ Required<RouteResponse<'/webhooks/delete'>>
125
+ >
126
+
127
+ export type WebhooksGetBody = SetNonNullable<
128
+ Required<RouteRequestBody<'/webhooks/get'>>
129
+ >
130
+
131
+ export type WebhooksGetResponse = SetNonNullable<
132
+ Required<RouteResponse<'/webhooks/get'>>
133
+ >
134
+
135
+ export type WebhooksListParams = SetNonNullable<
136
+ Required<RouteRequestParams<'/webhooks/list'>>
137
+ >
138
+
139
+ export type WebhooksListResponse = SetNonNullable<
140
+ Required<RouteResponse<'/webhooks/list'>>
141
+ >
@@ -1,35 +1,102 @@
1
- import type { RouteRequestParams, RouteResponse } from '@seamapi/types/connect'
2
- import { Axios } from 'axios'
1
+ /*
2
+ * Automatically generated by generate-routes.ts.
3
+ * Do not edit this file or add other files to this directory.
4
+ */
5
+
6
+ import type {
7
+ RouteRequestBody,
8
+ RouteRequestParams,
9
+ RouteResponse,
10
+ } from '@seamapi/types/connect'
11
+ import type { Axios } from 'axios'
3
12
  import type { SetNonNullable } from 'type-fest'
4
13
 
5
14
  import { createAxiosClient } from 'lib/seam/connect/axios.js'
6
- import type { SeamHttpOptions } from 'lib/seam/connect/client-options.js'
15
+ import {
16
+ isSeamHttpOptionsWithApiKey,
17
+ isSeamHttpOptionsWithClient,
18
+ isSeamHttpOptionsWithClientSessionToken,
19
+ SeamHttpInvalidOptionsError,
20
+ type SeamHttpOptions,
21
+ type SeamHttpOptionsWithApiKey,
22
+ type SeamHttpOptionsWithClient,
23
+ type SeamHttpOptionsWithClientSessionToken,
24
+ } from 'lib/seam/connect/client-options.js'
7
25
  import { parseOptions } from 'lib/seam/connect/parse-options.js'
8
26
 
9
- export class WorkspacesHttp {
27
+ export class SeamHttpWorkspaces {
10
28
  client: Axios
11
29
 
12
- constructor(apiKeyOrOptionsOrClient: Axios | string | SeamHttpOptions) {
13
- if (apiKeyOrOptionsOrClient instanceof Axios) {
14
- this.client = apiKeyOrOptionsOrClient
15
- return
30
+ constructor(apiKeyOrOptions: string | SeamHttpOptions) {
31
+ const options = parseOptions(apiKeyOrOptions)
32
+ this.client = createAxiosClient(options)
33
+ }
34
+
35
+ static fromClient(
36
+ client: SeamHttpOptionsWithClient['client'],
37
+ options: Omit<SeamHttpOptionsWithClient, 'client'> = {},
38
+ ): SeamHttpWorkspaces {
39
+ const opts = { ...options, client }
40
+ if (!isSeamHttpOptionsWithClient(opts)) {
41
+ throw new SeamHttpInvalidOptionsError('Missing client')
16
42
  }
43
+ return new SeamHttpWorkspaces(opts)
44
+ }
17
45
 
18
- const options = parseOptions(apiKeyOrOptionsOrClient)
19
- this.client = createAxiosClient(options)
46
+ static fromApiKey(
47
+ apiKey: SeamHttpOptionsWithApiKey['apiKey'],
48
+ options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
49
+ ): SeamHttpWorkspaces {
50
+ const opts = { ...options, apiKey }
51
+ if (!isSeamHttpOptionsWithApiKey(opts)) {
52
+ throw new SeamHttpInvalidOptionsError('Missing apiKey')
53
+ }
54
+ return new SeamHttpWorkspaces(opts)
55
+ }
56
+
57
+ static fromClientSessionToken(
58
+ clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
59
+ options: Omit<
60
+ SeamHttpOptionsWithClientSessionToken,
61
+ 'clientSessionToken'
62
+ > = {},
63
+ ): SeamHttpWorkspaces {
64
+ const opts = { ...options, clientSessionToken }
65
+ if (!isSeamHttpOptionsWithClientSessionToken(opts)) {
66
+ throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
67
+ }
68
+ return new SeamHttpWorkspaces(opts)
20
69
  }
21
70
 
22
71
  async get(
23
- params: WorkspacesGetParams = {},
72
+ params?: WorkspacesGetParams,
24
73
  ): Promise<WorkspacesGetResponse['workspace']> {
25
- const { data } = await this.client.get<WorkspacesGetResponse>(
26
- '/workspaces/get',
27
- {
28
- params,
29
- },
30
- )
74
+ const { data } = await this.client.request<WorkspacesGetResponse>({
75
+ url: '/workspaces/get',
76
+ method: 'get',
77
+ params,
78
+ })
31
79
  return data.workspace
32
80
  }
81
+
82
+ async list(
83
+ params?: WorkspacesListParams,
84
+ ): Promise<WorkspacesListResponse['workspaces']> {
85
+ const { data } = await this.client.request<WorkspacesListResponse>({
86
+ url: '/workspaces/list',
87
+ method: 'get',
88
+ params,
89
+ })
90
+ return data.workspaces
91
+ }
92
+
93
+ async resetSandbox(body: WorkspacesResetSandboxBody): Promise<void> {
94
+ await this.client.request<WorkspacesResetSandboxResponse>({
95
+ url: '/workspaces/reset_sandbox',
96
+ method: 'post',
97
+ data: body,
98
+ })
99
+ }
33
100
  }
34
101
 
35
102
  export type WorkspacesGetParams = SetNonNullable<
@@ -39,3 +106,19 @@ export type WorkspacesGetParams = SetNonNullable<
39
106
  export type WorkspacesGetResponse = SetNonNullable<
40
107
  Required<RouteResponse<'/workspaces/get'>>
41
108
  >
109
+
110
+ export type WorkspacesListParams = SetNonNullable<
111
+ Required<RouteRequestParams<'/workspaces/list'>>
112
+ >
113
+
114
+ export type WorkspacesListResponse = SetNonNullable<
115
+ Required<RouteResponse<'/workspaces/list'>>
116
+ >
117
+
118
+ export type WorkspacesResetSandboxBody = SetNonNullable<
119
+ Required<RouteRequestBody<'/workspaces/reset_sandbox'>>
120
+ >
121
+
122
+ export type WorkspacesResetSandboxResponse = SetNonNullable<
123
+ Required<RouteResponse<'/workspaces/reset_sandbox'>>
124
+ >
@@ -1,8 +0,0 @@
1
- import type { RouteRequestParams, RouteResponse } from '@seamapi/types/connect';
2
- import type { SetNonNullable } from 'type-fest';
3
- import { WorkspacesHttp } from '../../../../lib/seam/connect/routes/workspaces.js';
4
- export declare class LegacyWorkspacesHttp extends WorkspacesHttp {
5
- get(params?: WorkspacesGetParams): Promise<WorkspacesGetResponse['workspace']>;
6
- }
7
- export type WorkspacesGetParams = SetNonNullable<Required<RouteRequestParams<'/workspaces/get'>>>;
8
- export type WorkspacesGetResponse = SetNonNullable<Required<RouteResponse<'/workspaces/get'>>>;
@@ -1,10 +0,0 @@
1
- import { WorkspacesHttp } from '../../../../lib/seam/connect/routes/workspaces.js';
2
- export class LegacyWorkspacesHttp extends WorkspacesHttp {
3
- async get(params = {}) {
4
- const { data } = await this.client.get('/workspaces/get', {
5
- params,
6
- });
7
- return data.workspace;
8
- }
9
- }
10
- //# sourceMappingURL=workspaces.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"workspaces.js","sourceRoot":"","sources":["../../../../src/lib/seam/connect/legacy/workspaces.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAA;AAEtE,MAAM,OAAO,oBAAqB,SAAQ,cAAc;IAC7C,KAAK,CAAC,GAAG,CAChB,SAA8B,EAAE;QAEhC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CACpC,iBAAiB,EACjB;YACE,MAAM;SACP,CACF,CAAA;QACD,OAAO,IAAI,CAAC,SAAS,CAAA;IACvB,CAAC;CACF"}
@@ -1,26 +0,0 @@
1
- import type { RouteRequestParams, RouteResponse } from '@seamapi/types/connect'
2
- import type { SetNonNullable } from 'type-fest'
3
-
4
- import { WorkspacesHttp } from 'lib/seam/connect/routes/workspaces.js'
5
-
6
- export class LegacyWorkspacesHttp extends WorkspacesHttp {
7
- override async get(
8
- params: WorkspacesGetParams = {},
9
- ): Promise<WorkspacesGetResponse['workspace']> {
10
- const { data } = await this.client.get<WorkspacesGetResponse>(
11
- '/workspaces/get',
12
- {
13
- params,
14
- },
15
- )
16
- return data.workspace
17
- }
18
- }
19
-
20
- export type WorkspacesGetParams = SetNonNullable<
21
- Required<RouteRequestParams<'/workspaces/get'>>
22
- >
23
-
24
- export type WorkspacesGetResponse = SetNonNullable<
25
- Required<RouteResponse<'/workspaces/get'>>
26
- >