@seamapi/http 1.72.0 → 1.74.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 (62) hide show
  1. package/dist/connect.cjs +372 -0
  2. package/dist/connect.cjs.map +1 -1
  3. package/dist/connect.d.cts +138 -3
  4. package/dist/index.cjs +378 -0
  5. package/dist/index.cjs.map +1 -1
  6. package/dist/index.d.cts +1 -1
  7. package/lib/seam/connect/routes/access-grants/access-grants.d.ts +2 -0
  8. package/lib/seam/connect/routes/access-grants/access-grants.js +4 -0
  9. package/lib/seam/connect/routes/access-grants/access-grants.js.map +1 -1
  10. package/lib/seam/connect/routes/access-grants/index.d.ts +1 -0
  11. package/lib/seam/connect/routes/access-grants/index.js +1 -0
  12. package/lib/seam/connect/routes/access-grants/index.js.map +1 -1
  13. package/lib/seam/connect/routes/access-grants/unmanaged/index.d.ts +1 -0
  14. package/lib/seam/connect/routes/access-grants/unmanaged/index.js +6 -0
  15. package/lib/seam/connect/routes/access-grants/unmanaged/index.js.map +1 -0
  16. package/lib/seam/connect/routes/access-grants/unmanaged/unmanaged.d.ts +47 -0
  17. package/lib/seam/connect/routes/access-grants/unmanaged/unmanaged.js +107 -0
  18. package/lib/seam/connect/routes/access-grants/unmanaged/unmanaged.js.map +1 -0
  19. package/lib/seam/connect/routes/access-methods/access-methods.d.ts +2 -0
  20. package/lib/seam/connect/routes/access-methods/access-methods.js +4 -0
  21. package/lib/seam/connect/routes/access-methods/access-methods.js.map +1 -1
  22. package/lib/seam/connect/routes/access-methods/index.d.ts +1 -0
  23. package/lib/seam/connect/routes/access-methods/index.js +1 -0
  24. package/lib/seam/connect/routes/access-methods/index.js.map +1 -1
  25. package/lib/seam/connect/routes/access-methods/unmanaged/index.d.ts +1 -0
  26. package/lib/seam/connect/routes/access-methods/unmanaged/index.js +6 -0
  27. package/lib/seam/connect/routes/access-methods/unmanaged/index.js.map +1 -0
  28. package/lib/seam/connect/routes/access-methods/unmanaged/unmanaged.d.ts +47 -0
  29. package/lib/seam/connect/routes/access-methods/unmanaged/unmanaged.js +107 -0
  30. package/lib/seam/connect/routes/access-methods/unmanaged/unmanaged.js.map +1 -0
  31. package/lib/seam/connect/routes/seam-http-endpoints.d.ts +11 -2
  32. package/lib/seam/connect/routes/seam-http-endpoints.js +45 -0
  33. package/lib/seam/connect/routes/seam-http-endpoints.js.map +1 -1
  34. package/lib/seam/connect/routes/user-identities/index.d.ts +1 -0
  35. package/lib/seam/connect/routes/user-identities/index.js +1 -0
  36. package/lib/seam/connect/routes/user-identities/index.js.map +1 -1
  37. package/lib/seam/connect/routes/user-identities/unmanaged/index.d.ts +1 -0
  38. package/lib/seam/connect/routes/user-identities/unmanaged/index.js +6 -0
  39. package/lib/seam/connect/routes/user-identities/unmanaged/index.js.map +1 -0
  40. package/lib/seam/connect/routes/user-identities/unmanaged/unmanaged.d.ts +47 -0
  41. package/lib/seam/connect/routes/user-identities/unmanaged/unmanaged.js +107 -0
  42. package/lib/seam/connect/routes/user-identities/unmanaged/unmanaged.js.map +1 -0
  43. package/lib/seam/connect/routes/user-identities/user-identities.d.ts +2 -0
  44. package/lib/seam/connect/routes/user-identities/user-identities.js +4 -0
  45. package/lib/seam/connect/routes/user-identities/user-identities.js.map +1 -1
  46. package/lib/version.d.ts +1 -1
  47. package/lib/version.js +1 -1
  48. package/package.json +3 -3
  49. package/src/lib/seam/connect/routes/access-grants/access-grants.ts +6 -0
  50. package/src/lib/seam/connect/routes/access-grants/index.ts +1 -0
  51. package/src/lib/seam/connect/routes/access-grants/unmanaged/index.ts +6 -0
  52. package/src/lib/seam/connect/routes/access-grants/unmanaged/unmanaged.ts +236 -0
  53. package/src/lib/seam/connect/routes/access-methods/access-methods.ts +6 -0
  54. package/src/lib/seam/connect/routes/access-methods/index.ts +1 -0
  55. package/src/lib/seam/connect/routes/access-methods/unmanaged/index.ts +6 -0
  56. package/src/lib/seam/connect/routes/access-methods/unmanaged/unmanaged.ts +237 -0
  57. package/src/lib/seam/connect/routes/seam-http-endpoints.ts +112 -0
  58. package/src/lib/seam/connect/routes/user-identities/index.ts +1 -0
  59. package/src/lib/seam/connect/routes/user-identities/unmanaged/index.ts +6 -0
  60. package/src/lib/seam/connect/routes/user-identities/unmanaged/unmanaged.ts +240 -0
  61. package/src/lib/seam/connect/routes/user-identities/user-identities.ts +8 -0
  62. package/src/lib/version.ts +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seamapi/http",
