@seamapi/http 0.0.2 → 0.2.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 (132) hide show
  1. package/dist/connect.cjs +1807 -96
  2. package/dist/connect.cjs.map +1 -1
  3. package/dist/connect.d.cts +472 -15
  4. package/lib/params-serializer.d.ts +5 -0
  5. package/lib/params-serializer.js +42 -0
  6. package/lib/params-serializer.js.map +1 -0
  7. package/lib/seam/connect/auth.d.ts +4 -3
  8. package/lib/seam/connect/auth.js +59 -8
  9. package/lib/seam/connect/auth.js.map +1 -1
  10. package/lib/seam/connect/client.d.ts +10 -10
  11. package/lib/seam/connect/client.js +16 -49
  12. package/lib/seam/connect/client.js.map +1 -1
  13. package/lib/seam/connect/index.d.ts +2 -1
  14. package/lib/seam/connect/index.js +2 -1
  15. package/lib/seam/connect/index.js.map +1 -1
  16. package/lib/seam/connect/options.d.ts +23 -0
  17. package/lib/seam/connect/options.js +39 -0
  18. package/lib/seam/connect/options.js.map +1 -0
  19. package/lib/seam/connect/parse-options.d.ts +6 -2
  20. package/lib/seam/connect/parse-options.js +35 -10
  21. package/lib/seam/connect/parse-options.js.map +1 -1
  22. package/lib/seam/connect/routes/access-codes-unmanaged.d.ts +27 -0
  23. package/lib/seam/connect/routes/access-codes-unmanaged.js +84 -0
  24. package/lib/seam/connect/routes/access-codes-unmanaged.js.map +1 -0
  25. package/lib/seam/connect/routes/access-codes.d.ts +38 -0
  26. package/lib/seam/connect/routes/access-codes.js +113 -0
  27. package/lib/seam/connect/routes/access-codes.js.map +1 -0
  28. package/lib/seam/connect/routes/acs-access-groups.d.ts +36 -0
  29. package/lib/seam/connect/routes/acs-access-groups.js +107 -0
  30. package/lib/seam/connect/routes/acs-access-groups.js.map +1 -0
  31. package/lib/seam/connect/routes/acs-credentials.d.ts +24 -0
  32. package/lib/seam/connect/routes/acs-credentials.js +78 -0
  33. package/lib/seam/connect/routes/acs-credentials.js.map +1 -0
  34. package/lib/seam/connect/routes/acs-systems.d.ts +18 -0
  35. package/lib/seam/connect/routes/acs-systems.js +63 -0
  36. package/lib/seam/connect/routes/acs-systems.js.map +1 -0
  37. package/lib/seam/connect/routes/acs-users.d.ts +39 -0
  38. package/lib/seam/connect/routes/acs-users.js +113 -0
  39. package/lib/seam/connect/routes/acs-users.js.map +1 -0
  40. package/lib/seam/connect/routes/acs.d.ts +18 -0
  41. package/lib/seam/connect/routes/acs.js +63 -0
  42. package/lib/seam/connect/routes/acs.js.map +1 -0
  43. package/lib/seam/connect/routes/action-attempts.d.ts +18 -0
  44. package/lib/seam/connect/routes/action-attempts.js +63 -0
  45. package/lib/seam/connect/routes/action-attempts.js.map +1 -0
  46. package/lib/seam/connect/routes/client-sessions.d.ts +30 -0
  47. package/lib/seam/connect/routes/client-sessions.js +93 -0
  48. package/lib/seam/connect/routes/client-sessions.js.map +1 -0
  49. package/lib/seam/connect/routes/connect-webviews.d.ts +27 -0
  50. package/lib/seam/connect/routes/connect-webviews.js +85 -0
  51. package/lib/seam/connect/routes/connect-webviews.js.map +1 -0
  52. package/lib/seam/connect/routes/connected-accounts.d.ts +21 -0
  53. package/lib/seam/connect/routes/connected-accounts.js +70 -0
  54. package/lib/seam/connect/routes/connected-accounts.js.map +1 -0
  55. package/lib/seam/connect/routes/devices-unmanaged.d.ts +21 -0
  56. package/lib/seam/connect/routes/devices-unmanaged.js +70 -0
  57. package/lib/seam/connect/routes/devices-unmanaged.js.map +1 -0
  58. package/lib/seam/connect/routes/devices.d.ts +29 -0
  59. package/lib/seam/connect/routes/devices.js +89 -0
  60. package/lib/seam/connect/routes/devices.js.map +1 -0
  61. package/lib/seam/connect/routes/events.d.ts +18 -0
  62. package/lib/seam/connect/routes/events.js +63 -0
  63. package/lib/seam/connect/routes/events.js.map +1 -0
  64. package/lib/seam/connect/routes/index.d.ts +21 -0
  65. package/lib/seam/connect/routes/index.js +22 -0
  66. package/lib/seam/connect/routes/index.js.map +1 -0
  67. package/lib/seam/connect/routes/locks.d.ts +24 -0
  68. package/lib/seam/connect/routes/locks.js +79 -0
  69. package/lib/seam/connect/routes/locks.js.map +1 -0
  70. package/lib/seam/connect/routes/noise-sensors-noise-thresholds.d.ts +27 -0
  71. package/lib/seam/connect/routes/noise-sensors-noise-thresholds.js +84 -0
  72. package/lib/seam/connect/routes/noise-sensors-noise-thresholds.js.map +1 -0
  73. package/lib/seam/connect/routes/noise-sensors.d.ts +12 -0
  74. package/lib/seam/connect/routes/noise-sensors.js +51 -0
  75. package/lib/seam/connect/routes/noise-sensors.js.map +1 -0
  76. package/lib/seam/connect/routes/thermostats-climate-setting-schedules.d.ts +27 -0
  77. package/lib/seam/connect/routes/thermostats-climate-setting-schedules.js +85 -0
  78. package/lib/seam/connect/routes/thermostats-climate-setting-schedules.js.map +1 -0
  79. package/lib/seam/connect/routes/thermostats.d.ts +38 -0
  80. package/lib/seam/connect/routes/thermostats.js +109 -0
  81. package/lib/seam/connect/routes/thermostats.js.map +1 -0
  82. package/lib/seam/connect/routes/webhooks.d.ts +24 -0
  83. package/lib/seam/connect/routes/webhooks.js +78 -0
  84. package/lib/seam/connect/routes/webhooks.js.map +1 -0
  85. package/lib/seam/connect/routes/workspaces.d.ts +17 -7
  86. package/lib/seam/connect/routes/workspaces.js +61 -11
  87. package/lib/seam/connect/routes/workspaces.js.map +1 -1
  88. package/lib/seam/connect/seam-http.d.ts +24 -0
  89. package/lib/seam/connect/seam-http.js +82 -0
  90. package/lib/seam/connect/seam-http.js.map +1 -0
  91. package/package.json +9 -3
  92. package/src/lib/params-serializer.ts +55 -0
  93. package/src/lib/seam/connect/auth.ts +101 -13
  94. package/src/lib/seam/connect/client.ts +30 -62
  95. package/src/lib/seam/connect/env.d.ts +11 -0
  96. package/src/lib/seam/connect/index.ts +2 -1
  97. package/src/lib/seam/connect/{client-options.ts → options.ts} +37 -15
  98. package/src/lib/seam/connect/parse-options.ts +55 -14
  99. package/src/lib/seam/connect/routes/access-codes-unmanaged.ts +170 -0
  100. package/src/lib/seam/connect/routes/access-codes.ts +226 -0
  101. package/src/lib/seam/connect/routes/acs-access-groups.ts +216 -0
  102. package/src/lib/seam/connect/routes/acs-credentials.ts +151 -0
  103. package/src/lib/seam/connect/routes/acs-systems.ts +118 -0
  104. package/src/lib/seam/connect/routes/acs-users.ts +221 -0
  105. package/src/lib/seam/connect/routes/acs.ts +101 -0
  106. package/src/lib/seam/connect/routes/action-attempts.ts +118 -0
  107. package/src/lib/seam/connect/routes/client-sessions.ts +187 -0
  108. package/src/lib/seam/connect/routes/connect-webviews.ts +170 -0
  109. package/src/lib/seam/connect/routes/connected-accounts.ts +139 -0
  110. package/src/lib/seam/connect/routes/devices-unmanaged.ts +134 -0
  111. package/src/lib/seam/connect/routes/devices.ts +166 -0
  112. package/src/lib/seam/connect/routes/events.ts +114 -0
  113. package/src/lib/seam/connect/routes/index.ts +21 -0
  114. package/src/lib/seam/connect/routes/locks.ts +148 -0
  115. package/src/lib/seam/connect/routes/noise-sensors-noise-thresholds.ts +170 -0
  116. package/src/lib/seam/connect/routes/noise-sensors.ts +86 -0
  117. package/src/lib/seam/connect/routes/thermostats-climate-setting-schedules.ts +192 -0
  118. package/src/lib/seam/connect/routes/thermostats.ts +208 -0
  119. package/src/lib/seam/connect/routes/webhooks.ts +151 -0
  120. package/src/lib/seam/connect/routes/workspaces.ts +118 -22
  121. package/src/lib/seam/connect/seam-http.ts +141 -0
  122. package/lib/seam/connect/axios.d.ts +0 -3
  123. package/lib/seam/connect/axios.js +0 -17
  124. package/lib/seam/connect/axios.js.map +0 -1
  125. package/lib/seam/connect/client-options.d.ts +0 -19
  126. package/lib/seam/connect/client-options.js +0 -29
  127. package/lib/seam/connect/client-options.js.map +0 -1
  128. package/lib/seam/connect/legacy/workspaces.d.ts +0 -8
  129. package/lib/seam/connect/legacy/workspaces.js +0 -10
  130. package/lib/seam/connect/legacy/workspaces.js.map +0 -1
  131. package/src/lib/seam/connect/axios.ts +0 -23
  132. package/src/lib/seam/connect/legacy/workspaces.ts +0 -26
