@seamapi/http 1.117.0 → 1.119.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 +594 -0
  2. package/dist/connect.cjs.map +1 -1
  3. package/dist/connect.d.cts +219 -3
  4. package/dist/index.cjs +600 -0
  5. package/dist/index.cjs.map +1 -1
  6. package/dist/index.d.cts +1 -1
  7. package/lib/seam/connect/routes/access-methods/access-methods.d.ts +24 -0
  8. package/lib/seam/connect/routes/access-methods/access-methods.js +18 -0
  9. package/lib/seam/connect/routes/access-methods/access-methods.js.map +1 -1
  10. package/lib/seam/connect/routes/acs/encoders/encoders.d.ts +12 -0
  11. package/lib/seam/connect/routes/acs/encoders/encoders.js +9 -0
  12. package/lib/seam/connect/routes/acs/encoders/encoders.js.map +1 -1
  13. package/lib/seam/connect/routes/seam/console/v1/index.d.ts +2 -0
  14. package/lib/seam/connect/routes/seam/console/v1/index.js +2 -0
  15. package/lib/seam/connect/routes/seam/console/v1/index.js.map +1 -1
  16. package/lib/seam/connect/routes/seam/console/v1/lynx-migration/index.d.ts +1 -0
  17. package/lib/seam/connect/routes/seam/console/v1/lynx-migration/index.js +6 -0
  18. package/lib/seam/connect/routes/seam/console/v1/lynx-migration/index.js.map +1 -0
  19. package/lib/seam/connect/routes/seam/console/v1/lynx-migration/lynx-migration.d.ts +73 -0
  20. package/lib/seam/connect/routes/seam/console/v1/lynx-migration/lynx-migration.js +140 -0
  21. package/lib/seam/connect/routes/seam/console/v1/lynx-migration/lynx-migration.js.map +1 -0
  22. package/lib/seam/connect/routes/seam/console/v1/sites/index.d.ts +1 -0
  23. package/lib/seam/connect/routes/seam/console/v1/sites/index.js +6 -0
  24. package/lib/seam/connect/routes/seam/console/v1/sites/index.js.map +1 -0
  25. package/lib/seam/connect/routes/seam/console/v1/sites/sites.d.ts +73 -0
  26. package/lib/seam/connect/routes/seam/console/v1/sites/sites.js +140 -0
  27. package/lib/seam/connect/routes/seam/console/v1/sites/sites.js.map +1 -0
  28. package/lib/seam/connect/routes/seam/console/v1/v1.d.ts +4 -0
  29. package/lib/seam/connect/routes/seam/console/v1/v1.js +8 -0
  30. package/lib/seam/connect/routes/seam/console/v1/v1.js.map +1 -1
  31. package/lib/seam/connect/routes/seam/customer/v1/connectors/connectors.d.ts +2 -0
  32. package/lib/seam/connect/routes/seam/customer/v1/connectors/connectors.js +4 -0
  33. package/lib/seam/connect/routes/seam/customer/v1/connectors/connectors.js.map +1 -1
  34. package/lib/seam/connect/routes/seam/customer/v1/connectors/external-sites/external-sites.d.ts +34 -0
  35. package/lib/seam/connect/routes/seam/customer/v1/connectors/external-sites/external-sites.js +104 -0
  36. package/lib/seam/connect/routes/seam/customer/v1/connectors/external-sites/external-sites.js.map +1 -0
  37. package/lib/seam/connect/routes/seam/customer/v1/connectors/external-sites/index.d.ts +1 -0
  38. package/lib/seam/connect/routes/seam/customer/v1/connectors/external-sites/index.js +6 -0
  39. package/lib/seam/connect/routes/seam/customer/v1/connectors/external-sites/index.js.map +1 -0
  40. package/lib/seam/connect/routes/seam/customer/v1/connectors/index.d.ts +1 -0
  41. package/lib/seam/connect/routes/seam/customer/v1/connectors/index.js +1 -0
  42. package/lib/seam/connect/routes/seam/customer/v1/connectors/index.js.map +1 -1
  43. package/lib/seam/connect/routes/seam-http-endpoints.d.ts +19 -4
  44. package/lib/seam/connect/routes/seam-http-endpoints.js +114 -0
  45. package/lib/seam/connect/routes/seam-http-endpoints.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-methods/access-methods.ts +76 -0
  50. package/src/lib/seam/connect/routes/acs/encoders/encoders.ts +39 -0
  51. package/src/lib/seam/connect/routes/seam/console/v1/index.ts +2 -0
  52. package/src/lib/seam/connect/routes/seam/console/v1/lynx-migration/index.ts +6 -0
  53. package/src/lib/seam/connect/routes/seam/console/v1/lynx-migration/lynx-migration.ts +350 -0
  54. package/src/lib/seam/connect/routes/seam/console/v1/sites/index.ts +6 -0
  55. package/src/lib/seam/connect/routes/seam/console/v1/sites/sites.ts +327 -0
  56. package/src/lib/seam/connect/routes/seam/console/v1/v1.ts +13 -0
  57. package/src/lib/seam/connect/routes/seam/customer/v1/connectors/connectors.ts +8 -0
  58. package/src/lib/seam/connect/routes/seam/customer/v1/connectors/external-sites/external-sites.ts +214 -0
  59. package/src/lib/seam/connect/routes/seam/customer/v1/connectors/external-sites/index.ts +6 -0
  60. package/src/lib/seam/connect/routes/seam/customer/v1/connectors/index.ts +1 -0
  61. package/src/lib/seam/connect/routes/seam-http-endpoints.ts +285 -0
  62. package/src/lib/version.ts +1 -1
