@seamapi/http 1.49.0 → 1.51.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.
- package/dist/connect.cjs +313 -117
- package/dist/connect.cjs.map +1 -1
- package/dist/connect.d.cts +106 -59
- package/dist/index.cjs +319 -119
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/lib/seam/connect/resolve-action-attempt.d.ts +16 -16
- package/lib/seam/connect/routes/index.d.ts +1 -1
- package/lib/seam/connect/routes/index.js +1 -1
- package/lib/seam/connect/routes/index.js.map +1 -1
- package/lib/seam/connect/routes/instant-keys/index.d.ts +1 -0
- package/lib/seam/connect/routes/instant-keys/index.js +6 -0
- package/lib/seam/connect/routes/instant-keys/index.js.map +1 -0
- package/lib/seam/connect/routes/{networks/networks.d.ts → instant-keys/instant-keys.d.ts} +15 -28
- package/lib/seam/connect/routes/{networks/networks.js → instant-keys/instant-keys.js} +12 -30
- package/lib/seam/connect/routes/instant-keys/instant-keys.js.map +1 -0
- package/lib/seam/connect/routes/seam/console/console.d.ts +21 -0
- package/lib/seam/connect/routes/seam/console/console.js +93 -0
- package/lib/seam/connect/routes/seam/console/console.js.map +1 -0
- package/lib/seam/connect/routes/seam/console/index.d.ts +2 -0
- package/lib/seam/connect/routes/seam/console/index.js +7 -0
- package/lib/seam/connect/routes/seam/console/index.js.map +1 -0
- package/lib/seam/connect/routes/seam/console/v1/index.d.ts +1 -0
- package/lib/seam/connect/routes/{networks → seam/console/v1}/index.js +1 -1
- package/lib/seam/connect/routes/seam/console/v1/index.js.map +1 -0
- package/lib/seam/connect/routes/seam/console/v1/v1.d.ts +34 -0
- package/lib/seam/connect/routes/seam/console/v1/v1.js +102 -0
- package/lib/seam/connect/routes/seam/console/v1/v1.js.map +1 -0
- package/lib/seam/connect/routes/seam/index.d.ts +1 -0
- package/lib/seam/connect/routes/seam/index.js +1 -0
- package/lib/seam/connect/routes/seam/index.js.map +1 -1
- package/lib/seam/connect/routes/seam-http-endpoints.d.ts +7 -5
- package/lib/seam/connect/routes/seam-http-endpoints.js +29 -21
- package/lib/seam/connect/routes/seam-http-endpoints.js.map +1 -1
- package/lib/seam/connect/routes/seam-http.d.ts +2 -2
- package/lib/seam/connect/routes/seam-http.js +4 -4
- package/lib/seam/connect/routes/seam-http.js.map +1 -1
- package/lib/seam/connect/routes/workspaces/workspaces.d.ts +13 -0
- package/lib/seam/connect/routes/workspaces/workspaces.js +12 -0
- package/lib/seam/connect/routes/workspaces/workspaces.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +3 -3
- package/src/lib/seam/connect/routes/index.ts +1 -1
- package/src/lib/seam/connect/routes/instant-keys/index.ts +6 -0
- package/src/lib/seam/connect/routes/instant-keys/instant-keys.ts +200 -0
- package/src/lib/seam/connect/routes/seam/console/console.ts +173 -0
- package/src/lib/seam/connect/routes/seam/console/index.ts +7 -0
- package/src/lib/seam/connect/routes/{networks → seam/console/v1}/index.ts +1 -1
- package/src/lib/seam/connect/routes/{networks/networks.ts → seam/console/v1/v1.ts} +35 -70
- package/src/lib/seam/connect/routes/seam/index.ts +1 -0
- package/src/lib/seam/connect/routes/seam-http-endpoints.ts +67 -47
- package/src/lib/seam/connect/routes/seam-http.ts +5 -5
- package/src/lib/seam/connect/routes/workspaces/workspaces.ts +41 -0
- package/src/lib/version.ts +1 -1
- package/lib/seam/connect/routes/networks/index.d.ts +0 -1
- package/lib/seam/connect/routes/networks/index.js.map +0 -1
- package/lib/seam/connect/routes/networks/networks.js.map +0 -1
|
@@ -0,0 +1,200 @@
|
|
|
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 SeamHttpInstantKeys {
|
|
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
|
+
): SeamHttpInstantKeys {
|
|
55
|
+
const constructorOptions = { ...options, client }
|
|
56
|
+
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
57
|
+
throw new SeamHttpInvalidOptionsError('Missing client')
|
|
58
|
+
}
|
|
59
|
+
return new SeamHttpInstantKeys(constructorOptions)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
static fromApiKey(
|
|
63
|
+
apiKey: SeamHttpOptionsWithApiKey['apiKey'],
|
|
64
|
+
options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
|
|
65
|
+
): SeamHttpInstantKeys {
|
|
66
|
+
const constructorOptions = { ...options, apiKey }
|
|
67
|
+
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
68
|
+
throw new SeamHttpInvalidOptionsError('Missing apiKey')
|
|
69
|
+
}
|
|
70
|
+
return new SeamHttpInstantKeys(constructorOptions)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
static fromClientSessionToken(
|
|
74
|
+
clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
|
|
75
|
+
options: Omit<
|
|
76
|
+
SeamHttpOptionsWithClientSessionToken,
|
|
77
|
+
'clientSessionToken'
|
|
78
|
+
> = {},
|
|
79
|
+
): SeamHttpInstantKeys {
|
|
80
|
+
const constructorOptions = { ...options, clientSessionToken }
|
|
81
|
+
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
82
|
+
throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
|
|
83
|
+
}
|
|
84
|
+
return new SeamHttpInstantKeys(constructorOptions)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
static async fromPublishableKey(
|
|
88
|
+
publishableKey: string,
|
|
89
|
+
userIdentifierKey: string,
|
|
90
|
+
options: SeamHttpFromPublishableKeyOptions = {},
|
|
91
|
+
): Promise<SeamHttpInstantKeys> {
|
|
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 SeamHttpInstantKeys.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 SeamHttpInstantKeys.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
|
+
): SeamHttpInstantKeys {
|
|
115
|
+
const constructorOptions = { ...options, consoleSessionToken, workspaceId }
|
|
116
|
+
if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) {
|
|
117
|
+
throw new SeamHttpInvalidOptionsError(
|
|
118
|
+
'Missing consoleSessionToken or workspaceId',
|
|
119
|
+
)
|
|
120
|
+
}
|
|
121
|
+
return new SeamHttpInstantKeys(constructorOptions)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
static fromPersonalAccessToken(
|
|
125
|
+
personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'],
|
|
126
|
+
workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'],
|
|
127
|
+
options: Omit<
|
|
128
|
+
SeamHttpOptionsWithPersonalAccessToken,
|
|
129
|
+
'personalAccessToken' | 'workspaceId'
|
|
130
|
+
> = {},
|
|
131
|
+
): SeamHttpInstantKeys {
|
|
132
|
+
const constructorOptions = { ...options, personalAccessToken, workspaceId }
|
|
133
|
+
if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) {
|
|
134
|
+
throw new SeamHttpInvalidOptionsError(
|
|
135
|
+
'Missing personalAccessToken or workspaceId',
|
|
136
|
+
)
|
|
137
|
+
}
|
|
138
|
+
return new SeamHttpInstantKeys(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
|
+
list(
|
|
167
|
+
parameters?: InstantKeysListParameters,
|
|
168
|
+
options: InstantKeysListOptions = {},
|
|
169
|
+
): InstantKeysListRequest {
|
|
170
|
+
return new SeamHttpRequest(this, {
|
|
171
|
+
pathname: '/instant_keys/list',
|
|
172
|
+
method: 'POST',
|
|
173
|
+
body: parameters,
|
|
174
|
+
responseKey: 'instant_keys',
|
|
175
|
+
options,
|
|
176
|
+
})
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export type InstantKeysListParameters = RouteRequestBody<'/instant_keys/list'>
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* @deprecated Use InstantKeysListParameters instead.
|
|
184
|
+
*/
|
|
185
|
+
export type InstantKeysListParams = InstantKeysListParameters
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* @deprecated Use InstantKeysListRequest instead.
|
|
189
|
+
*/
|
|
190
|
+
export type InstantKeysListResponse = SetNonNullable<
|
|
191
|
+
Required<RouteResponse<'/instant_keys/list'>>
|
|
192
|
+
>
|
|
193
|
+
|
|
194
|
+
export type InstantKeysListRequest = SeamHttpRequest<
|
|
195
|
+
InstantKeysListResponse,
|
|
196
|
+
'instant_keys'
|
|
197
|
+
>
|
|
198
|
+
|
|
199
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
200
|
+
export interface InstantKeysListOptions {}
|
|
@@ -0,0 +1,173 @@
|
|
|
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 { seamApiLtsVersion } from 'lib/lts-version.js'
|
|
7
|
+
import {
|
|
8
|
+
getAuthHeadersForClientSessionToken,
|
|
9
|
+
warnOnInsecureuserIdentifierKey,
|
|
10
|
+
} from 'lib/seam/connect/auth.js'
|
|
11
|
+
import { type Client, createClient } from 'lib/seam/connect/client.js'
|
|
12
|
+
import {
|
|
13
|
+
isSeamHttpOptionsWithApiKey,
|
|
14
|
+
isSeamHttpOptionsWithClient,
|
|
15
|
+
isSeamHttpOptionsWithClientSessionToken,
|
|
16
|
+
isSeamHttpOptionsWithConsoleSessionToken,
|
|
17
|
+
isSeamHttpOptionsWithPersonalAccessToken,
|
|
18
|
+
type SeamHttpFromPublishableKeyOptions,
|
|
19
|
+
SeamHttpInvalidOptionsError,
|
|
20
|
+
type SeamHttpOptions,
|
|
21
|
+
type SeamHttpOptionsWithApiKey,
|
|
22
|
+
type SeamHttpOptionsWithClient,
|
|
23
|
+
type SeamHttpOptionsWithClientSessionToken,
|
|
24
|
+
type SeamHttpOptionsWithConsoleSessionToken,
|
|
25
|
+
type SeamHttpOptionsWithPersonalAccessToken,
|
|
26
|
+
type SeamHttpRequestOptions,
|
|
27
|
+
} from 'lib/seam/connect/options.js'
|
|
28
|
+
import {
|
|
29
|
+
limitToSeamHttpRequestOptions,
|
|
30
|
+
parseOptions,
|
|
31
|
+
} from 'lib/seam/connect/parse-options.js'
|
|
32
|
+
import { SeamHttpClientSessions } from 'lib/seam/connect/routes/client-sessions/index.js'
|
|
33
|
+
import type { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js'
|
|
34
|
+
import { SeamPaginator } from 'lib/seam/connect/seam-paginator.js'
|
|
35
|
+
|
|
36
|
+
import { SeamHttpSeamConsoleV1 } from './v1/index.js'
|
|
37
|
+
|
|
38
|
+
export class SeamHttpSeamConsole {
|
|
39
|
+
client: Client
|
|
40
|
+
readonly defaults: Required<SeamHttpRequestOptions>
|
|
41
|
+
readonly ltsVersion = seamApiLtsVersion
|
|
42
|
+
static ltsVersion = seamApiLtsVersion
|
|
43
|
+
|
|
44
|
+
constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
|
|
45
|
+
const options = parseOptions(apiKeyOrOptions)
|
|
46
|
+
if (!options.isUndocumentedApiEnabled) {
|
|
47
|
+
throw new Error(
|
|
48
|
+
'Cannot use undocumented API without isUndocumentedApiEnabled',
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
this.client = 'client' in options ? options.client : createClient(options)
|
|
52
|
+
this.defaults = limitToSeamHttpRequestOptions(options)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
static fromClient(
|
|
56
|
+
client: SeamHttpOptionsWithClient['client'],
|
|
57
|
+
options: Omit<SeamHttpOptionsWithClient, 'client'> = {},
|
|
58
|
+
): SeamHttpSeamConsole {
|
|
59
|
+
const constructorOptions = { ...options, client }
|
|
60
|
+
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
61
|
+
throw new SeamHttpInvalidOptionsError('Missing client')
|
|
62
|
+
}
|
|
63
|
+
return new SeamHttpSeamConsole(constructorOptions)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
static fromApiKey(
|
|
67
|
+
apiKey: SeamHttpOptionsWithApiKey['apiKey'],
|
|
68
|
+
options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
|
|
69
|
+
): SeamHttpSeamConsole {
|
|
70
|
+
const constructorOptions = { ...options, apiKey }
|
|
71
|
+
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
72
|
+
throw new SeamHttpInvalidOptionsError('Missing apiKey')
|
|
73
|
+
}
|
|
74
|
+
return new SeamHttpSeamConsole(constructorOptions)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
static fromClientSessionToken(
|
|
78
|
+
clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
|
|
79
|
+
options: Omit<
|
|
80
|
+
SeamHttpOptionsWithClientSessionToken,
|
|
81
|
+
'clientSessionToken'
|
|
82
|
+
> = {},
|
|
83
|
+
): SeamHttpSeamConsole {
|
|
84
|
+
const constructorOptions = { ...options, clientSessionToken }
|
|
85
|
+
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
86
|
+
throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
|
|
87
|
+
}
|
|
88
|
+
return new SeamHttpSeamConsole(constructorOptions)
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
static async fromPublishableKey(
|
|
92
|
+
publishableKey: string,
|
|
93
|
+
userIdentifierKey: string,
|
|
94
|
+
options: SeamHttpFromPublishableKeyOptions = {},
|
|
95
|
+
): Promise<SeamHttpSeamConsole> {
|
|
96
|
+
warnOnInsecureuserIdentifierKey(userIdentifierKey)
|
|
97
|
+
const clientOptions = parseOptions({ ...options, publishableKey })
|
|
98
|
+
if (isSeamHttpOptionsWithClient(clientOptions)) {
|
|
99
|
+
throw new SeamHttpInvalidOptionsError(
|
|
100
|
+
'The client option cannot be used with SeamHttpSeamConsole.fromPublishableKey',
|
|
101
|
+
)
|
|
102
|
+
}
|
|
103
|
+
const client = createClient(clientOptions)
|
|
104
|
+
const clientSessions = SeamHttpClientSessions.fromClient(client)
|
|
105
|
+
const { token } = await clientSessions.getOrCreate({
|
|
106
|
+
user_identifier_key: userIdentifierKey,
|
|
107
|
+
})
|
|
108
|
+
return SeamHttpSeamConsole.fromClientSessionToken(token, options)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
static fromConsoleSessionToken(
|
|
112
|
+
consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'],
|
|
113
|
+
workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'],
|
|
114
|
+
options: Omit<
|
|
115
|
+
SeamHttpOptionsWithConsoleSessionToken,
|
|
116
|
+
'consoleSessionToken' | 'workspaceId'
|
|
117
|
+
> = {},
|
|
118
|
+
): SeamHttpSeamConsole {
|
|
119
|
+
const constructorOptions = { ...options, consoleSessionToken, workspaceId }
|
|
120
|
+
if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) {
|
|
121
|
+
throw new SeamHttpInvalidOptionsError(
|
|
122
|
+
'Missing consoleSessionToken or workspaceId',
|
|
123
|
+
)
|
|
124
|
+
}
|
|
125
|
+
return new SeamHttpSeamConsole(constructorOptions)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
static fromPersonalAccessToken(
|
|
129
|
+
personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'],
|
|
130
|
+
workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'],
|
|
131
|
+
options: Omit<
|
|
132
|
+
SeamHttpOptionsWithPersonalAccessToken,
|
|
133
|
+
'personalAccessToken' | 'workspaceId'
|
|
134
|
+
> = {},
|
|
135
|
+
): SeamHttpSeamConsole {
|
|
136
|
+
const constructorOptions = { ...options, personalAccessToken, workspaceId }
|
|
137
|
+
if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) {
|
|
138
|
+
throw new SeamHttpInvalidOptionsError(
|
|
139
|
+
'Missing personalAccessToken or workspaceId',
|
|
140
|
+
)
|
|
141
|
+
}
|
|
142
|
+
return new SeamHttpSeamConsole(constructorOptions)
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
createPaginator<const TResponse, const TResponseKey extends keyof TResponse>(
|
|
146
|
+
request: SeamHttpRequest<TResponse, TResponseKey>,
|
|
147
|
+
): SeamPaginator<TResponse, TResponseKey> {
|
|
148
|
+
return new SeamPaginator<TResponse, TResponseKey>(this, request)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
async updateClientSessionToken(
|
|
152
|
+
clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
|
|
153
|
+
): Promise<void> {
|
|
154
|
+
const { headers } = this.client.defaults
|
|
155
|
+
const authHeaders = getAuthHeadersForClientSessionToken({
|
|
156
|
+
clientSessionToken,
|
|
157
|
+
})
|
|
158
|
+
for (const key of Object.keys(authHeaders)) {
|
|
159
|
+
if (headers[key] == null) {
|
|
160
|
+
throw new Error(
|
|
161
|
+
'Cannot update a clientSessionToken on a client created without a clientSessionToken',
|
|
162
|
+
)
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
this.client.defaults.headers = { ...headers, ...authHeaders }
|
|
166
|
+
const clientSessions = SeamHttpClientSessions.fromClient(this.client)
|
|
167
|
+
await clientSessions.get()
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
get v1(): SeamHttpSeamConsoleV1 {
|
|
171
|
+
return SeamHttpSeamConsoleV1.fromClient(this.client, this.defaults)
|
|
172
|
+
}
|
|
173
|
+
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Do not edit this file or add other files to this directory.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import type {
|
|
6
|
+
import type { RouteRequestParams, RouteResponse } from '@seamapi/types/connect'
|
|
7
7
|
|
|
8
8
|
import { seamApiLtsVersion } from 'lib/lts-version.js'
|
|
9
9
|
import {
|
|
@@ -36,7 +36,7 @@ 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
|
-
export class
|
|
39
|
+
export class SeamHttpSeamConsoleV1 {
|
|
40
40
|
client: Client
|
|
41
41
|
readonly defaults: Required<SeamHttpRequestOptions>
|
|
42
42
|
readonly ltsVersion = seamApiLtsVersion
|
|
@@ -56,23 +56,23 @@ export class SeamHttpNetworks {
|
|
|
56
56
|
static fromClient(
|
|
57
57
|
client: SeamHttpOptionsWithClient['client'],
|
|
58
58
|
options: Omit<SeamHttpOptionsWithClient, 'client'> = {},
|
|
59
|
-
):
|
|
59
|
+
): SeamHttpSeamConsoleV1 {
|
|
60
60
|
const constructorOptions = { ...options, client }
|
|
61
61
|
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
62
62
|
throw new SeamHttpInvalidOptionsError('Missing client')
|
|
63
63
|
}
|
|
64
|
-
return new
|
|
64
|
+
return new SeamHttpSeamConsoleV1(constructorOptions)
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
static fromApiKey(
|
|
68
68
|
apiKey: SeamHttpOptionsWithApiKey['apiKey'],
|
|
69
69
|
options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
|
|
70
|
-
):
|
|
70
|
+
): SeamHttpSeamConsoleV1 {
|
|
71
71
|
const constructorOptions = { ...options, apiKey }
|
|
72
72
|
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
73
73
|
throw new SeamHttpInvalidOptionsError('Missing apiKey')
|
|
74
74
|
}
|
|
75
|
-
return new
|
|
75
|
+
return new SeamHttpSeamConsoleV1(constructorOptions)
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
static fromClientSessionToken(
|
|
@@ -81,24 +81,24 @@ export class SeamHttpNetworks {
|
|
|
81
81
|
SeamHttpOptionsWithClientSessionToken,
|
|
82
82
|
'clientSessionToken'
|
|
83
83
|
> = {},
|
|
84
|
-
):
|
|
84
|
+
): SeamHttpSeamConsoleV1 {
|
|
85
85
|
const constructorOptions = { ...options, clientSessionToken }
|
|
86
86
|
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
87
87
|
throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
|
|
88
88
|
}
|
|
89
|
-
return new
|
|
89
|
+
return new SeamHttpSeamConsoleV1(constructorOptions)
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
static async fromPublishableKey(
|
|
93
93
|
publishableKey: string,
|
|
94
94
|
userIdentifierKey: string,
|
|
95
95
|
options: SeamHttpFromPublishableKeyOptions = {},
|
|
96
|
-
): Promise<
|
|
96
|
+
): Promise<SeamHttpSeamConsoleV1> {
|
|
97
97
|
warnOnInsecureuserIdentifierKey(userIdentifierKey)
|
|
98
98
|
const clientOptions = parseOptions({ ...options, publishableKey })
|
|
99
99
|
if (isSeamHttpOptionsWithClient(clientOptions)) {
|
|
100
100
|
throw new SeamHttpInvalidOptionsError(
|
|
101
|
-
'The client option cannot be used with
|
|
101
|
+
'The client option cannot be used with SeamHttpSeamConsoleV1.fromPublishableKey',
|
|
102
102
|
)
|
|
103
103
|
}
|
|
104
104
|
const client = createClient(clientOptions)
|
|
@@ -106,7 +106,7 @@ export class SeamHttpNetworks {
|
|
|
106
106
|
const { token } = await clientSessions.getOrCreate({
|
|
107
107
|
user_identifier_key: userIdentifierKey,
|
|
108
108
|
})
|
|
109
|
-
return
|
|
109
|
+
return SeamHttpSeamConsoleV1.fromClientSessionToken(token, options)
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
static fromConsoleSessionToken(
|
|
@@ -116,14 +116,14 @@ export class SeamHttpNetworks {
|
|
|
116
116
|
SeamHttpOptionsWithConsoleSessionToken,
|
|
117
117
|
'consoleSessionToken' | 'workspaceId'
|
|
118
118
|
> = {},
|
|
119
|
-
):
|
|
119
|
+
): SeamHttpSeamConsoleV1 {
|
|
120
120
|
const constructorOptions = { ...options, consoleSessionToken, workspaceId }
|
|
121
121
|
if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) {
|
|
122
122
|
throw new SeamHttpInvalidOptionsError(
|
|
123
123
|
'Missing consoleSessionToken or workspaceId',
|
|
124
124
|
)
|
|
125
125
|
}
|
|
126
|
-
return new
|
|
126
|
+
return new SeamHttpSeamConsoleV1(constructorOptions)
|
|
127
127
|
}
|
|
128
128
|
|
|
129
129
|
static fromPersonalAccessToken(
|
|
@@ -133,14 +133,14 @@ export class SeamHttpNetworks {
|
|
|
133
133
|
SeamHttpOptionsWithPersonalAccessToken,
|
|
134
134
|
'personalAccessToken' | 'workspaceId'
|
|
135
135
|
> = {},
|
|
136
|
-
):
|
|
136
|
+
): SeamHttpSeamConsoleV1 {
|
|
137
137
|
const constructorOptions = { ...options, personalAccessToken, workspaceId }
|
|
138
138
|
if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) {
|
|
139
139
|
throw new SeamHttpInvalidOptionsError(
|
|
140
140
|
'Missing personalAccessToken or workspaceId',
|
|
141
141
|
)
|
|
142
142
|
}
|
|
143
|
-
return new
|
|
143
|
+
return new SeamHttpSeamConsoleV1(constructorOptions)
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
createPaginator<const TResponse, const TResponseKey extends keyof TResponse>(
|
|
@@ -168,80 +168,45 @@ export class SeamHttpNetworks {
|
|
|
168
168
|
await clientSessions.get()
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
-
|
|
172
|
-
parameters?:
|
|
173
|
-
options:
|
|
174
|
-
):
|
|
171
|
+
getResourceLocator(
|
|
172
|
+
parameters?: SeamConsoleV1GetResourceLocatorParameters,
|
|
173
|
+
options: SeamConsoleV1GetResourceLocatorOptions = {},
|
|
174
|
+
): SeamConsoleV1GetResourceLocatorRequest {
|
|
175
175
|
if (!this.defaults.isUndocumentedApiEnabled) {
|
|
176
176
|
throw new Error(
|
|
177
177
|
'Cannot use undocumented API without isUndocumentedApiEnabled',
|
|
178
178
|
)
|
|
179
179
|
}
|
|
180
180
|
return new SeamHttpRequest(this, {
|
|
181
|
-
pathname: '/
|
|
182
|
-
method: '
|
|
183
|
-
|
|
184
|
-
responseKey: '
|
|
185
|
-
options,
|
|
186
|
-
})
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
list(
|
|
190
|
-
parameters?: NetworksListParameters,
|
|
191
|
-
options: NetworksListOptions = {},
|
|
192
|
-
): NetworksListRequest {
|
|
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: '/networks/list',
|
|
200
|
-
method: 'POST',
|
|
201
|
-
body: parameters,
|
|
202
|
-
responseKey: 'networks',
|
|
181
|
+
pathname: '/seam/console/v1/get_resource_locator',
|
|
182
|
+
method: 'GET',
|
|
183
|
+
params: parameters,
|
|
184
|
+
responseKey: 'resource_locator',
|
|
203
185
|
options,
|
|
204
186
|
})
|
|
205
187
|
}
|
|
206
188
|
}
|
|
207
189
|
|
|
208
|
-
export type
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* @deprecated Use NetworksGetParameters instead.
|
|
212
|
-
*/
|
|
213
|
-
export type NetworksGetParams = NetworksGetParameters
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* @deprecated Use NetworksGetRequest instead.
|
|
217
|
-
*/
|
|
218
|
-
export type NetworksGetResponse = SetNonNullable<
|
|
219
|
-
Required<RouteResponse<'/networks/get'>>
|
|
220
|
-
>
|
|
221
|
-
|
|
222
|
-
export type NetworksGetRequest = SeamHttpRequest<NetworksGetResponse, 'network'>
|
|
223
|
-
|
|
224
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
225
|
-
export interface NetworksGetOptions {}
|
|
226
|
-
|
|
227
|
-
export type NetworksListParameters = RouteRequestBody<'/networks/list'>
|
|
190
|
+
export type SeamConsoleV1GetResourceLocatorParameters =
|
|
191
|
+
RouteRequestParams<'/seam/console/v1/get_resource_locator'>
|
|
228
192
|
|
|
229
193
|
/**
|
|
230
|
-
* @deprecated Use
|
|
194
|
+
* @deprecated Use SeamConsoleV1GetResourceLocatorParameters instead.
|
|
231
195
|
*/
|
|
232
|
-
export type
|
|
196
|
+
export type SeamConsoleV1GetResourceLocatorParams =
|
|
197
|
+
SeamConsoleV1GetResourceLocatorParameters
|
|
233
198
|
|
|
234
199
|
/**
|
|
235
|
-
* @deprecated Use
|
|
200
|
+
* @deprecated Use SeamConsoleV1GetResourceLocatorRequest instead.
|
|
236
201
|
*/
|
|
237
|
-
export type
|
|
238
|
-
Required<RouteResponse<'/
|
|
202
|
+
export type SeamConsoleV1GetResourceLocatorResponse = SetNonNullable<
|
|
203
|
+
Required<RouteResponse<'/seam/console/v1/get_resource_locator'>>
|
|
239
204
|
>
|
|
240
205
|
|
|
241
|
-
export type
|
|
242
|
-
|
|
243
|
-
'
|
|
206
|
+
export type SeamConsoleV1GetResourceLocatorRequest = SeamHttpRequest<
|
|
207
|
+
SeamConsoleV1GetResourceLocatorResponse,
|
|
208
|
+
'resource_locator'
|
|
244
209
|
>
|
|
245
210
|
|
|
246
211
|
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
247
|
-
export interface
|
|
212
|
+
export interface SeamConsoleV1GetResourceLocatorOptions {}
|