3
- "version": "1.72.0",
3
+ "version": "1.74.0",
4
4
  "description": "JavaScript HTTP client for the Seam API written in TypeScript.",
5
5
  "type": "module",
6
6
  "main": "index.js",
@@ -86,7 +86,7 @@
86
86
  "npm": ">=10.1.0"
87
87
  },
88
88
  "peerDependencies": {
89
- "@seamapi/types": "^1.561.0"
89
+ "@seamapi/types": "^1.585.0"
90
90
  },
91
91
  "peerDependenciesMeta": {
92
92
  "@seamapi/types": {
@@ -102,7 +102,7 @@
102
102
  "@seamapi/blueprint": "^0.51.1",
103
103
  "@seamapi/fake-seam-connect": "^1.77.0",
104
104
  "@seamapi/smith": "^0.5.2",
105
- "@seamapi/types": "1.561.0",
105
+ "@seamapi/types": "1.585.0",
106
106
  "@swc/core": "^1.11.29",
107
107
  "@types/jsonwebtoken": "^9.0.6",
108
108
  "@types/node": "^22.15.21",
@@ -40,6 +40,8 @@ import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js'
40
40
  import { SeamPaginator } from 'lib/seam/connect/seam-paginator.js'
41
41
  import type { SetNonNullable } from 'lib/types.js'
42
42
 
43
+ import { SeamHttpAccessGrantsUnmanaged } from './unmanaged/index.js'
44
+
43
45
  export class SeamHttpAccessGrants {
44
46
  client: Client
45
47
  readonly defaults: Required<SeamHttpRequestOptions>
@@ -167,6 +169,10 @@ export class SeamHttpAccessGrants {
167
169
  await clientSessions.get()
168
170
  }
169
171
 
172
+ get unmanaged(): SeamHttpAccessGrantsUnmanaged {
173
+ return SeamHttpAccessGrantsUnmanaged.fromClient(this.client, this.defaults)
174
+ }
175
+
170
176
  create(
171
177
  parameters?: AccessGrantsCreateParameters,
172
178
  options: AccessGrantsCreateOptions = {},
@@ -4,3 +4,4 @@
4
4
  */
5
5
 
6
6
  export * from './access-grants.js'
7
+ export * from './unmanaged/index.js'
@@ -0,0 +1,6 @@
1
+ /*
2
+ * Automatically generated by codegen/smith.ts.
3
+ * Do not edit this file or add other files to this directory.
4
+ */
5
+
6
+ export * from './unmanaged.js'
@@ -0,0 +1,236 @@
1
+ /*
2
+ * Automatically generated by codegen/smith.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
+
8
+ import { seamApiLtsVersion } from 'lib/lts-version.js'
9
+ import {
10
+ getAuthHeadersForClientSessionToken,
11
+ warnOnInsecureuserIdentifierKey,
12
+ } from 'lib/seam/connect/auth.js'
13
+ import { type Client, createClient } from 'lib/seam/connect/client.js'
14
+ import {
15
+ isSeamHttpOptionsWithApiKey,
16
+ isSeamHttpOptionsWithClient,
17
+ isSeamHttpOptionsWithClientSessionToken,
18
+ isSeamHttpOptionsWithConsoleSessionToken,
19
+ isSeamHttpOptionsWithPersonalAccessToken,
20
+ type SeamHttpFromPublishableKeyOptions,
21
+ SeamHttpInvalidOptionsError,
22
+ type SeamHttpOptions,
23
+ type SeamHttpOptionsWithApiKey,
24
+ type SeamHttpOptionsWithClient,
25
+ type SeamHttpOptionsWithClientSessionToken,
26
+ type SeamHttpOptionsWithConsoleSessionToken,
27
+ type SeamHttpOptionsWithPersonalAccessToken,
28
+ type SeamHttpRequestOptions,
29
+ } from 'lib/seam/connect/options.js'
30
+ import {
31
+ limitToSeamHttpRequestOptions,
32
+ parseOptions,
33
+ } from 'lib/seam/connect/parse-options.js'
34
+ import { SeamHttpClientSessions } from 'lib/seam/connect/routes/client-sessions/index.js'
35
+ import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js'
36
+ import { SeamPaginator } from 'lib/seam/connect/seam-paginator.js'
37
+ import type { SetNonNullable } from 'lib/types.js'
38
+
39
+ export class SeamHttpAccessGrantsUnmanaged {
40
+ client: Client
41
+ readonly defaults: Required<SeamHttpRequestOptions>
42
+ readonly ltsVersion = seamApiLtsVersion
43
+ static ltsVersion = seamApiLtsVersion
44
+
45
+ constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
46
+ const options = parseOptions(apiKeyOrOptions)
47
+ this.client = 'client' in options ? options.client : createClient(options)
48
+ this.defaults = limitToSeamHttpRequestOptions(options)
49
+ }
50
+
51
+ static fromClient(
52
+ client: SeamHttpOptionsWithClient['client'],
53
+ options: Omit<SeamHttpOptionsWithClient, 'client'> = {},
54
+ ): SeamHttpAccessGrantsUnmanaged {
55
+ const constructorOptions = { ...options, client }
56
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
57
+ throw new SeamHttpInvalidOptionsError('Missing client')
58
+ }
59
+ return new SeamHttpAccessGrantsUnmanaged(constructorOptions)
60
+ }
61
+
62
+ static fromApiKey(
63
+ apiKey: SeamHttpOptionsWithApiKey['apiKey'],
64
+ options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
65
+ ): SeamHttpAccessGrantsUnmanaged {
66
+ const constructorOptions = { ...options, apiKey }
67
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
68
+ throw new SeamHttpInvalidOptionsError('Missing apiKey')
69
+ }
70
+ return new SeamHttpAccessGrantsUnmanaged(constructorOptions)
71
+ }
72
+
73
+ static fromClientSessionToken(
74
+ clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
75
+ options: Omit<
76
+ SeamHttpOptionsWithClientSessionToken,
77
+ 'clientSessionToken'
78
+ > = {},
79
+ ): SeamHttpAccessGrantsUnmanaged {
80
+ const constructorOptions = { ...options, clientSessionToken }
81
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
82
+ throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
83
+ }
84
+ return new SeamHttpAccessGrantsUnmanaged(constructorOptions)
85
+ }
86
+
87
+ static async fromPublishableKey(
88
+ publishableKey: string,
89
+ userIdentifierKey: string,
90
+ options: SeamHttpFromPublishableKeyOptions = {},
91
+ ): Promise<SeamHttpAccessGrantsUnmanaged> {
92
+ warnOnInsecureuserIdentifierKey(userIdentifierKey)
93
+ const clientOptions = parseOptions({ ...options, publishableKey })
94
+ if (isSeamHttpOptionsWithClient(clientOptions)) {
95
+ throw new SeamHttpInvalidOptionsError(
96
+ 'The client option cannot be used with SeamHttpAccessGrantsUnmanaged.fromPublishableKey',
97
+ )
98
+ }
99
+ const client = createClient(clientOptions)
100
+ const clientSessions = SeamHttpClientSessions.fromClient(client)
101
+ const { token } = await clientSessions.getOrCreate({
102
+ user_identifier_key: userIdentifierKey,
103
+ })
104
+ return SeamHttpAccessGrantsUnmanaged.fromClientSessionToken(token, options)
105
+ }
106
+
107
+ static fromConsoleSessionToken(
108
+ consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'],
109
+ workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'],
110
+ options: Omit<
111
+ SeamHttpOptionsWithConsoleSessionToken,
112
+ 'consoleSessionToken' | 'workspaceId'
113
+ > = {},
114
+ ): SeamHttpAccessGrantsUnmanaged {
115
+ const constructorOptions = { ...options, consoleSessionToken, workspaceId }
116
+ if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) {
117
+ throw new SeamHttpInvalidOptionsError(
118
+ 'Missing consoleSessionToken or workspaceId',
119
+ )
120
+ }
121
+ return new SeamHttpAccessGrantsUnmanaged(constructorOptions)
122
+ }
123
+
124
+ static fromPersonalAccessToken(
125
+ personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'],
126
+ workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'],
127
+ options: Omit<
128
+ SeamHttpOptionsWithPersonalAccessToken,
129
+ 'personalAccessToken' | 'workspaceId'
130
+ > = {},
131
+ ): SeamHttpAccessGrantsUnmanaged {
132
+ const constructorOptions = { ...options, personalAccessToken, workspaceId }
133
+ if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) {
134
+ throw new SeamHttpInvalidOptionsError(
135
+ 'Missing personalAccessToken or workspaceId',
136
+ )
137
+ }
138
+ return new SeamHttpAccessGrantsUnmanaged(constructorOptions)
139
+ }
140
+
141
+ createPaginator<const TResponse, const TResponseKey extends keyof TResponse>(
142
+ request: SeamHttpRequest<TResponse, TResponseKey>,
143
+ ): SeamPaginator<TResponse, TResponseKey> {
144
+ return new SeamPaginator<TResponse, TResponseKey>(this, request)
145
+ }
146
+
147
+ async updateClientSessionToken(
148
+ clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
149
+ ): Promise<void> {
150
+ const { headers } = this.client.defaults
151
+ const authHeaders = getAuthHeadersForClientSessionToken({
152
+ clientSessionToken,
153
+ })
154
+ for (const key of Object.keys(authHeaders)) {
155
+ if (headers[key] == null) {
156
+ throw new Error(
157
+ 'Cannot update a clientSessionToken on a client created without a clientSessionToken',
158
+ )
159
+ }
160
+ }
161
+ this.client.defaults.headers = { ...headers, ...authHeaders }
162
+ const clientSessions = SeamHttpClientSessions.fromClient(this.client)
163
+ await clientSessions.get()
164
+ }
165
+
166
+ get(
167
+ parameters?: AccessGrantsUnmanagedGetParameters,
168
+ options: AccessGrantsUnmanagedGetOptions = {},
169
+ ): AccessGrantsUnmanagedGetRequest {
170
+ return new SeamHttpRequest(this, {
171
+ pathname: '/access_grants/unmanaged/get',
172
+ method: 'POST',
173
+ body: parameters,
174
+ responseKey: 'access_grant',
175
+ options,
176
+ })
177
+ }
178
+
179
+ list(
180
+ parameters?: AccessGrantsUnmanagedListParameters,
181
+ options: AccessGrantsUnmanagedListOptions = {},
182
+ ): AccessGrantsUnmanagedListRequest {
183
+ return new SeamHttpRequest(this, {
184
+ pathname: '/access_grants/unmanaged/list',
185
+ method: 'POST',
186
+ body: parameters,
187
+ responseKey: 'access_grants',
188
+ options,
189
+ })
190
+ }
191
+ }
192
+
193
+ export type AccessGrantsUnmanagedGetParameters =
194
+ RouteRequestBody<'/access_grants/unmanaged/get'>
195
+
196
+ /**
197
+ * @deprecated Use AccessGrantsUnmanagedGetParameters instead.
198
+ */
199
+ export type AccessGrantsUnmanagedGetParams = AccessGrantsUnmanagedGetParameters
200
+
201
+ /**
202
+ * @deprecated Use AccessGrantsUnmanagedGetRequest instead.
203
+ */
204
+ export type AccessGrantsUnmanagedGetResponse = SetNonNullable<
205
+ Required<RouteResponse<'/access_grants/unmanaged/get'>>
206
+ >
207
+
208
+ export type AccessGrantsUnmanagedGetRequest = SeamHttpRequest<
209
+ AccessGrantsUnmanagedGetResponse,
210
+ 'access_grant'
211
+ >
212
+
213
+ export interface AccessGrantsUnmanagedGetOptions {}
214
+
215
+ export type AccessGrantsUnmanagedListParameters =
216
+ RouteRequestBody<'/access_grants/unmanaged/list'>
217
+
218
+ /**
219
+ * @deprecated Use AccessGrantsUnmanagedListParameters instead.
220
+ */
221
+ export type AccessGrantsUnmanagedListParams =
222
+ AccessGrantsUnmanagedListParameters
223
+
224
+ /**
225
+ * @deprecated Use AccessGrantsUnmanagedListRequest instead.
226
+ */
227
+ export type AccessGrantsUnmanagedListResponse = SetNonNullable<
228
+ Required<RouteResponse<'/access_grants/unmanaged/list'>>
229
+ >
230
+
231
+ export type AccessGrantsUnmanagedListRequest = SeamHttpRequest<
232
+ AccessGrantsUnmanagedListResponse,
233
+ 'access_grants'
234
+ >
235
+
236
+ export interface AccessGrantsUnmanagedListOptions {}
@@ -36,6 +36,8 @@ import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js'
36
36
  import { SeamPaginator } from 'lib/seam/connect/seam-paginator.js'
37
37
  import type { SetNonNullable } from 'lib/types.js'
38
38
 
39
+ import { SeamHttpAccessMethodsUnmanaged } from './unmanaged/index.js'
40
+
39
41
  export class SeamHttpAccessMethods {
40
42
  client: Client
41
43
  readonly defaults: Required<SeamHttpRequestOptions>
@@ -163,6 +165,10 @@ export class SeamHttpAccessMethods {
163
165
  await clientSessions.get()
164
166
  }
165
167
 
168
+ get unmanaged(): SeamHttpAccessMethodsUnmanaged {
169
+ return SeamHttpAccessMethodsUnmanaged.fromClient(this.client, this.defaults)
170
+ }
171
+
166
172
  delete(
167
173
  parameters?: AccessMethodsDeleteParameters,
168
174
  options: AccessMethodsDeleteOptions = {},
@@ -4,3 +4,4 @@
4
4
  */
5
5
 
6
6
  export * from './access-methods.js'
7
+ export * from './unmanaged/index.js'
@@ -0,0 +1,6 @@
1
+ /*
2
+ * Automatically generated by codegen/smith.ts.
3
+ * Do not edit this file or add other files to this directory.
4
+ */
5
+
6
+ export * from './unmanaged.js'
@@ -0,0 +1,237 @@
1
+ /*
2
+ * Automatically generated by codegen/smith.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
+
8
+ import { seamApiLtsVersion } from 'lib/lts-version.js'
9
+ import {
10
+ getAuthHeadersForClientSessionToken,
11
+ warnOnInsecureuserIdentifierKey,
12
+ } from 'lib/seam/connect/auth.js'
13
+ import { type Client, createClient } from 'lib/seam/connect/client.js'
14
+ import {
15
+ isSeamHttpOptionsWithApiKey,
16
+ isSeamHttpOptionsWithClient,
17
+ isSeamHttpOptionsWithClientSessionToken,
18
+ isSeamHttpOptionsWithConsoleSessionToken,
19
+ isSeamHttpOptionsWithPersonalAccessToken,
20
+ type SeamHttpFromPublishableKeyOptions,
21
+ SeamHttpInvalidOptionsError,
22
+ type SeamHttpOptions,
23
+ type SeamHttpOptionsWithApiKey,
24
+ type SeamHttpOptionsWithClient,
25
+ type SeamHttpOptionsWithClientSessionToken,
26
+ type SeamHttpOptionsWithConsoleSessionToken,
27
+ type SeamHttpOptionsWithPersonalAccessToken,
28
+ type SeamHttpRequestOptions,
29
+ } from 'lib/seam/connect/options.js'
30
+ import {
31
+ limitToSeamHttpRequestOptions,
32
+ parseOptions,
33
+ } from 'lib/seam/connect/parse-options.js'
34
+ import { SeamHttpClientSessions } from 'lib/seam/connect/routes/client-sessions/index.js'
35
+ import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js'
36
+ import { SeamPaginator } from 'lib/seam/connect/seam-paginator.js'
37
+ import type { SetNonNullable } from 'lib/types.js'
38
+
39
+ export class SeamHttpAccessMethodsUnmanaged {
40
+ client: Client
41
+ readonly defaults: Required<SeamHttpRequestOptions>
42
+ readonly ltsVersion = seamApiLtsVersion
43
+ static ltsVersion = seamApiLtsVersion
44
+
45
+ constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
46
+ const options = parseOptions(apiKeyOrOptions)
47
+ this.client = 'client' in options ? options.client : createClient(options)
48
+ this.defaults = limitToSeamHttpRequestOptions(options)
49
+ }
50
+
51
+ static fromClient(
52
+ client: SeamHttpOptionsWithClient['client'],
53
+ options: Omit<SeamHttpOptionsWithClient, 'client'> = {},
54
+ ): SeamHttpAccessMethodsUnmanaged {
55
+ const constructorOptions = { ...options, client }
56
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
57
+ throw new SeamHttpInvalidOptionsError('Missing client')
58
+ }
59
+ return new SeamHttpAccessMethodsUnmanaged(constructorOptions)
60
+ }
61
+
62
+ static fromApiKey(
63
+ apiKey: SeamHttpOptionsWithApiKey['apiKey'],
64
+ options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
65
+ ): SeamHttpAccessMethodsUnmanaged {
66
+ const constructorOptions = { ...options, apiKey }
67
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
68
+ throw new SeamHttpInvalidOptionsError('Missing apiKey')
69
+ }
70
+ return new SeamHttpAccessMethodsUnmanaged(constructorOptions)
71
+ }
72
+
73
+ static fromClientSessionToken(
74
+ clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
75
+ options: Omit<
76
+ SeamHttpOptionsWithClientSessionToken,
77
+ 'clientSessionToken'
78
+ > = {},
79
+ ): SeamHttpAccessMethodsUnmanaged {
80
+ const constructorOptions = { ...options, clientSessionToken }
81
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
82
+ throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
83
+ }
84
+ return new SeamHttpAccessMethodsUnmanaged(constructorOptions)
85
+ }
86
+
87
+ static async fromPublishableKey(
88
+ publishableKey: string,
89
+ userIdentifierKey: string,
90
+ options: SeamHttpFromPublishableKeyOptions = {},
91
+ ): Promise<SeamHttpAccessMethodsUnmanaged> {
92
+ warnOnInsecureuserIdentifierKey(userIdentifierKey)
93
+ const clientOptions = parseOptions({ ...options, publishableKey })
94
+ if (isSeamHttpOptionsWithClient(clientOptions)) {
95
+ throw new SeamHttpInvalidOptionsError(
96
+ 'The client option cannot be used with SeamHttpAccessMethodsUnmanaged.fromPublishableKey',
97
+ )
98
+ }
99
+ const client = createClient(clientOptions)
100
+ const clientSessions = SeamHttpClientSessions.fromClient(client)
101
+ const { token } = await clientSessions.getOrCreate({
102
+ user_identifier_key: userIdentifierKey,
103
+ })
104
+ return SeamHttpAccessMethodsUnmanaged.fromClientSessionToken(token, options)
105
+ }
106
+
107
+ static fromConsoleSessionToken(
108
+ consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'],
109
+ workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'],
110
+ options: Omit<
111
+ SeamHttpOptionsWithConsoleSessionToken,
112
+ 'consoleSessionToken' | 'workspaceId'
113
+ > = {},
114
+ ): SeamHttpAccessMethodsUnmanaged {
115
+ const constructorOptions = { ...options, consoleSessionToken, workspaceId }
116
+ if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) {
117
+ throw new SeamHttpInvalidOptionsError(
118
+ 'Missing consoleSessionToken or workspaceId',
119
+ )
120
+ }
121
+ return new SeamHttpAccessMethodsUnmanaged(constructorOptions)
122
+ }
123
+
124
+ static fromPersonalAccessToken(
125
+ personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'],
126
+ workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'],
127
+ options: Omit<
128
+ SeamHttpOptionsWithPersonalAccessToken,
129
+ 'personalAccessToken' | 'workspaceId'
130
+ > = {},
131
+ ): SeamHttpAccessMethodsUnmanaged {
132
+ const constructorOptions = { ...options, personalAccessToken, workspaceId }
133
+ if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) {
134
+ throw new SeamHttpInvalidOptionsError(
135
+ 'Missing personalAccessToken or workspaceId',
136
+ )
137
+ }
138
+ return new SeamHttpAccessMethodsUnmanaged(constructorOptions)
139
+ }
140
+
141
+ createPaginator<const TResponse, const TResponseKey extends keyof TResponse>(
142
+ request: SeamHttpRequest<TResponse, TResponseKey>,
143
+ ): SeamPaginator<TResponse, TResponseKey> {
144
+ return new SeamPaginator<TResponse, TResponseKey>(this, request)
145
+ }
146
+
147
+ async updateClientSessionToken(
148
+ clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
149
+ ): Promise<void> {
150
+ const { headers } = this.client.defaults
151
+ const authHeaders = getAuthHeadersForClientSessionToken({
152
+ clientSessionToken,
153
+ })
154
+ for (const key of Object.keys(authHeaders)) {
155
+ if (headers[key] == null) {
156
+ throw new Error(
157
+ 'Cannot update a clientSessionToken on a client created without a clientSessionToken',
158
+ )
159
+ }
160
+ }
161
+ this.client.defaults.headers = { ...headers, ...authHeaders }
162
+ const clientSessions = SeamHttpClientSessions.fromClient(this.client)
163
+ await clientSessions.get()
164
+ }
165
+
166
+ get(
167
+ parameters?: AccessMethodsUnmanagedGetParameters,
168
+ options: AccessMethodsUnmanagedGetOptions = {},
169
+ ): AccessMethodsUnmanagedGetRequest {
170
+ return new SeamHttpRequest(this, {
171
+ pathname: '/access_methods/unmanaged/get',
172
+ method: 'POST',
173
+ body: parameters,
174
+ responseKey: 'access_method',
175
+ options,
176
+ })
177
+ }
178
+
179
+ list(
180
+ parameters?: AccessMethodsUnmanagedListParameters,
181
+ options: AccessMethodsUnmanagedListOptions = {},
182
+ ): AccessMethodsUnmanagedListRequest {
183
+ return new SeamHttpRequest(this, {
184
+ pathname: '/access_methods/unmanaged/list',
185
+ method: 'POST',
186
+ body: parameters,
187
+ responseKey: 'access_methods',
188
+ options,
189
+ })
190
+ }
191
+ }
192
+
193
+ export type AccessMethodsUnmanagedGetParameters =
194
+ RouteRequestBody<'/access_methods/unmanaged/get'>
195
+
196
+ /**
197
+ * @deprecated Use AccessMethodsUnmanagedGetParameters instead.
198
+ */
199
+ export type AccessMethodsUnmanagedGetParams =
200
+ AccessMethodsUnmanagedGetParameters
201
+
202
+ /**
203
+ * @deprecated Use AccessMethodsUnmanagedGetRequest instead.
204
+ */
205
+ export type AccessMethodsUnmanagedGetResponse = SetNonNullable<
206
+ Required<RouteResponse<'/access_methods/unmanaged/get'>>
207
+ >
208
+
209
+ export type AccessMethodsUnmanagedGetRequest = SeamHttpRequest<
210
+ AccessMethodsUnmanagedGetResponse,
211
+ 'access_method'
212
+ >
213
+
214
+ export interface AccessMethodsUnmanagedGetOptions {}
215
+
216
+ export type AccessMethodsUnmanagedListParameters =
217
+ RouteRequestBody<'/access_methods/unmanaged/list'>
218
+
219
+ /**
220
+ * @deprecated Use AccessMethodsUnmanagedListParameters instead.
221
+ */
222
+ export type AccessMethodsUnmanagedListParams =
223
+ AccessMethodsUnmanagedListParameters
224
+
225
+ /**
226
+ * @deprecated Use AccessMethodsUnmanagedListRequest instead.
227
+ */
228
+ export type AccessMethodsUnmanagedListResponse = SetNonNullable<
229
+ Required<RouteResponse<'/access_methods/unmanaged/list'>>
230
+ >
231
+
232
+ export type AccessMethodsUnmanagedListRequest = SeamHttpRequest<
233
+ AccessMethodsUnmanagedListResponse,
234
+ 'access_methods'
235
+ >
236
+
237
+ export interface AccessMethodsUnmanagedListOptions {}