@@ -0,0 +1,350 @@
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 SeamHttpSeamConsoleV1LynxMigration {
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
+ if (!options.isUndocumentedApiEnabled) {
48
+ throw new Error(
49
+ 'Cannot use undocumented API without isUndocumentedApiEnabled',
50
+ )
51
+ }
52
+ this.client = 'client' in options ? options.client : createClient(options)
53
+ this.defaults = limitToSeamHttpRequestOptions(options)
54
+ }
55
+
56
+ static fromClient(
57
+ client: SeamHttpOptionsWithClient['client'],
58
+ options: Omit<SeamHttpOptionsWithClient, 'client'> = {},
59
+ ): SeamHttpSeamConsoleV1LynxMigration {
60
+ const constructorOptions = { ...options, client }
61
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
62
+ throw new SeamHttpInvalidOptionsError('Missing client')
63
+ }
64
+ return new SeamHttpSeamConsoleV1LynxMigration(constructorOptions)
65
+ }
66
+
67
+ static fromApiKey(
68
+ apiKey: SeamHttpOptionsWithApiKey['apiKey'],
69
+ options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
70
+ ): SeamHttpSeamConsoleV1LynxMigration {
71
+ const constructorOptions = { ...options, apiKey }
72
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
73
+ throw new SeamHttpInvalidOptionsError('Missing apiKey')
74
+ }
75
+ return new SeamHttpSeamConsoleV1LynxMigration(constructorOptions)
76
+ }
77
+
78
+ static fromClientSessionToken(
79
+ clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
80
+ options: Omit<
81
+ SeamHttpOptionsWithClientSessionToken,
82
+ 'clientSessionToken'
83
+ > = {},
84
+ ): SeamHttpSeamConsoleV1LynxMigration {
85
+ const constructorOptions = { ...options, clientSessionToken }
86
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
87
+ throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
88
+ }
89
+ return new SeamHttpSeamConsoleV1LynxMigration(constructorOptions)
90
+ }
91
+
92
+ static async fromPublishableKey(
93
+ publishableKey: string,
94
+ userIdentifierKey: string,
95
+ options: SeamHttpFromPublishableKeyOptions = {},
96
+ ): Promise<SeamHttpSeamConsoleV1LynxMigration> {
97
+ warnOnInsecureuserIdentifierKey(userIdentifierKey)
98
+ const clientOptions = parseOptions({ ...options, publishableKey })
99
+ if (isSeamHttpOptionsWithClient(clientOptions)) {
100
+ throw new SeamHttpInvalidOptionsError(
101
+ 'The client option cannot be used with SeamHttpSeamConsoleV1LynxMigration.fromPublishableKey',
102
+ )
103
+ }
104
+ const client = createClient(clientOptions)
105
+ const clientSessions = SeamHttpClientSessions.fromClient(client)
106
+ const { token } = await clientSessions.getOrCreate({
107
+ user_identifier_key: userIdentifierKey,
108
+ })
109
+ return SeamHttpSeamConsoleV1LynxMigration.fromClientSessionToken(
110
+ token,
111
+ options,
112
+ )
113
+ }
114
+
115
+ static fromConsoleSessionToken(
116
+ consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'],
117
+ workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'],
118
+ options: Omit<
119
+ SeamHttpOptionsWithConsoleSessionToken,
120
+ 'consoleSessionToken' | 'workspaceId'
121
+ > = {},
122
+ ): SeamHttpSeamConsoleV1LynxMigration {
123
+ const constructorOptions = { ...options, consoleSessionToken, workspaceId }
124
+ if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) {
125
+ throw new SeamHttpInvalidOptionsError(
126
+ 'Missing consoleSessionToken or workspaceId',
127
+ )
128
+ }
129
+ return new SeamHttpSeamConsoleV1LynxMigration(constructorOptions)
130
+ }
131
+
132
+ static fromPersonalAccessToken(
133
+ personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'],
134
+ workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'],
135
+ options: Omit<
136
+ SeamHttpOptionsWithPersonalAccessToken,
137
+ 'personalAccessToken' | 'workspaceId'
138
+ > = {},
139
+ ): SeamHttpSeamConsoleV1LynxMigration {
140
+ const constructorOptions = { ...options, personalAccessToken, workspaceId }
141
+ if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) {
142
+ throw new SeamHttpInvalidOptionsError(
143
+ 'Missing personalAccessToken or workspaceId',
144
+ )
145
+ }
146
+ return new SeamHttpSeamConsoleV1LynxMigration(constructorOptions)
147
+ }
148
+
149
+ createPaginator<const TResponse, const TResponseKey extends keyof TResponse>(
150
+ request: SeamHttpRequest<TResponse, TResponseKey>,
151
+ ): SeamPaginator<TResponse, TResponseKey> {
152
+ return new SeamPaginator<TResponse, TResponseKey>(this, request)
153
+ }
154
+
155
+ async updateClientSessionToken(
156
+ clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
157
+ ): Promise<void> {
158
+ const { headers } = this.client.defaults
159
+ const authHeaders = getAuthHeadersForClientSessionToken({
160
+ clientSessionToken,
161
+ })
162
+ for (const key of Object.keys(authHeaders)) {
163
+ if (headers[key] == null) {
164
+ throw new Error(
165
+ 'Cannot update a clientSessionToken on a client created without a clientSessionToken',
166
+ )
167
+ }
168
+ }
169
+ this.client.defaults.headers = { ...headers, ...authHeaders }
170
+ const clientSessions = SeamHttpClientSessions.fromClient(this.client)
171
+ await clientSessions.get()
172
+ }
173
+
174
+ getPropertyMigrationStatus(
175
+ parameters?: SeamConsoleV1LynxMigrationGetPropertyMigrationStatusParameters,
176
+ options: SeamConsoleV1LynxMigrationGetPropertyMigrationStatusOptions = {},
177
+ ): SeamConsoleV1LynxMigrationGetPropertyMigrationStatusRequest {
178
+ if (!this.defaults.isUndocumentedApiEnabled) {
179
+ throw new Error(
180
+ 'Cannot use undocumented API without isUndocumentedApiEnabled',
181
+ )
182
+ }
183
+ return new SeamHttpRequest(this, {
184
+ pathname: '/seam/console/v1/lynx_migration/get_property_migration_status',
185
+ method: 'POST',
186
+ body: parameters,
187
+ responseKey: 'lynx_migration_property_run',
188
+ options,
189
+ })
190
+ }
191
+
192
+ getReservationMigrationStatus(
193
+ parameters?: SeamConsoleV1LynxMigrationGetReservationMigrationStatusParameters,
194
+ options: SeamConsoleV1LynxMigrationGetReservationMigrationStatusOptions = {},
195
+ ): SeamConsoleV1LynxMigrationGetReservationMigrationStatusRequest {
196
+ if (!this.defaults.isUndocumentedApiEnabled) {
197
+ throw new Error(
198
+ 'Cannot use undocumented API without isUndocumentedApiEnabled',
199
+ )
200
+ }
201
+ return new SeamHttpRequest(this, {
202
+ pathname:
203
+ '/seam/console/v1/lynx_migration/get_reservation_migration_status',
204
+ method: 'POST',
205
+ body: parameters,
206
+ responseKey: 'lynx_migration_reservation_run',
207
+ options,
208
+ })
209
+ }
210
+
211
+ listPropertyReservations(
212
+ parameters?: SeamConsoleV1LynxMigrationListPropertyReservationsParameters,
213
+ options: SeamConsoleV1LynxMigrationListPropertyReservationsOptions = {},
214
+ ): SeamConsoleV1LynxMigrationListPropertyReservationsRequest {
215
+ if (!this.defaults.isUndocumentedApiEnabled) {
216
+ throw new Error(
217
+ 'Cannot use undocumented API without isUndocumentedApiEnabled',
218
+ )
219
+ }
220
+ return new SeamHttpRequest(this, {
221
+ pathname: '/seam/console/v1/lynx_migration/list_property_reservations',
222
+ method: 'POST',
223
+ body: parameters,
224
+ responseKey: 'lynx_migration_property_plan',
225
+ options,
226
+ })
227
+ }
228
+
229
+ migrateProperty(
230
+ parameters?: SeamConsoleV1LynxMigrationMigratePropertyParameters,
231
+ options: SeamConsoleV1LynxMigrationMigratePropertyOptions = {},
232
+ ): SeamConsoleV1LynxMigrationMigratePropertyRequest {
233
+ if (!this.defaults.isUndocumentedApiEnabled) {
234
+ throw new Error(
235
+ 'Cannot use undocumented API without isUndocumentedApiEnabled',
236
+ )
237
+ }
238
+ return new SeamHttpRequest(this, {
239
+ pathname: '/seam/console/v1/lynx_migration/migrate_property',
240
+ method: 'POST',
241
+ body: parameters,
242
+ responseKey: 'lynx_migration_property_run',
243
+ options,
244
+ })
245
+ }
246
+ }
247
+
248
+ export type SeamConsoleV1LynxMigrationGetPropertyMigrationStatusParameters =
249
+ RouteRequestBody<'/seam/console/v1/lynx_migration/get_property_migration_status'>
250
+
251
+ /**
252
+ * @deprecated Use SeamConsoleV1LynxMigrationGetPropertyMigrationStatusParameters instead.
253
+ */
254
+ export type SeamConsoleV1LynxMigrationGetPropertyMigrationStatusParams =
255
+ SeamConsoleV1LynxMigrationGetPropertyMigrationStatusParameters
256
+
257
+ /**
258
+ * @deprecated Use SeamConsoleV1LynxMigrationGetPropertyMigrationStatusRequest instead.
259
+ */
260
+ export type SeamConsoleV1LynxMigrationGetPropertyMigrationStatusResponse =
261
+ SetNonNullable<
262
+ Required<
263
+ RouteResponse<'/seam/console/v1/lynx_migration/get_property_migration_status'>
264
+ >
265
+ >
266
+
267
+ export type SeamConsoleV1LynxMigrationGetPropertyMigrationStatusRequest =
268
+ SeamHttpRequest<
269
+ SeamConsoleV1LynxMigrationGetPropertyMigrationStatusResponse,
270
+ 'lynx_migration_property_run'
271
+ >
272
+
273
+ export interface SeamConsoleV1LynxMigrationGetPropertyMigrationStatusOptions {}
274
+
275
+ export type SeamConsoleV1LynxMigrationGetReservationMigrationStatusParameters =
276
+ RouteRequestBody<'/seam/console/v1/lynx_migration/get_reservation_migration_status'>
277
+
278
+ /**
279
+ * @deprecated Use SeamConsoleV1LynxMigrationGetReservationMigrationStatusParameters instead.
280
+ */
281
+ export type SeamConsoleV1LynxMigrationGetReservationMigrationStatusParams =
282
+ SeamConsoleV1LynxMigrationGetReservationMigrationStatusParameters
283
+
284
+ /**
285
+ * @deprecated Use SeamConsoleV1LynxMigrationGetReservationMigrationStatusRequest instead.
286
+ */
287
+ export type SeamConsoleV1LynxMigrationGetReservationMigrationStatusResponse =
288
+ SetNonNullable<
289
+ Required<
290
+ RouteResponse<'/seam/console/v1/lynx_migration/get_reservation_migration_status'>
291
+ >
292
+ >
293
+
294
+ export type SeamConsoleV1LynxMigrationGetReservationMigrationStatusRequest =
295
+ SeamHttpRequest<
296
+ SeamConsoleV1LynxMigrationGetReservationMigrationStatusResponse,
297
+ 'lynx_migration_reservation_run'
298
+ >
299
+
300
+ export interface SeamConsoleV1LynxMigrationGetReservationMigrationStatusOptions {}
301
+
302
+ export type SeamConsoleV1LynxMigrationListPropertyReservationsParameters =
303
+ RouteRequestBody<'/seam/console/v1/lynx_migration/list_property_reservations'>
304
+
305
+ /**
306
+ * @deprecated Use SeamConsoleV1LynxMigrationListPropertyReservationsParameters instead.
307
+ */
308
+ export type SeamConsoleV1LynxMigrationListPropertyReservationsParams =
309
+ SeamConsoleV1LynxMigrationListPropertyReservationsParameters
310
+
311
+ /**
312
+ * @deprecated Use SeamConsoleV1LynxMigrationListPropertyReservationsRequest instead.
313
+ */
314
+ export type SeamConsoleV1LynxMigrationListPropertyReservationsResponse =
315
+ SetNonNullable<
316
+ Required<
317
+ RouteResponse<'/seam/console/v1/lynx_migration/list_property_reservations'>
318
+ >
319
+ >
320
+
321
+ export type SeamConsoleV1LynxMigrationListPropertyReservationsRequest =
322
+ SeamHttpRequest<
323
+ SeamConsoleV1LynxMigrationListPropertyReservationsResponse,
324
+ 'lynx_migration_property_plan'
325
+ >
326
+
327
+ export interface SeamConsoleV1LynxMigrationListPropertyReservationsOptions {}
328
+
329
+ export type SeamConsoleV1LynxMigrationMigratePropertyParameters =
330
+ RouteRequestBody<'/seam/console/v1/lynx_migration/migrate_property'>
331
+
332
+ /**
333
+ * @deprecated Use SeamConsoleV1LynxMigrationMigratePropertyParameters instead.
334
+ */
335
+ export type SeamConsoleV1LynxMigrationMigratePropertyBody =
336
+ SeamConsoleV1LynxMigrationMigratePropertyParameters
337
+
338
+ /**
339
+ * @deprecated Use SeamConsoleV1LynxMigrationMigratePropertyRequest instead.
340
+ */
341
+ export type SeamConsoleV1LynxMigrationMigratePropertyResponse = SetNonNullable<
342
+ Required<RouteResponse<'/seam/console/v1/lynx_migration/migrate_property'>>
343
+ >
344
+
345
+ export type SeamConsoleV1LynxMigrationMigratePropertyRequest = SeamHttpRequest<
346
+ SeamConsoleV1LynxMigrationMigratePropertyResponse,
347
+ 'lynx_migration_property_run'
348
+ >
349
+
350
+ export interface SeamConsoleV1LynxMigrationMigratePropertyOptions {}
@@ -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 './sites.js'
@@ -0,0 +1,327 @@
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 SeamHttpSeamConsoleV1Sites {
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
+ if (!options.isUndocumentedApiEnabled) {
48
+ throw new Error(
49
+ 'Cannot use undocumented API without isUndocumentedApiEnabled',
50
+ )
51
+ }
52
+ this.client = 'client' in options ? options.client : createClient(options)
53
+ this.defaults = limitToSeamHttpRequestOptions(options)
54
+ }
55
+
56
+ static fromClient(
57
+ client: SeamHttpOptionsWithClient['client'],
58
+ options: Omit<SeamHttpOptionsWithClient, 'client'> = {},
59
+ ): SeamHttpSeamConsoleV1Sites {
60
+ const constructorOptions = { ...options, client }
61
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
62
+ throw new SeamHttpInvalidOptionsError('Missing client')
63
+ }
64
+ return new SeamHttpSeamConsoleV1Sites(constructorOptions)
65
+ }
66
+
67
+ static fromApiKey(
68
+ apiKey: SeamHttpOptionsWithApiKey['apiKey'],
69
+ options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
70
+ ): SeamHttpSeamConsoleV1Sites {
71
+ const constructorOptions = { ...options, apiKey }
72
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
73
+ throw new SeamHttpInvalidOptionsError('Missing apiKey')
74
+ }
75
+ return new SeamHttpSeamConsoleV1Sites(constructorOptions)
76
+ }
77
+
78
+ static fromClientSessionToken(
79
+ clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
80
+ options: Omit<
81
+ SeamHttpOptionsWithClientSessionToken,
82
+ 'clientSessionToken'
83
+ > = {},
84
+ ): SeamHttpSeamConsoleV1Sites {
85
+ const constructorOptions = { ...options, clientSessionToken }
86
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
87
+ throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
88
+ }
89
+ return new SeamHttpSeamConsoleV1Sites(constructorOptions)
90
+ }
91
+
92
+ static async fromPublishableKey(
93
+ publishableKey: string,
94
+ userIdentifierKey: string,
95
+ options: SeamHttpFromPublishableKeyOptions = {},
96
+ ): Promise<SeamHttpSeamConsoleV1Sites> {
97
+ warnOnInsecureuserIdentifierKey(userIdentifierKey)
98
+ const clientOptions = parseOptions({ ...options, publishableKey })
99
+ if (isSeamHttpOptionsWithClient(clientOptions)) {
100
+ throw new SeamHttpInvalidOptionsError(
101
+ 'The client option cannot be used with SeamHttpSeamConsoleV1Sites.fromPublishableKey',
102
+ )
103
+ }
104
+ const client = createClient(clientOptions)
105
+ const clientSessions = SeamHttpClientSessions.fromClient(client)
106
+ const { token } = await clientSessions.getOrCreate({
107
+ user_identifier_key: userIdentifierKey,
108
+ })
109
+ return SeamHttpSeamConsoleV1Sites.fromClientSessionToken(token, options)
110
+ }
111
+
112
+ static fromConsoleSessionToken(
113
+ consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'],
114
+ workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'],
115
+ options: Omit<
116
+ SeamHttpOptionsWithConsoleSessionToken,
117
+ 'consoleSessionToken' | 'workspaceId'
118
+ > = {},
119
+ ): SeamHttpSeamConsoleV1Sites {
120
+ const constructorOptions = { ...options, consoleSessionToken, workspaceId }
121
+ if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) {
122
+ throw new SeamHttpInvalidOptionsError(
123
+ 'Missing consoleSessionToken or workspaceId',
124
+ )
125
+ }
126
+ return new SeamHttpSeamConsoleV1Sites(constructorOptions)
127
+ }
128
+
129
+ static fromPersonalAccessToken(
130
+ personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'],
131
+ workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'],
132
+ options: Omit<
133
+ SeamHttpOptionsWithPersonalAccessToken,
134
+ 'personalAccessToken' | 'workspaceId'
135
+ > = {},
136
+ ): SeamHttpSeamConsoleV1Sites {
137
+ const constructorOptions = { ...options, personalAccessToken, workspaceId }
138
+ if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) {
139
+ throw new SeamHttpInvalidOptionsError(
140
+ 'Missing personalAccessToken or workspaceId',
141
+ )
142
+ }
143
+ return new SeamHttpSeamConsoleV1Sites(constructorOptions)
144
+ }
145
+
146
+ createPaginator<const TResponse, const TResponseKey extends keyof TResponse>(
147
+ request: SeamHttpRequest<TResponse, TResponseKey>,
148
+ ): SeamPaginator<TResponse, TResponseKey> {
149
+ return new SeamPaginator<TResponse, TResponseKey>(this, request)
150
+ }
151
+
152
+ async updateClientSessionToken(
153
+ clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
154
+ ): Promise<void> {
155
+ const { headers } = this.client.defaults
156
+ const authHeaders = getAuthHeadersForClientSessionToken({
157
+ clientSessionToken,
158
+ })
159
+ for (const key of Object.keys(authHeaders)) {
160
+ if (headers[key] == null) {
161
+ throw new Error(
162
+ 'Cannot update a clientSessionToken on a client created without a clientSessionToken',
163
+ )
164
+ }
165
+ }
166
+ this.client.defaults.headers = { ...headers, ...authHeaders }
167
+ const clientSessions = SeamHttpClientSessions.fromClient(this.client)
168
+ await clientSessions.get()
169
+ }
170
+
171
+ create(
172
+ parameters?: SeamConsoleV1SitesCreateParameters,
173
+ options: SeamConsoleV1SitesCreateOptions = {},
174
+ ): SeamConsoleV1SitesCreateRequest {
175
+ if (!this.defaults.isUndocumentedApiEnabled) {
176
+ throw new Error(
177
+ 'Cannot use undocumented API without isUndocumentedApiEnabled',
178
+ )
179
+ }
180
+ return new SeamHttpRequest(this, {
181
+ pathname: '/seam/console/v1/sites/create',
182
+ method: 'POST',
183
+ body: parameters,
184
+ responseKey: 'site',
185
+ options,
186
+ })
187
+ }
188
+
189
+ delete(
190
+ parameters?: SeamConsoleV1SitesDeleteParameters,
191
+ options: SeamConsoleV1SitesDeleteOptions = {},
192
+ ): SeamConsoleV1SitesDeleteRequest {
193
+ if (!this.defaults.isUndocumentedApiEnabled) {
194
+ throw new Error(
195
+ 'Cannot use undocumented API without isUndocumentedApiEnabled',
196
+ )
197
+ }
198
+ return new SeamHttpRequest(this, {
199
+ pathname: '/seam/console/v1/sites/delete',
200
+ method: 'POST',
201
+ body: parameters,
202
+ responseKey: undefined,
203
+ options,
204
+ })
205
+ }
206
+
207
+ list(
208
+ parameters?: SeamConsoleV1SitesListParameters,
209
+ options: SeamConsoleV1SitesListOptions = {},
210
+ ): SeamConsoleV1SitesListRequest {
211
+ if (!this.defaults.isUndocumentedApiEnabled) {
212
+ throw new Error(
213
+ 'Cannot use undocumented API without isUndocumentedApiEnabled',
214
+ )
215
+ }
216
+ return new SeamHttpRequest(this, {
217
+ pathname: '/seam/console/v1/sites/list',
218
+ method: 'POST',
219
+ body: parameters,
220
+ responseKey: 'sites',
221
+ options,
222
+ })
223
+ }
224
+
225
+ update(
226
+ parameters?: SeamConsoleV1SitesUpdateParameters,
227
+ options: SeamConsoleV1SitesUpdateOptions = {},
228
+ ): SeamConsoleV1SitesUpdateRequest {
229
+ if (!this.defaults.isUndocumentedApiEnabled) {
230
+ throw new Error(
231
+ 'Cannot use undocumented API without isUndocumentedApiEnabled',
232
+ )
233
+ }
234
+ return new SeamHttpRequest(this, {
235
+ pathname: '/seam/console/v1/sites/update',
236
+ method: 'PATCH',
237
+ body: parameters,
238
+ responseKey: 'site',
239
+ options,
240
+ })
241
+ }
242
+ }
243
+
244
+ export type SeamConsoleV1SitesCreateParameters =
245
+ RouteRequestBody<'/seam/console/v1/sites/create'>
246
+
247
+ /**
248
+ * @deprecated Use SeamConsoleV1SitesCreateParameters instead.
249
+ */
250
+ export type SeamConsoleV1SitesCreateBody = SeamConsoleV1SitesCreateParameters
251
+
252
+ /**
253
+ * @deprecated Use SeamConsoleV1SitesCreateRequest instead.
254
+ */
255
+ export type SeamConsoleV1SitesCreateResponse = SetNonNullable<
256
+ Required<RouteResponse<'/seam/console/v1/sites/create'>>
257
+ >
258
+
259
+ export type SeamConsoleV1SitesCreateRequest = SeamHttpRequest<
260
+ SeamConsoleV1SitesCreateResponse,
261
+ 'site'
262
+ >
263
+
264
+ export interface SeamConsoleV1SitesCreateOptions {}
265
+
266
+ export type SeamConsoleV1SitesDeleteParameters =
267
+ RouteRequestBody<'/seam/console/v1/sites/delete'>
268
+
269
+ /**
270
+ * @deprecated Use SeamConsoleV1SitesDeleteParameters instead.
271
+ */
272
+ export type SeamConsoleV1SitesDeleteParams = SeamConsoleV1SitesDeleteParameters
273
+
274
+ /**
275
+ * @deprecated Use SeamConsoleV1SitesDeleteRequest instead.
276
+ */
277
+ export type SeamConsoleV1SitesDeleteResponse = SetNonNullable<
278
+ Required<RouteResponse<'/seam/console/v1/sites/delete'>>
279
+ >
280
+
281
+ export type SeamConsoleV1SitesDeleteRequest = SeamHttpRequest<void, undefined>
282
+
283
+ export interface SeamConsoleV1SitesDeleteOptions {}
284
+
285
+ export type SeamConsoleV1SitesListParameters =
286
+ RouteRequestBody<'/seam/console/v1/sites/list'>
287
+
288
+ /**
289
+ * @deprecated Use SeamConsoleV1SitesListParameters instead.
290
+ */
291
+ export type SeamConsoleV1SitesListParams = SeamConsoleV1SitesListParameters
292
+
293
+ /**
294
+ * @deprecated Use SeamConsoleV1SitesListRequest instead.
295
+ */
296
+ export type SeamConsoleV1SitesListResponse = SetNonNullable<
297
+ Required<RouteResponse<'/seam/console/v1/sites/list'>>
298
+ >
299
+
300
+ export type SeamConsoleV1SitesListRequest = SeamHttpRequest<
301
+ SeamConsoleV1SitesListResponse,
302
+ 'sites'
303
+ >
304
+
305
+ export interface SeamConsoleV1SitesListOptions {}
306
+
307
+ export type SeamConsoleV1SitesUpdateParameters =
308
+ RouteRequestBody<'/seam/console/v1/sites/update'>
309
+
310
+ /**
311
+ * @deprecated Use SeamConsoleV1SitesUpdateParameters instead.
312
+ */
313
+ export type SeamConsoleV1SitesUpdateBody = SeamConsoleV1SitesUpdateParameters
314
+
315
+ /**
316
+ * @deprecated Use SeamConsoleV1SitesUpdateRequest instead.
317
+ */
318
+ export type SeamConsoleV1SitesUpdateResponse = SetNonNullable<
319
+ Required<RouteResponse<'/seam/console/v1/sites/update'>>
320
+ >
321
+
322
+ export type SeamConsoleV1SitesUpdateRequest = SeamHttpRequest<
323
+ SeamConsoleV1SitesUpdateResponse,
324
+ 'site'
325
+ >
326
+
327
+ export interface SeamConsoleV1SitesUpdateOptions {}