@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,187 @@
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 { RouteRequestBody, RouteResponse } from '@seamapi/types/connect'
7
+ import type { Axios } from 'axios'
8
+ import type { SetNonNullable } from 'type-fest'
9
+
10
+ import { createAxiosClient } from 'lib/seam/connect/axios.js'
11
+ import {
12
+ isSeamHttpOptionsWithApiKey,
13
+ isSeamHttpOptionsWithClient,
14
+ isSeamHttpOptionsWithClientSessionToken,
15
+ SeamHttpInvalidOptionsError,
16
+ type SeamHttpOptions,
17
+ type SeamHttpOptionsWithApiKey,
18
+ type SeamHttpOptionsWithClient,
19
+ type SeamHttpOptionsWithClientSessionToken,
20
+ } from 'lib/seam/connect/client-options.js'
21
+ import { parseOptions } from 'lib/seam/connect/parse-options.js'
22
+
23
+ export class SeamHttpAcsUsers {
24
+ client: Axios
25
+
26
+ constructor(apiKeyOrOptions: string | SeamHttpOptions) {
27
+ const options = parseOptions(apiKeyOrOptions)
28
+ this.client = createAxiosClient(options)
29
+ }
30
+
31
+ static fromClient(
32
+ client: SeamHttpOptionsWithClient['client'],
33
+ options: Omit<SeamHttpOptionsWithClient, 'client'> = {},
34
+ ): SeamHttpAcsUsers {
35
+ const opts = { ...options, client }
36
+ if (!isSeamHttpOptionsWithClient(opts)) {
37
+ throw new SeamHttpInvalidOptionsError('Missing client')
38
+ }
39
+ return new SeamHttpAcsUsers(opts)
40
+ }
41
+
42
+ static fromApiKey(
43
+ apiKey: SeamHttpOptionsWithApiKey['apiKey'],
44
+ options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
45
+ ): SeamHttpAcsUsers {
46
+ const opts = { ...options, apiKey }
47
+ if (!isSeamHttpOptionsWithApiKey(opts)) {
48
+ throw new SeamHttpInvalidOptionsError('Missing apiKey')
49
+ }
50
+ return new SeamHttpAcsUsers(opts)
51
+ }
52
+
53
+ static fromClientSessionToken(
54
+ clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
55
+ options: Omit<
56
+ SeamHttpOptionsWithClientSessionToken,
57
+ 'clientSessionToken'
58
+ > = {},
59
+ ): SeamHttpAcsUsers {
60
+ const opts = { ...options, clientSessionToken }
61
+ if (!isSeamHttpOptionsWithClientSessionToken(opts)) {
62
+ throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
63
+ }
64
+ return new SeamHttpAcsUsers(opts)
65
+ }
66
+
67
+ async addToAccessGroup(body: AcsUsersAddToAccessGroupBody): Promise<void> {
68
+ await this.client.request<AcsUsersAddToAccessGroupResponse>({
69
+ url: '/acs/users/add_to_access_group',
70
+ method: 'post',
71
+ data: body,
72
+ })
73
+ }
74
+
75
+ async create(
76
+ body: AcsUsersCreateBody,
77
+ ): Promise<AcsUsersCreateResponse['acs_user']> {
78
+ const { data } = await this.client.request<AcsUsersCreateResponse>({
79
+ url: '/acs/users/create',
80
+ method: 'post',
81
+ data: body,
82
+ })
83
+ return data.acs_user
84
+ }
85
+
86
+ async delete(body: AcsUsersDeleteBody): Promise<void> {
87
+ await this.client.request<AcsUsersDeleteResponse>({
88
+ url: '/acs/users/delete',
89
+ method: 'post',
90
+ data: body,
91
+ })
92
+ }
93
+
94
+ async get(body: AcsUsersGetBody): Promise<AcsUsersGetResponse['acs_user']> {
95
+ const { data } = await this.client.request<AcsUsersGetResponse>({
96
+ url: '/acs/users/get',
97
+ method: 'post',
98
+ data: body,
99
+ })
100
+ return data.acs_user
101
+ }
102
+
103
+ async list(
104
+ body: AcsUsersListBody,
105
+ ): Promise<AcsUsersListResponse['acs_users']> {
106
+ const { data } = await this.client.request<AcsUsersListResponse>({
107
+ url: '/acs/users/list',
108
+ method: 'post',
109
+ data: body,
110
+ })
111
+ return data.acs_users
112
+ }
113
+
114
+ async removeFromAccessGroup(
115
+ body: AcsUsersRemoveFromAccessGroupBody,
116
+ ): Promise<void> {
117
+ await this.client.request<AcsUsersRemoveFromAccessGroupResponse>({
118
+ url: '/acs/users/remove_from_access_group',
119
+ method: 'post',
120
+ data: body,
121
+ })
122
+ }
123
+
124
+ async update(body: AcsUsersUpdateBody): Promise<void> {
125
+ await this.client.request<AcsUsersUpdateResponse>({
126
+ url: '/acs/users/update',
127
+ method: 'post',
128
+ data: body,
129
+ })
130
+ }
131
+ }
132
+
133
+ export type AcsUsersAddToAccessGroupBody = SetNonNullable<
134
+ Required<RouteRequestBody<'/acs/users/add_to_access_group'>>
135
+ >
136
+
137
+ export type AcsUsersAddToAccessGroupResponse = SetNonNullable<
138
+ Required<RouteResponse<'/acs/users/add_to_access_group'>>
139
+ >
140
+
141
+ export type AcsUsersCreateBody = SetNonNullable<
142
+ Required<RouteRequestBody<'/acs/users/create'>>
143
+ >
144
+
145
+ export type AcsUsersCreateResponse = SetNonNullable<
146
+ Required<RouteResponse<'/acs/users/create'>>
147
+ >
148
+
149
+ export type AcsUsersDeleteBody = SetNonNullable<
150
+ Required<RouteRequestBody<'/acs/users/delete'>>
151
+ >
152
+
153
+ export type AcsUsersDeleteResponse = SetNonNullable<
154
+ Required<RouteResponse<'/acs/users/delete'>>
155
+ >
156
+
157
+ export type AcsUsersGetBody = SetNonNullable<
158
+ Required<RouteRequestBody<'/acs/users/get'>>
159
+ >
160
+
161
+ export type AcsUsersGetResponse = SetNonNullable<
162
+ Required<RouteResponse<'/acs/users/get'>>
163
+ >
164
+
165
+ export type AcsUsersListBody = SetNonNullable<
166
+ Required<RouteRequestBody<'/acs/users/list'>>
167
+ >
168
+
169
+ export type AcsUsersListResponse = SetNonNullable<
170
+ Required<RouteResponse<'/acs/users/list'>>
171
+ >
172
+
173
+ export type AcsUsersRemoveFromAccessGroupBody = SetNonNullable<
174
+ Required<RouteRequestBody<'/acs/users/remove_from_access_group'>>
175
+ >
176
+
177
+ export type AcsUsersRemoveFromAccessGroupResponse = SetNonNullable<
178
+ Required<RouteResponse<'/acs/users/remove_from_access_group'>>
179
+ >
180
+
181
+ export type AcsUsersUpdateBody = SetNonNullable<
182
+ Required<RouteRequestBody<'/acs/users/update'>>
183
+ >
184
+
185
+ export type AcsUsersUpdateResponse = SetNonNullable<
186
+ Required<RouteResponse<'/acs/users/update'>>
187
+ >
@@ -0,0 +1,85 @@
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 { Axios } from 'axios'
7
+
8
+ import { createAxiosClient } from 'lib/seam/connect/axios.js'
9
+ import {
10
+ isSeamHttpOptionsWithApiKey,
11
+ isSeamHttpOptionsWithClient,
12
+ isSeamHttpOptionsWithClientSessionToken,
13
+ SeamHttpInvalidOptionsError,
14
+ type SeamHttpOptions,
15
+ type SeamHttpOptionsWithApiKey,
16
+ type SeamHttpOptionsWithClient,
17
+ type SeamHttpOptionsWithClientSessionToken,
18
+ } from 'lib/seam/connect/client-options.js'
19
+ import { parseOptions } from 'lib/seam/connect/parse-options.js'
20
+
21
+ import { SeamHttpAcsAccessGroups } from './acs-access-groups.js'
22
+ import { SeamHttpAcsCredentials } from './acs-credentials.js'
23
+ import { SeamHttpAcsSystems } from './acs-systems.js'
24
+ import { SeamHttpAcsUsers } from './acs-users.js'
25
+
26
+ export class SeamHttpAcs {
27
+ client: Axios
28
+
29
+ constructor(apiKeyOrOptions: string | SeamHttpOptions) {
30
+ const options = parseOptions(apiKeyOrOptions)
31
+ this.client = createAxiosClient(options)
32
+ }
33
+
34
+ static fromClient(
35
+ client: SeamHttpOptionsWithClient['client'],
36
+ options: Omit<SeamHttpOptionsWithClient, 'client'> = {},
37
+ ): SeamHttpAcs {
38
+ const opts = { ...options, client }
39
+ if (!isSeamHttpOptionsWithClient(opts)) {
40
+ throw new SeamHttpInvalidOptionsError('Missing client')
41
+ }
42
+ return new SeamHttpAcs(opts)
43
+ }
44
+
45
+ static fromApiKey(
46
+ apiKey: SeamHttpOptionsWithApiKey['apiKey'],
47
+ options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
48
+ ): SeamHttpAcs {
49
+ const opts = { ...options, apiKey }
50
+ if (!isSeamHttpOptionsWithApiKey(opts)) {
51
+ throw new SeamHttpInvalidOptionsError('Missing apiKey')
52
+ }
53
+ return new SeamHttpAcs(opts)
54
+ }
55
+
56
+ static fromClientSessionToken(
57
+ clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
58
+ options: Omit<
59
+ SeamHttpOptionsWithClientSessionToken,
60
+ 'clientSessionToken'
61
+ > = {},
62
+ ): SeamHttpAcs {
63
+ const opts = { ...options, clientSessionToken }
64
+ if (!isSeamHttpOptionsWithClientSessionToken(opts)) {
65
+ throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
66
+ }
67
+ return new SeamHttpAcs(opts)
68
+ }
69
+
70
+ get accessGroups(): SeamHttpAcsAccessGroups {
71
+ return SeamHttpAcsAccessGroups.fromClient(this.client)
72
+ }
73
+
74
+ get credentials(): SeamHttpAcsCredentials {
75
+ return SeamHttpAcsCredentials.fromClient(this.client)
76
+ }
77
+
78
+ get systems(): SeamHttpAcsSystems {
79
+ return SeamHttpAcsSystems.fromClient(this.client)
80
+ }
81
+
82
+ get users(): SeamHttpAcsUsers {
83
+ return SeamHttpAcsUsers.fromClient(this.client)
84
+ }
85
+ }
@@ -0,0 +1,104 @@
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 { RouteRequestBody, RouteResponse } from '@seamapi/types/connect'
7
+ import type { Axios } from 'axios'
8
+ import type { SetNonNullable } from 'type-fest'
9
+
10
+ import { createAxiosClient } from 'lib/seam/connect/axios.js'
11
+ import {
12
+ isSeamHttpOptionsWithApiKey,
13
+ isSeamHttpOptionsWithClient,
14
+ isSeamHttpOptionsWithClientSessionToken,
15
+ SeamHttpInvalidOptionsError,
16
+ type SeamHttpOptions,
17
+ type SeamHttpOptionsWithApiKey,
18
+ type SeamHttpOptionsWithClient,
19
+ type SeamHttpOptionsWithClientSessionToken,
20
+ } from 'lib/seam/connect/client-options.js'
21
+ import { parseOptions } from 'lib/seam/connect/parse-options.js'
22
+
23
+ export class SeamHttpActionAttempts {
24
+ client: Axios
25
+
26
+ constructor(apiKeyOrOptions: string | SeamHttpOptions) {
27
+ const options = parseOptions(apiKeyOrOptions)
28
+ this.client = createAxiosClient(options)
29
+ }
30
+
31
+ static fromClient(
32
+ client: SeamHttpOptionsWithClient['client'],
33
+ options: Omit<SeamHttpOptionsWithClient, 'client'> = {},
34
+ ): SeamHttpActionAttempts {
35
+ const opts = { ...options, client }
36
+ if (!isSeamHttpOptionsWithClient(opts)) {
37
+ throw new SeamHttpInvalidOptionsError('Missing client')
38
+ }
39
+ return new SeamHttpActionAttempts(opts)
40
+ }
41
+
42
+ static fromApiKey(
43
+ apiKey: SeamHttpOptionsWithApiKey['apiKey'],
44
+ options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
45
+ ): SeamHttpActionAttempts {
46
+ const opts = { ...options, apiKey }
47
+ if (!isSeamHttpOptionsWithApiKey(opts)) {
48
+ throw new SeamHttpInvalidOptionsError('Missing apiKey')
49
+ }
50
+ return new SeamHttpActionAttempts(opts)
51
+ }
52
+
53
+ static fromClientSessionToken(
54
+ clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
55
+ options: Omit<
56
+ SeamHttpOptionsWithClientSessionToken,
57
+ 'clientSessionToken'
58
+ > = {},
59
+ ): SeamHttpActionAttempts {
60
+ const opts = { ...options, clientSessionToken }
61
+ if (!isSeamHttpOptionsWithClientSessionToken(opts)) {
62
+ throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
63
+ }
64
+ return new SeamHttpActionAttempts(opts)
65
+ }
66
+
67
+ async get(
68
+ body: ActionAttemptsGetBody,
69
+ ): Promise<ActionAttemptsGetResponse['action_attempt']> {
70
+ const { data } = await this.client.request<ActionAttemptsGetResponse>({
71
+ url: '/action_attempts/get',
72
+ method: 'post',
73
+ data: body,
74
+ })
75
+ return data.action_attempt
76
+ }
77
+
78
+ async list(
79
+ body: ActionAttemptsListBody,
80
+ ): Promise<ActionAttemptsListResponse['action_attempts']> {
81
+ const { data } = await this.client.request<ActionAttemptsListResponse>({
82
+ url: '/action_attempts/list',
83
+ method: 'post',
84
+ data: body,
85
+ })
86
+ return data.action_attempts
87
+ }
88
+ }
89
+
90
+ export type ActionAttemptsGetBody = SetNonNullable<
91
+ Required<RouteRequestBody<'/action_attempts/get'>>
92
+ >
93
+
94
+ export type ActionAttemptsGetResponse = SetNonNullable<
95
+ Required<RouteResponse<'/action_attempts/get'>>
96
+ >
97
+
98
+ export type ActionAttemptsListBody = SetNonNullable<
99
+ Required<RouteRequestBody<'/action_attempts/list'>>
100
+ >
101
+
102
+ export type ActionAttemptsListResponse = SetNonNullable<
103
+ Required<RouteResponse<'/action_attempts/list'>>
104
+ >
@@ -0,0 +1,159 @@
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 { RouteRequestBody, RouteResponse } from '@seamapi/types/connect'
7
+ import type { Axios } from 'axios'
8
+ import type { SetNonNullable } from 'type-fest'
9
+
10
+ import { createAxiosClient } from 'lib/seam/connect/axios.js'
11
+ import {
12
+ isSeamHttpOptionsWithApiKey,
13
+ isSeamHttpOptionsWithClient,
14
+ isSeamHttpOptionsWithClientSessionToken,
15
+ SeamHttpInvalidOptionsError,
16
+ type SeamHttpOptions,
17
+ type SeamHttpOptionsWithApiKey,
18
+ type SeamHttpOptionsWithClient,
19
+ type SeamHttpOptionsWithClientSessionToken,
20
+ } from 'lib/seam/connect/client-options.js'
21
+ import { parseOptions } from 'lib/seam/connect/parse-options.js'
22
+
23
+ export class SeamHttpClientSessions {
24
+ client: Axios
25
+
26
+ constructor(apiKeyOrOptions: string | SeamHttpOptions) {
27
+ const options = parseOptions(apiKeyOrOptions)
28
+ this.client = createAxiosClient(options)
29
+ }
30
+
31
+ static fromClient(
32
+ client: SeamHttpOptionsWithClient['client'],
33
+ options: Omit<SeamHttpOptionsWithClient, 'client'> = {},
34
+ ): SeamHttpClientSessions {
35
+ const opts = { ...options, client }
36
+ if (!isSeamHttpOptionsWithClient(opts)) {
37
+ throw new SeamHttpInvalidOptionsError('Missing client')
38
+ }
39
+ return new SeamHttpClientSessions(opts)
40
+ }
41
+
42
+ static fromApiKey(
43
+ apiKey: SeamHttpOptionsWithApiKey['apiKey'],
44
+ options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
45
+ ): SeamHttpClientSessions {
46
+ const opts = { ...options, apiKey }
47
+ if (!isSeamHttpOptionsWithApiKey(opts)) {
48
+ throw new SeamHttpInvalidOptionsError('Missing apiKey')
49
+ }
50
+ return new SeamHttpClientSessions(opts)
51
+ }
52
+
53
+ static fromClientSessionToken(
54
+ clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
55
+ options: Omit<
56
+ SeamHttpOptionsWithClientSessionToken,
57
+ 'clientSessionToken'
58
+ > = {},
59
+ ): SeamHttpClientSessions {
60
+ const opts = { ...options, clientSessionToken }
61
+ if (!isSeamHttpOptionsWithClientSessionToken(opts)) {
62
+ throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
63
+ }
64
+ return new SeamHttpClientSessions(opts)
65
+ }
66
+
67
+ async create(
68
+ body: ClientSessionsCreateBody,
69
+ ): Promise<ClientSessionsCreateResponse['client_session']> {
70
+ const { data } = await this.client.request<ClientSessionsCreateResponse>({
71
+ url: '/client_sessions/create',
72
+ method: 'post',
73
+ data: body,
74
+ })
75
+ return data.client_session
76
+ }
77
+
78
+ async delete(body: ClientSessionsDeleteBody): Promise<void> {
79
+ await this.client.request<ClientSessionsDeleteResponse>({
80
+ url: '/client_sessions/delete',
81
+ method: 'post',
82
+ data: body,
83
+ })
84
+ }
85
+
86
+ async get(
87
+ body: ClientSessionsGetBody,
88
+ ): Promise<ClientSessionsGetResponse['client_session']> {
89
+ const { data } = await this.client.request<ClientSessionsGetResponse>({
90
+ url: '/client_sessions/get',
91
+ method: 'post',
92
+ data: body,
93
+ })
94
+ return data.client_session
95
+ }
96
+
97
+ async grantAccess(
98
+ body: ClientSessionsGrantAccessBody,
99
+ ): Promise<ClientSessionsGrantAccessResponse['client_session']> {
100
+ const { data } =
101
+ await this.client.request<ClientSessionsGrantAccessResponse>({
102
+ url: '/client_sessions/grant_access',
103
+ method: 'post',
104
+ data: body,
105
+ })
106
+ return data.client_session
107
+ }
108
+
109
+ async list(
110
+ body: ClientSessionsListBody,
111
+ ): Promise<ClientSessionsListResponse['client_sessions']> {
112
+ const { data } = await this.client.request<ClientSessionsListResponse>({
113
+ url: '/client_sessions/list',
114
+ method: 'post',
115
+ data: body,
116
+ })
117
+ return data.client_sessions
118
+ }
119
+ }
120
+
121
+ export type ClientSessionsCreateBody = SetNonNullable<
122
+ Required<RouteRequestBody<'/client_sessions/create'>>
123
+ >
124
+
125
+ export type ClientSessionsCreateResponse = SetNonNullable<
126
+ Required<RouteResponse<'/client_sessions/create'>>
127
+ >
128
+
129
+ export type ClientSessionsDeleteBody = SetNonNullable<
130
+ Required<RouteRequestBody<'/client_sessions/delete'>>
131
+ >
132
+
133
+ export type ClientSessionsDeleteResponse = SetNonNullable<
134
+ Required<RouteResponse<'/client_sessions/delete'>>
135
+ >
136
+
137
+ export type ClientSessionsGetBody = SetNonNullable<
138
+ Required<RouteRequestBody<'/client_sessions/get'>>
139
+ >
140
+
141
+ export type ClientSessionsGetResponse = SetNonNullable<
142
+ Required<RouteResponse<'/client_sessions/get'>>
143
+ >
144
+
145
+ export type ClientSessionsGrantAccessBody = SetNonNullable<
146
+ Required<RouteRequestBody<'/client_sessions/grant_access'>>
147
+ >
148
+
149
+ export type ClientSessionsGrantAccessResponse = SetNonNullable<
150
+ Required<RouteResponse<'/client_sessions/grant_access'>>
151
+ >
152
+
153
+ export type ClientSessionsListBody = SetNonNullable<
154
+ Required<RouteRequestBody<'/client_sessions/list'>>
155
+ >
156
+
157
+ export type ClientSessionsListResponse = SetNonNullable<
158
+ Required<RouteResponse<'/client_sessions/list'>>
159
+ >
@@ -0,0 +1,159 @@
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 SeamHttpConnectWebviews {
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
+ ): SeamHttpConnectWebviews {
39
+ const opts = { ...options, client }
40
+ if (!isSeamHttpOptionsWithClient(opts)) {
41
+ throw new SeamHttpInvalidOptionsError('Missing client')
42
+ }
43
+ return new SeamHttpConnectWebviews(opts)
44
+ }
45
+
46
+ static fromApiKey(
47
+ apiKey: SeamHttpOptionsWithApiKey['apiKey'],
48
+ options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
49
+ ): SeamHttpConnectWebviews {
50
+ const opts = { ...options, apiKey }
51
+ if (!isSeamHttpOptionsWithApiKey(opts)) {
52
+ throw new SeamHttpInvalidOptionsError('Missing apiKey')
53
+ }
54
+ return new SeamHttpConnectWebviews(opts)
55
+ }
56
+
57
+ static fromClientSessionToken(
58
+ clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
59
+ options: Omit<
60
+ SeamHttpOptionsWithClientSessionToken,
61
+ 'clientSessionToken'
62
+ > = {},
63
+ ): SeamHttpConnectWebviews {
64
+ const opts = { ...options, clientSessionToken }
65
+ if (!isSeamHttpOptionsWithClientSessionToken(opts)) {
66
+ throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
67
+ }
68
+ return new SeamHttpConnectWebviews(opts)
69
+ }
70
+
71
+ async create(
72
+ body: ConnectWebviewsCreateBody,
73
+ ): Promise<ConnectWebviewsCreateResponse['connect_webview']> {
74
+ const { data } = await this.client.request<ConnectWebviewsCreateResponse>({
75
+ url: '/connect_webviews/create',
76
+ method: 'post',
77
+ data: body,
78
+ })
79
+ return data.connect_webview
80
+ }
81
+
82
+ async delete(body: ConnectWebviewsDeleteBody): Promise<void> {
83
+ await this.client.request<ConnectWebviewsDeleteResponse>({
84
+ url: '/connect_webviews/delete',
85
+ method: 'post',
86
+ data: body,
87
+ })
88
+ }
89
+
90
+ async get(
91
+ body: ConnectWebviewsGetBody,
92
+ ): Promise<ConnectWebviewsGetResponse['connect_webview']> {
93
+ const { data } = await this.client.request<ConnectWebviewsGetResponse>({
94
+ url: '/connect_webviews/get',
95
+ method: 'post',
96
+ data: body,
97
+ })
98
+ return data.connect_webview
99
+ }
100
+
101
+ async list(
102
+ params?: ConnectWebviewsListParams,
103
+ ): Promise<ConnectWebviewsListResponse['connect_webviews']> {
104
+ const { data } = await this.client.request<ConnectWebviewsListResponse>({
105
+ url: '/connect_webviews/list',
106
+ method: 'get',
107
+ params,
108
+ })
109
+ return data.connect_webviews
110
+ }
111
+
112
+ async view(params?: ConnectWebviewsViewParams): Promise<void> {
113
+ await this.client.request<ConnectWebviewsViewResponse>({
114
+ url: '/connect_webviews/view',
115
+ method: 'get',
116
+ params,
117
+ })
118
+ }
119
+ }
120
+
121
+ export type ConnectWebviewsCreateBody = SetNonNullable<
122
+ Required<RouteRequestBody<'/connect_webviews/create'>>
123
+ >
124
+
125
+ export type ConnectWebviewsCreateResponse = SetNonNullable<
126
+ Required<RouteResponse<'/connect_webviews/create'>>
127
+ >
128
+
129
+ export type ConnectWebviewsDeleteBody = SetNonNullable<
130
+ Required<RouteRequestBody<'/connect_webviews/delete'>>
131
+ >
132
+
133
+ export type ConnectWebviewsDeleteResponse = SetNonNullable<
134
+ Required<RouteResponse<'/connect_webviews/delete'>>
135
+ >
136
+
137
+ export type ConnectWebviewsGetBody = SetNonNullable<
138
+ Required<RouteRequestBody<'/connect_webviews/get'>>
139
+ >
140
+
141
+ export type ConnectWebviewsGetResponse = SetNonNullable<
142
+ Required<RouteResponse<'/connect_webviews/get'>>
143
+ >
144
+
145
+ export type ConnectWebviewsListParams = SetNonNullable<
146
+ Required<RouteRequestParams<'/connect_webviews/list'>>
147
+ >
148
+
149
+ export type ConnectWebviewsListResponse = SetNonNullable<
150
+ Required<RouteResponse<'/connect_webviews/list'>>
151
+ >
152
+
153
+ export type ConnectWebviewsViewParams = SetNonNullable<
154
+ Required<RouteRequestParams<'/connect_webviews/view'>>
155
+ >
156
+
157
+ export type ConnectWebviewsViewResponse = SetNonNullable<
158
+ Required<RouteResponse<'/connect_webviews/view'>>
159
+ >