@seamapi/http 0.27.0 → 1.0.0-rc.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 +190 -7
- package/dist/connect.cjs.map +1 -1
- package/dist/connect.d.cts +44 -8
- package/lib/seam/connect/routes/access-codes-simulate.d.ts +21 -0
- package/lib/seam/connect/routes/access-codes-simulate.js +88 -0
- package/lib/seam/connect/routes/access-codes-simulate.js.map +1 -0
- package/lib/seam/connect/routes/access-codes.d.ts +2 -0
- package/lib/seam/connect/routes/access-codes.js +4 -0
- package/lib/seam/connect/routes/access-codes.js.map +1 -1
- package/lib/seam/connect/routes/acs-credentials.d.ts +3 -3
- package/lib/seam/connect/routes/acs-credentials.js +3 -3
- package/lib/seam/connect/routes/acs-credentials.js.map +1 -1
- package/lib/seam/connect/routes/client-sessions.d.ts +1 -1
- package/lib/seam/connect/routes/client-sessions.js +1 -1
- package/lib/seam/connect/routes/client-sessions.js.map +1 -1
- package/lib/seam/connect/routes/index.d.ts +2 -0
- package/lib/seam/connect/routes/index.js +2 -0
- package/lib/seam/connect/routes/index.js.map +1 -1
- package/lib/seam/connect/routes/noise-sensors-simulate.d.ts +21 -0
- package/lib/seam/connect/routes/noise-sensors-simulate.js +88 -0
- package/lib/seam/connect/routes/noise-sensors-simulate.js.map +1 -0
- package/lib/seam/connect/routes/noise-sensors.d.ts +2 -0
- package/lib/seam/connect/routes/noise-sensors.js +4 -0
- package/lib/seam/connect/routes/noise-sensors.js.map +1 -1
- package/lib/seam/connect/routes/user-identities.d.ts +1 -1
- package/lib/seam/connect/routes/user-identities.js +1 -1
- package/lib/seam/connect/routes/user-identities.js.map +1 -1
- package/lib/seam/connect/routes/workspaces.d.ts +2 -2
- package/lib/seam/connect/routes/workspaces.js +3 -2
- package/lib/seam/connect/routes/workspaces.js.map +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/lib/version.js.map +1 -1
- package/package.json +1 -1
- package/src/lib/seam/connect/routes/access-codes-simulate.ts +182 -0
- package/src/lib/seam/connect/routes/access-codes.ts +5 -0
- package/src/lib/seam/connect/routes/acs-credentials.ts +6 -10
- package/src/lib/seam/connect/routes/client-sessions.ts +2 -2
- package/src/lib/seam/connect/routes/index.ts +2 -0
- package/src/lib/seam/connect/routes/noise-sensors-simulate.ts +176 -0
- package/src/lib/seam/connect/routes/noise-sensors.ts +5 -0
- package/src/lib/seam/connect/routes/user-identities.ts +2 -5
- package/src/lib/seam/connect/routes/workspaces.ts +8 -3
- package/src/lib/version.ts +1 -1
|
@@ -0,0 +1,176 @@
|
|
|
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
|
+
|
|
8
|
+
import {
|
|
9
|
+
getAuthHeadersForClientSessionToken,
|
|
10
|
+
warnOnInsecureuserIdentifierKey,
|
|
11
|
+
} from 'lib/seam/connect/auth.js'
|
|
12
|
+
import { type Client, createClient } from 'lib/seam/connect/client.js'
|
|
13
|
+
import {
|
|
14
|
+
isSeamHttpOptionsWithApiKey,
|
|
15
|
+
isSeamHttpOptionsWithClient,
|
|
16
|
+
isSeamHttpOptionsWithClientSessionToken,
|
|
17
|
+
isSeamHttpOptionsWithConsoleSessionToken,
|
|
18
|
+
isSeamHttpOptionsWithPersonalAccessToken,
|
|
19
|
+
type SeamHttpFromPublishableKeyOptions,
|
|
20
|
+
SeamHttpInvalidOptionsError,
|
|
21
|
+
type SeamHttpOptions,
|
|
22
|
+
type SeamHttpOptionsWithApiKey,
|
|
23
|
+
type SeamHttpOptionsWithClient,
|
|
24
|
+
type SeamHttpOptionsWithClientSessionToken,
|
|
25
|
+
type SeamHttpOptionsWithConsoleSessionToken,
|
|
26
|
+
type SeamHttpOptionsWithPersonalAccessToken,
|
|
27
|
+
type SeamHttpRequestOptions,
|
|
28
|
+
} from 'lib/seam/connect/options.js'
|
|
29
|
+
import {
|
|
30
|
+
limitToSeamHttpRequestOptions,
|
|
31
|
+
parseOptions,
|
|
32
|
+
} from 'lib/seam/connect/parse-options.js'
|
|
33
|
+
import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js'
|
|
34
|
+
import type { SetNonNullable } from 'lib/types.js'
|
|
35
|
+
|
|
36
|
+
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
37
|
+
|
|
38
|
+
export class SeamHttpNoiseSensorsSimulate {
|
|
39
|
+
client: Client
|
|
40
|
+
readonly defaults: Required<SeamHttpRequestOptions>
|
|
41
|
+
|
|
42
|
+
constructor(apiKeyOrOptions: string | SeamHttpOptions = {}) {
|
|
43
|
+
const options = parseOptions(apiKeyOrOptions)
|
|
44
|
+
this.client = 'client' in options ? options.client : createClient(options)
|
|
45
|
+
this.defaults = limitToSeamHttpRequestOptions(options)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
static fromClient(
|
|
49
|
+
client: SeamHttpOptionsWithClient['client'],
|
|
50
|
+
options: Omit<SeamHttpOptionsWithClient, 'client'> = {},
|
|
51
|
+
): SeamHttpNoiseSensorsSimulate {
|
|
52
|
+
const constructorOptions = { ...options, client }
|
|
53
|
+
if (!isSeamHttpOptionsWithClient(constructorOptions)) {
|
|
54
|
+
throw new SeamHttpInvalidOptionsError('Missing client')
|
|
55
|
+
}
|
|
56
|
+
return new SeamHttpNoiseSensorsSimulate(constructorOptions)
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
static fromApiKey(
|
|
60
|
+
apiKey: SeamHttpOptionsWithApiKey['apiKey'],
|
|
61
|
+
options: Omit<SeamHttpOptionsWithApiKey, 'apiKey'> = {},
|
|
62
|
+
): SeamHttpNoiseSensorsSimulate {
|
|
63
|
+
const constructorOptions = { ...options, apiKey }
|
|
64
|
+
if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
|
|
65
|
+
throw new SeamHttpInvalidOptionsError('Missing apiKey')
|
|
66
|
+
}
|
|
67
|
+
return new SeamHttpNoiseSensorsSimulate(constructorOptions)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
static fromClientSessionToken(
|
|
71
|
+
clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
|
|
72
|
+
options: Omit<
|
|
73
|
+
SeamHttpOptionsWithClientSessionToken,
|
|
74
|
+
'clientSessionToken'
|
|
75
|
+
> = {},
|
|
76
|
+
): SeamHttpNoiseSensorsSimulate {
|
|
77
|
+
const constructorOptions = { ...options, clientSessionToken }
|
|
78
|
+
if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
|
|
79
|
+
throw new SeamHttpInvalidOptionsError('Missing clientSessionToken')
|
|
80
|
+
}
|
|
81
|
+
return new SeamHttpNoiseSensorsSimulate(constructorOptions)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
static async fromPublishableKey(
|
|
85
|
+
publishableKey: string,
|
|
86
|
+
userIdentifierKey: string,
|
|
87
|
+
options: SeamHttpFromPublishableKeyOptions = {},
|
|
88
|
+
): Promise<SeamHttpNoiseSensorsSimulate> {
|
|
89
|
+
warnOnInsecureuserIdentifierKey(userIdentifierKey)
|
|
90
|
+
const clientOptions = parseOptions({ ...options, publishableKey })
|
|
91
|
+
if (isSeamHttpOptionsWithClient(clientOptions)) {
|
|
92
|
+
throw new SeamHttpInvalidOptionsError(
|
|
93
|
+
'The client option cannot be used with SeamHttp.fromPublishableKey',
|
|
94
|
+
)
|
|
95
|
+
}
|
|
96
|
+
const client = createClient(clientOptions)
|
|
97
|
+
const clientSessions = SeamHttpClientSessions.fromClient(client)
|
|
98
|
+
const { token } = await clientSessions.getOrCreate({
|
|
99
|
+
user_identifier_key: userIdentifierKey,
|
|
100
|
+
})
|
|
101
|
+
return SeamHttpNoiseSensorsSimulate.fromClientSessionToken(token, options)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
static fromConsoleSessionToken(
|
|
105
|
+
consoleSessionToken: SeamHttpOptionsWithConsoleSessionToken['consoleSessionToken'],
|
|
106
|
+
workspaceId: SeamHttpOptionsWithConsoleSessionToken['workspaceId'],
|
|
107
|
+
options: Omit<
|
|
108
|
+
SeamHttpOptionsWithConsoleSessionToken,
|
|
109
|
+
'consoleSessionToken' | 'workspaceId'
|
|
110
|
+
> = {},
|
|
111
|
+
): SeamHttpNoiseSensorsSimulate {
|
|
112
|
+
const constructorOptions = { ...options, consoleSessionToken, workspaceId }
|
|
113
|
+
if (!isSeamHttpOptionsWithConsoleSessionToken(constructorOptions)) {
|
|
114
|
+
throw new SeamHttpInvalidOptionsError(
|
|
115
|
+
'Missing consoleSessionToken or workspaceId',
|
|
116
|
+
)
|
|
117
|
+
}
|
|
118
|
+
return new SeamHttpNoiseSensorsSimulate(constructorOptions)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
static fromPersonalAccessToken(
|
|
122
|
+
personalAccessToken: SeamHttpOptionsWithPersonalAccessToken['personalAccessToken'],
|
|
123
|
+
workspaceId: SeamHttpOptionsWithPersonalAccessToken['workspaceId'],
|
|
124
|
+
options: Omit<
|
|
125
|
+
SeamHttpOptionsWithPersonalAccessToken,
|
|
126
|
+
'personalAccessToken' | 'workspaceId'
|
|
127
|
+
> = {},
|
|
128
|
+
): SeamHttpNoiseSensorsSimulate {
|
|
129
|
+
const constructorOptions = { ...options, personalAccessToken, workspaceId }
|
|
130
|
+
if (!isSeamHttpOptionsWithPersonalAccessToken(constructorOptions)) {
|
|
131
|
+
throw new SeamHttpInvalidOptionsError(
|
|
132
|
+
'Missing personalAccessToken or workspaceId',
|
|
133
|
+
)
|
|
134
|
+
}
|
|
135
|
+
return new SeamHttpNoiseSensorsSimulate(constructorOptions)
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async updateClientSessionToken(
|
|
139
|
+
clientSessionToken: SeamHttpOptionsWithClientSessionToken['clientSessionToken'],
|
|
140
|
+
): Promise<void> {
|
|
141
|
+
const { headers } = this.client.defaults
|
|
142
|
+
const authHeaders = getAuthHeadersForClientSessionToken({
|
|
143
|
+
clientSessionToken,
|
|
144
|
+
})
|
|
145
|
+
for (const key of Object.keys(authHeaders)) {
|
|
146
|
+
if (headers[key] == null) {
|
|
147
|
+
throw new Error(
|
|
148
|
+
'Cannot update a clientSessionToken on a client created without a clientSessionToken',
|
|
149
|
+
)
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
this.client.defaults.headers = { ...headers, ...authHeaders }
|
|
153
|
+
const clientSessions = SeamHttpClientSessions.fromClient(this.client)
|
|
154
|
+
await clientSessions.get()
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
triggerNoiseThreshold(
|
|
158
|
+
body?: NoiseSensorsSimulateTriggerNoiseThresholdBody,
|
|
159
|
+
): SeamHttpRequest<void, undefined> {
|
|
160
|
+
return new SeamHttpRequest(this, {
|
|
161
|
+
path: '/noise_sensors/simulate/trigger_noise_threshold',
|
|
162
|
+
method: 'post',
|
|
163
|
+
body,
|
|
164
|
+
responseKey: undefined,
|
|
165
|
+
})
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export type NoiseSensorsSimulateTriggerNoiseThresholdBody =
|
|
170
|
+
RouteRequestBody<'/noise_sensors/simulate/trigger_noise_threshold'>
|
|
171
|
+
|
|
172
|
+
export type NoiseSensorsSimulateTriggerNoiseThresholdResponse = SetNonNullable<
|
|
173
|
+
Required<RouteResponse<'/noise_sensors/simulate/trigger_noise_threshold'>>
|
|
174
|
+
>
|
|
175
|
+
|
|
176
|
+
export type NoiseSensorsSimulateTriggerNoiseThresholdOptions = never
|
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
|
|
32
32
|
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
33
33
|
import { SeamHttpNoiseSensorsNoiseThresholds } from './noise-sensors-noise-thresholds.js'
|
|
34
|
+
import { SeamHttpNoiseSensorsSimulate } from './noise-sensors-simulate.js'
|
|
34
35
|
|
|
35
36
|
export class SeamHttpNoiseSensors {
|
|
36
37
|
client: Client
|
|
@@ -157,4 +158,8 @@ export class SeamHttpNoiseSensors {
|
|
|
157
158
|
this.defaults,
|
|
158
159
|
)
|
|
159
160
|
}
|
|
161
|
+
|
|
162
|
+
get simulate(): SeamHttpNoiseSensorsSimulate {
|
|
163
|
+
return SeamHttpNoiseSensorsSimulate.fromClient(this.client, this.defaults)
|
|
164
|
+
}
|
|
160
165
|
}
|
|
@@ -228,15 +228,12 @@ export class SeamHttpUserIdentities {
|
|
|
228
228
|
|
|
229
229
|
listAccessibleDevices(
|
|
230
230
|
body?: UserIdentitiesListAccessibleDevicesParams,
|
|
231
|
-
): SeamHttpRequest<
|
|
232
|
-
UserIdentitiesListAccessibleDevicesResponse,
|
|
233
|
-
'accessible_devices'
|
|
234
|
-
> {
|
|
231
|
+
): SeamHttpRequest<UserIdentitiesListAccessibleDevicesResponse, 'devices'> {
|
|
235
232
|
return new SeamHttpRequest(this, {
|
|
236
233
|
path: '/user_identities/list_accessible_devices',
|
|
237
234
|
method: 'post',
|
|
238
235
|
body,
|
|
239
|
-
responseKey: '
|
|
236
|
+
responseKey: 'devices',
|
|
240
237
|
})
|
|
241
238
|
}
|
|
242
239
|
|
|
@@ -189,12 +189,14 @@ export class SeamHttpWorkspaces {
|
|
|
189
189
|
|
|
190
190
|
resetSandbox(
|
|
191
191
|
body?: WorkspacesResetSandboxBody,
|
|
192
|
-
|
|
192
|
+
options: Pick<SeamHttpRequestOptions, 'waitForActionAttempt'> = {},
|
|
193
|
+
): SeamHttpRequest<WorkspacesResetSandboxResponse, 'action_attempt'> {
|
|
193
194
|
return new SeamHttpRequest(this, {
|
|
194
195
|
path: '/workspaces/reset_sandbox',
|
|
195
196
|
method: 'post',
|
|
196
197
|
body,
|
|
197
|
-
responseKey:
|
|
198
|
+
responseKey: 'action_attempt',
|
|
199
|
+
options,
|
|
198
200
|
})
|
|
199
201
|
}
|
|
200
202
|
}
|
|
@@ -230,4 +232,7 @@ export type WorkspacesResetSandboxResponse = SetNonNullable<
|
|
|
230
232
|
Required<RouteResponse<'/workspaces/reset_sandbox'>>
|
|
231
233
|
>
|
|
232
234
|
|
|
233
|
-
export type WorkspacesResetSandboxOptions =
|
|
235
|
+
export type WorkspacesResetSandboxOptions = Pick<
|
|
236
|
+
SeamHttpRequestOptions,
|
|
237
|
+
'waitForActionAttempt'
|
|
238
|
+
>
|
package/src/lib/version.ts
CHANGED