@@ -0,0 +1,151 @@
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 { SetNonNullable } from 'type-fest'
8
+
9
+ import { warnOnInsecureuserIdentifierKey } from 'lib/seam/connect/auth.js'
10
+ import { type Client, createClient } from 'lib/seam/connect/client.js'
11
+ import {
12
+ isSeamHttpOptionsWithApiKey,
13
+ isSeamHttpOptionsWithClient,
14
+ isSeamHttpOptionsWithClientSessionToken,
15
+ type SeamHttpFromPublishableKeyOptions,
16
+ SeamHttpInvalidOptionsError,
17
+ type SeamHttpOptions,
18
+ type SeamHttpOptionsWithApiKey,
19
+ type SeamHttpOptionsWithClient,
20
+ type SeamHttpOptionsWithClientSessionToken,
21
+ } from 'lib/seam/connect/options.js'
22
+ import { parseOptions } from 'lib/seam/connect/parse-options.js'
23
+
24
+ import { SeamHttpClientSessions } from './client-sessions.js'
25
+
26
+ export class SeamHttpAcsCredentials {
27
+ client: Client
28
+
29
+ constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
30
+ const clientOptions = parseOptions(apiKeyOrOptions)
31
+ this.client = createClient(clientOptions)
32
+ }
33
+
34
+ static fromClient(
35
+ client: SeamHttpOptionsWithClient['client'],
36
+ options: Omit<SeamHttpOptionsWithClient, 'client'> = {},
37
+ ): SeamHttpAcsCredentials {
38
+ const constructorOptions = { ...options, client }
39
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
40
+ throw new SeamHttpInvalidOptionsError('Missing client')
41
+ }
42
+ return new SeamHttpAcsCredentials(constructorOptions)
43
+ }
44
+
45
+ static fromApiKey(
46
+ apiKey: SeamHttpOptionsWithApiKey['apiKey'],
47
+ options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
48
+ ): SeamHttpAcsCredentials {
49
+ const constructorOptions = { ...options, apiKey }
50
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
51
+ throw new SeamHttpInvalidOptionsError('Missing apiKey')
52
+ }
53
+ return new SeamHttpAcsCredentials(constructorOptions)
54
+ }
55
+
56
+ static fromClientSessionToken(
57
+ clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
58
+ options: Omit<
59
+ SeamHttpOptionsWithClientSessionToken,
60
+ 'clientSessionToken'
61
+ > = {},
62
+ ): SeamHttpAcsCredentials {
63
+ const constructorOptions = { ...options, clientSessionToken }
64
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
65
+ throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
66
+ }
67
+ return new SeamHttpAcsCredentials(constructorOptions)
68
+ }
69
+
70
+ static async fromPublishableKey(
71
+ publishableKey: string,
72
+ userIdentifierKey: string,
73
+ options: SeamHttpFromPublishableKeyOptions = {},
74
+ ): Promise<SeamHttpAcsCredentials> {
75
+ warnOnInsecureuserIdentifierKey(userIdentifierKey)
76
+ const clientOptions = parseOptions({ ...options, publishableKey })
77
+ const client = createClient(clientOptions)
78
+ const clientSessions = SeamHttpClientSessions.fromClient(client)
79
+ const { token } = await clientSessions.getOrCreate({
80
+ user_identifier_key: userIdentifierKey,
81
+ })
82
+ return SeamHttpAcsCredentials.fromClientSessionToken(token, options)
83
+ }
84
+
85
+ async create(
86
+ body: AcsCredentialsCreateBody,
87
+ ): Promise<AcsCredentialsCreateResponse['acs_credential']> {
88
+ const { data } = await this.client.request<AcsCredentialsCreateResponse>({
89
+ url: '/acs/credentials/create',
90
+ method: 'post',
91
+ data: body,
92
+ })
93
+ return data.acs_credential
94
+ }
95
+
96
+ async delete(body: AcsCredentialsDeleteBody): Promise<void> {
97
+ await this.client.request<AcsCredentialsDeleteResponse>({
98
+ url: '/acs/credentials/delete',
99
+ method: 'post',
100
+ data: body,
101
+ })
102
+ }
103
+
104
+ async get(
105
+ body: AcsCredentialsGetBody,
106
+ ): Promise<AcsCredentialsGetResponse['acs_credential']> {
107
+ const { data } = await this.client.request<AcsCredentialsGetResponse>({
108
+ url: '/acs/credentials/get',
109
+ method: 'post',
110
+ data: body,
111
+ })
112
+ return data.acs_credential
113
+ }
114
+
115
+ async list(
116
+ body: AcsCredentialsListBody,
117
+ ): Promise<AcsCredentialsListResponse['acs_credentials']> {
118
+ const { data } = await this.client.request<AcsCredentialsListResponse>({
119
+ url: '/acs/credentials/list',
120
+ method: 'post',
121
+ data: body,
122
+ })
123
+ return data.acs_credentials
124
+ }
125
+ }
126
+
127
+ export type AcsCredentialsCreateBody =
128
+ RouteRequestBody<'/acs/credentials/create'>
129
+
130
+ export type AcsCredentialsCreateResponse = SetNonNullable<
131
+ Required<RouteResponse<'/acs/credentials/create'>>
132
+ >
133
+
134
+ export type AcsCredentialsDeleteBody =
135
+ RouteRequestBody<'/acs/credentials/delete'>
136
+
137
+ export type AcsCredentialsDeleteResponse = SetNonNullable<
138
+ Required<RouteResponse<'/acs/credentials/delete'>>
139
+ >
140
+
141
+ export type AcsCredentialsGetBody = RouteRequestBody<'/acs/credentials/get'>
142
+
143
+ export type AcsCredentialsGetResponse = SetNonNullable<
144
+ Required<RouteResponse<'/acs/credentials/get'>>
145
+ >
146
+
147
+ export type AcsCredentialsListBody = RouteRequestBody<'/acs/credentials/list'>
148
+
149
+ export type AcsCredentialsListResponse = SetNonNullable<
150
+ Required<RouteResponse<'/acs/credentials/list'>>
151
+ >
@@ -0,0 +1,118 @@
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 { SetNonNullable } from 'type-fest'
8
+
9
+ import { warnOnInsecureuserIdentifierKey } from 'lib/seam/connect/auth.js'
10
+ import { type Client, createClient } from 'lib/seam/connect/client.js'
11
+ import {
12
+ isSeamHttpOptionsWithApiKey,
13
+ isSeamHttpOptionsWithClient,
14
+ isSeamHttpOptionsWithClientSessionToken,
15
+ type SeamHttpFromPublishableKeyOptions,
16
+ SeamHttpInvalidOptionsError,
17
+ type SeamHttpOptions,
18
+ type SeamHttpOptionsWithApiKey,
19
+ type SeamHttpOptionsWithClient,
20
+ type SeamHttpOptionsWithClientSessionToken,
21
+ } from 'lib/seam/connect/options.js'
22
+ import { parseOptions } from 'lib/seam/connect/parse-options.js'
23
+
24
+ import { SeamHttpClientSessions } from './client-sessions.js'
25
+
26
+ export class SeamHttpAcsSystems {
27
+ client: Client
28
+
29
+ constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
30
+ const clientOptions = parseOptions(apiKeyOrOptions)
31
+ this.client = createClient(clientOptions)
32
+ }
33
+
34
+ static fromClient(
35
+ client: SeamHttpOptionsWithClient['client'],
36
+ options: Omit<SeamHttpOptionsWithClient, 'client'> = {},
37
+ ): SeamHttpAcsSystems {
38
+ const constructorOptions = { ...options, client }
39
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
40
+ throw new SeamHttpInvalidOptionsError('Missing client')
41
+ }
42
+ return new SeamHttpAcsSystems(constructorOptions)
43
+ }
44
+
45
+ static fromApiKey(
46
+ apiKey: SeamHttpOptionsWithApiKey['apiKey'],
47
+ options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
48
+ ): SeamHttpAcsSystems {
49
+ const constructorOptions = { ...options, apiKey }
50
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
51
+ throw new SeamHttpInvalidOptionsError('Missing apiKey')
52
+ }
53
+ return new SeamHttpAcsSystems(constructorOptions)
54
+ }
55
+
56
+ static fromClientSessionToken(
57
+ clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
58
+ options: Omit<
59
+ SeamHttpOptionsWithClientSessionToken,
60
+ 'clientSessionToken'
61
+ > = {},
62
+ ): SeamHttpAcsSystems {
63
+ const constructorOptions = { ...options, clientSessionToken }
64
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
65
+ throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
66
+ }
67
+ return new SeamHttpAcsSystems(constructorOptions)
68
+ }
69
+
70
+ static async fromPublishableKey(
71
+ publishableKey: string,
72
+ userIdentifierKey: string,
73
+ options: SeamHttpFromPublishableKeyOptions = {},
74
+ ): Promise<SeamHttpAcsSystems> {
75
+ warnOnInsecureuserIdentifierKey(userIdentifierKey)
76
+ const clientOptions = parseOptions({ ...options, publishableKey })
77
+ const client = createClient(clientOptions)
78
+ const clientSessions = SeamHttpClientSessions.fromClient(client)
79
+ const { token } = await clientSessions.getOrCreate({
80
+ user_identifier_key: userIdentifierKey,
81
+ })
82
+ return SeamHttpAcsSystems.fromClientSessionToken(token, options)
83
+ }
84
+
85
+ async get(
86
+ body: AcsSystemsGetBody,
87
+ ): Promise<AcsSystemsGetResponse['acs_system']> {
88
+ const { data } = await this.client.request<AcsSystemsGetResponse>({
89
+ url: '/acs/systems/get',
90
+ method: 'post',
91
+ data: body,
92
+ })
93
+ return data.acs_system
94
+ }
95
+
96
+ async list(
97
+ body: AcsSystemsListBody,
98
+ ): Promise<AcsSystemsListResponse['acs_systems']> {
99
+ const { data } = await this.client.request<AcsSystemsListResponse>({
100
+ url: '/acs/systems/list',
101
+ method: 'post',
102
+ data: body,
103
+ })
104
+ return data.acs_systems
105
+ }
106
+ }
107
+
108
+ export type AcsSystemsGetBody = RouteRequestBody<'/acs/systems/get'>
109
+
110
+ export type AcsSystemsGetResponse = SetNonNullable<
111
+ Required<RouteResponse<'/acs/systems/get'>>
112
+ >
113
+
114
+ export type AcsSystemsListBody = RouteRequestBody<'/acs/systems/list'>
115
+
116
+ export type AcsSystemsListResponse = SetNonNullable<
117
+ Required<RouteResponse<'/acs/systems/list'>>
118
+ >
@@ -0,0 +1,221 @@
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 { SetNonNullable } from 'type-fest'
8
+
9
+ import { warnOnInsecureuserIdentifierKey } from 'lib/seam/connect/auth.js'
10
+ import { type Client, createClient } from 'lib/seam/connect/client.js'
11
+ import {
12
+ isSeamHttpOptionsWithApiKey,
13
+ isSeamHttpOptionsWithClient,
14
+ isSeamHttpOptionsWithClientSessionToken,
15
+ type SeamHttpFromPublishableKeyOptions,
16
+ SeamHttpInvalidOptionsError,
17
+ type SeamHttpOptions,
18
+ type SeamHttpOptionsWithApiKey,
19
+ type SeamHttpOptionsWithClient,
20
+ type SeamHttpOptionsWithClientSessionToken,
21
+ } from 'lib/seam/connect/options.js'
22
+ import { parseOptions } from 'lib/seam/connect/parse-options.js'
23
+
24
+ import { SeamHttpClientSessions } from './client-sessions.js'
25
+
26
+ export class SeamHttpAcsUsers {
27
+ client: Client
28
+
29
+ constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
30
+ const clientOptions = parseOptions(apiKeyOrOptions)
31
+ this.client = createClient(clientOptions)
32
+ }
33
+
34
+ static fromClient(
35
+ client: SeamHttpOptionsWithClient['client'],
36
+ options: Omit<SeamHttpOptionsWithClient, 'client'> = {},
37
+ ): SeamHttpAcsUsers {
38
+ const constructorOptions = { ...options, client }
39
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
40
+ throw new SeamHttpInvalidOptionsError('Missing client')
41
+ }
42
+ return new SeamHttpAcsUsers(constructorOptions)
43
+ }
44
+
45
+ static fromApiKey(
46
+ apiKey: SeamHttpOptionsWithApiKey['apiKey'],
47
+ options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
48
+ ): SeamHttpAcsUsers {
49
+ const constructorOptions = { ...options, apiKey }
50
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
51
+ throw new SeamHttpInvalidOptionsError('Missing apiKey')
52
+ }
53
+ return new SeamHttpAcsUsers(constructorOptions)
54
+ }
55
+
56
+ static fromClientSessionToken(
57
+ clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
58
+ options: Omit<
59
+ SeamHttpOptionsWithClientSessionToken,
60
+ 'clientSessionToken'
61
+ > = {},
62
+ ): SeamHttpAcsUsers {
63
+ const constructorOptions = { ...options, clientSessionToken }
64
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
65
+ throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
66
+ }
67
+ return new SeamHttpAcsUsers(constructorOptions)
68
+ }
69
+
70
+ static async fromPublishableKey(
71
+ publishableKey: string,
72
+ userIdentifierKey: string,
73
+ options: SeamHttpFromPublishableKeyOptions = {},
74
+ ): Promise<SeamHttpAcsUsers> {
75
+ warnOnInsecureuserIdentifierKey(userIdentifierKey)
76
+ const clientOptions = parseOptions({ ...options, publishableKey })
77
+ const client = createClient(clientOptions)
78
+ const clientSessions = SeamHttpClientSessions.fromClient(client)
79
+ const { token } = await clientSessions.getOrCreate({
80
+ user_identifier_key: userIdentifierKey,
81
+ })
82
+ return SeamHttpAcsUsers.fromClientSessionToken(token, options)
83
+ }
84
+
85
+ async addToAccessGroup(body: AcsUsersAddToAccessGroupBody): Promise<void> {
86
+ await this.client.request<AcsUsersAddToAccessGroupResponse>({
87
+ url: '/acs/users/add_to_access_group',
88
+ method: 'post',
89
+ data: body,
90
+ })
91
+ }
92
+
93
+ async create(
94
+ body: AcsUsersCreateBody,
95
+ ): Promise<AcsUsersCreateResponse['acs_user']> {
96
+ const { data } = await this.client.request<AcsUsersCreateResponse>({
97
+ url: '/acs/users/create',
98
+ method: 'post',
99
+ data: body,
100
+ })
101
+ return data.acs_user
102
+ }
103
+
104
+ async delete(body: AcsUsersDeleteBody): Promise<void> {
105
+ await this.client.request<AcsUsersDeleteResponse>({
106
+ url: '/acs/users/delete',
107
+ method: 'post',
108
+ data: body,
109
+ })
110
+ }
111
+
112
+ async get(body: AcsUsersGetBody): Promise<AcsUsersGetResponse['acs_user']> {
113
+ const { data } = await this.client.request<AcsUsersGetResponse>({
114
+ url: '/acs/users/get',
115
+ method: 'post',
116
+ data: body,
117
+ })
118
+ return data.acs_user
119
+ }
120
+
121
+ async list(
122
+ body: AcsUsersListBody,
123
+ ): Promise<AcsUsersListResponse['acs_users']> {
124
+ const { data } = await this.client.request<AcsUsersListResponse>({
125
+ url: '/acs/users/list',
126
+ method: 'post',
127
+ data: body,
128
+ })
129
+ return data.acs_users
130
+ }
131
+
132
+ async removeFromAccessGroup(
133
+ body: AcsUsersRemoveFromAccessGroupBody,
134
+ ): Promise<void> {
135
+ await this.client.request<AcsUsersRemoveFromAccessGroupResponse>({
136
+ url: '/acs/users/remove_from_access_group',
137
+ method: 'post',
138
+ data: body,
139
+ })
140
+ }
141
+
142
+ async suspend(body: AcsUsersSuspendBody): Promise<void> {
143
+ await this.client.request<AcsUsersSuspendResponse>({
144
+ url: '/acs/users/suspend',
145
+ method: 'post',
146
+ data: body,
147
+ })
148
+ }
149
+
150
+ async unsuspend(body: AcsUsersUnsuspendBody): Promise<void> {
151
+ await this.client.request<AcsUsersUnsuspendResponse>({
152
+ url: '/acs/users/unsuspend',
153
+ method: 'post',
154
+ data: body,
155
+ })
156
+ }
157
+
158
+ async update(body: AcsUsersUpdateBody): Promise<void> {
159
+ await this.client.request<AcsUsersUpdateResponse>({
160
+ url: '/acs/users/update',
161
+ method: 'post',
162
+ data: body,
163
+ })
164
+ }
165
+ }
166
+
167
+ export type AcsUsersAddToAccessGroupBody =
168
+ RouteRequestBody<'/acs/users/add_to_access_group'>
169
+
170
+ export type AcsUsersAddToAccessGroupResponse = SetNonNullable<
171
+ Required<RouteResponse<'/acs/users/add_to_access_group'>>
172
+ >
173
+
174
+ export type AcsUsersCreateBody = RouteRequestBody<'/acs/users/create'>
175
+
176
+ export type AcsUsersCreateResponse = SetNonNullable<
177
+ Required<RouteResponse<'/acs/users/create'>>
178
+ >
179
+
180
+ export type AcsUsersDeleteBody = RouteRequestBody<'/acs/users/delete'>
181
+
182
+ export type AcsUsersDeleteResponse = SetNonNullable<
183
+ Required<RouteResponse<'/acs/users/delete'>>
184
+ >
185
+
186
+ export type AcsUsersGetBody = RouteRequestBody<'/acs/users/get'>
187
+
188
+ export type AcsUsersGetResponse = SetNonNullable<
189
+ Required<RouteResponse<'/acs/users/get'>>
190
+ >
191
+
192
+ export type AcsUsersListBody = RouteRequestBody<'/acs/users/list'>
193
+
194
+ export type AcsUsersListResponse = SetNonNullable<
195
+ Required<RouteResponse<'/acs/users/list'>>
196
+ >
197
+
198
+ export type AcsUsersRemoveFromAccessGroupBody =
199
+ RouteRequestBody<'/acs/users/remove_from_access_group'>
200
+
201
+ export type AcsUsersRemoveFromAccessGroupResponse = SetNonNullable<
202
+ Required<RouteResponse<'/acs/users/remove_from_access_group'>>
203
+ >
204
+
205
+ export type AcsUsersSuspendBody = RouteRequestBody<'/acs/users/suspend'>
206
+
207
+ export type AcsUsersSuspendResponse = SetNonNullable<
208
+ Required<RouteResponse<'/acs/users/suspend'>>
209
+ >
210
+
211
+ export type AcsUsersUnsuspendBody = RouteRequestBody<'/acs/users/unsuspend'>
212
+
213
+ export type AcsUsersUnsuspendResponse = SetNonNullable<
214
+ Required<RouteResponse<'/acs/users/unsuspend'>>
215
+ >
216
+
217
+ export type AcsUsersUpdateBody = RouteRequestBody<'/acs/users/update'>
218
+
219
+ export type AcsUsersUpdateResponse = SetNonNullable<
220
+ Required<RouteResponse<'/acs/users/update'>>
221
+ >
@@ -0,0 +1,101 @@
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 { warnOnInsecureuserIdentifierKey } from 'lib/seam/connect/auth.js'
7
+ import { type Client, createClient } from 'lib/seam/connect/client.js'
8
+ import {
9
+ isSeamHttpOptionsWithApiKey,
10
+ isSeamHttpOptionsWithClient,
11
+ isSeamHttpOptionsWithClientSessionToken,
12
+ type SeamHttpFromPublishableKeyOptions,
13
+ SeamHttpInvalidOptionsError,
14
+ type SeamHttpOptions,
15
+ type SeamHttpOptionsWithApiKey,
16
+ type SeamHttpOptionsWithClient,
17
+ type SeamHttpOptionsWithClientSessionToken,
18
+ } from 'lib/seam/connect/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
+ import { SeamHttpClientSessions } from './client-sessions.js'
26
+
27
+ export class SeamHttpAcs {
28
+ client: Client
29
+
30
+ constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
31
+ const clientOptions = parseOptions(apiKeyOrOptions)
32
+ this.client = createClient(clientOptions)
33
+ }
34
+
35
+ static fromClient(
36
+ client: SeamHttpOptionsWithClient['client'],
37
+ options: Omit<SeamHttpOptionsWithClient, 'client'> = {},
38
+ ): SeamHttpAcs {
39
+ const constructorOptions = { ...options, client }
40
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
41
+ throw new SeamHttpInvalidOptionsError('Missing client')
42
+ }
43
+ return new SeamHttpAcs(constructorOptions)
44
+ }
45
+
46
+ static fromApiKey(
47
+ apiKey: SeamHttpOptionsWithApiKey['apiKey'],
48
+ options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
49
+ ): SeamHttpAcs {
50
+ const constructorOptions = { ...options, apiKey }
51
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
52
+ throw new SeamHttpInvalidOptionsError('Missing apiKey')
53
+ }
54
+ return new SeamHttpAcs(constructorOptions)
55
+ }
56
+
57
+ static fromClientSessionToken(
58
+ clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
59
+ options: Omit<
60
+ SeamHttpOptionsWithClientSessionToken,
61
+ 'clientSessionToken'
62
+ > = {},
63
+ ): SeamHttpAcs {
64
+ const constructorOptions = { ...options, clientSessionToken }
65
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
66
+ throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
67
+ }
68
+ return new SeamHttpAcs(constructorOptions)
69
+ }
70
+
71
+ static async fromPublishableKey(
72
+ publishableKey: string,
73
+ userIdentifierKey: string,
74
+ options: SeamHttpFromPublishableKeyOptions = {},
75
+ ): Promise<SeamHttpAcs> {
76
+ warnOnInsecureuserIdentifierKey(userIdentifierKey)
77
+ const clientOptions = parseOptions({ ...options, publishableKey })
78
+ const client = createClient(clientOptions)
79
+ const clientSessions = SeamHttpClientSessions.fromClient(client)
80
+ const { token } = await clientSessions.getOrCreate({
81
+ user_identifier_key: userIdentifierKey,
82
+ })
83
+ return SeamHttpAcs.fromClientSessionToken(token, options)
84
+ }
85
+
86
+ get accessGroups(): SeamHttpAcsAccessGroups {
87
+ return SeamHttpAcsAccessGroups.fromClient(this.client)
88
+ }
89
+
90
+ get credentials(): SeamHttpAcsCredentials {
91
+ return SeamHttpAcsCredentials.fromClient(this.client)
92
+ }
93
+
94
+ get systems(): SeamHttpAcsSystems {
95
+ return SeamHttpAcsSystems.fromClient(this.client)
96
+ }
97
+
98
+ get users(): SeamHttpAcsUsers {
99
+ return SeamHttpAcsUsers.fromClient(this.client)
100
+ }
101
+ }