@seamapi/http 0.23.0 → 0.25.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/README.md +15 -0
- package/dist/connect.cjs +847 -727
- package/dist/connect.cjs.map +1 -1
- package/dist/connect.d.cts +167 -126
- package/lib/seam/connect/routes/access-codes-unmanaged.d.ts +6 -5
- package/lib/seam/connect/routes/access-codes-unmanaged.js +26 -22
- package/lib/seam/connect/routes/access-codes-unmanaged.js.map +1 -1
- package/lib/seam/connect/routes/access-codes.d.ts +9 -8
- package/lib/seam/connect/routes/access-codes.js +41 -38
- package/lib/seam/connect/routes/access-codes.js.map +1 -1
- package/lib/seam/connect/routes/acs-access-groups.d.ts +6 -5
- package/lib/seam/connect/routes/acs-access-groups.js +26 -23
- package/lib/seam/connect/routes/acs-access-groups.js.map +1 -1
- package/lib/seam/connect/routes/acs-credential-pools.d.ts +2 -1
- package/lib/seam/connect/routes/acs-credential-pools.js +6 -5
- package/lib/seam/connect/routes/acs-credential-pools.js.map +1 -1
- package/lib/seam/connect/routes/acs-credential-provisioning-automations.d.ts +2 -1
- package/lib/seam/connect/routes/acs-credential-provisioning-automations.js +6 -5
- package/lib/seam/connect/routes/acs-credential-provisioning-automations.js.map +1 -1
- package/lib/seam/connect/routes/acs-credentials.d.ts +8 -7
- package/lib/seam/connect/routes/acs-credentials.js +36 -34
- package/lib/seam/connect/routes/acs-credentials.js.map +1 -1
- package/lib/seam/connect/routes/acs-entrances.d.ts +5 -4
- package/lib/seam/connect/routes/acs-entrances.js +21 -19
- package/lib/seam/connect/routes/acs-entrances.js.map +1 -1
- package/lib/seam/connect/routes/acs-systems.d.ts +3 -2
- package/lib/seam/connect/routes/acs-systems.js +11 -10
- package/lib/seam/connect/routes/acs-systems.js.map +1 -1
- package/lib/seam/connect/routes/acs-users.d.ts +12 -11
- package/lib/seam/connect/routes/acs-users.js +56 -48
- package/lib/seam/connect/routes/acs-users.js.map +1 -1
- package/lib/seam/connect/routes/action-attempts.d.ts +3 -2
- package/lib/seam/connect/routes/action-attempts.js +12 -18
- package/lib/seam/connect/routes/action-attempts.js.map +1 -1
- package/lib/seam/connect/routes/client-sessions.d.ts +8 -7
- package/lib/seam/connect/routes/client-sessions.js +36 -33
- package/lib/seam/connect/routes/client-sessions.js.map +1 -1
- package/lib/seam/connect/routes/connect-webviews.d.ts +6 -5
- package/lib/seam/connect/routes/connect-webviews.js +25 -22
- package/lib/seam/connect/routes/connect-webviews.js.map +1 -1
- package/lib/seam/connect/routes/connected-accounts.d.ts +5 -4
- package/lib/seam/connect/routes/connected-accounts.js +21 -19
- package/lib/seam/connect/routes/connected-accounts.js.map +1 -1
- package/lib/seam/connect/routes/devices-simulate.d.ts +21 -0
- package/lib/seam/connect/routes/devices-simulate.js +88 -0
- package/lib/seam/connect/routes/devices-simulate.js.map +1 -0
- package/lib/seam/connect/routes/devices-unmanaged.d.ts +4 -3
- package/lib/seam/connect/routes/devices-unmanaged.js +16 -14
- package/lib/seam/connect/routes/devices-unmanaged.js.map +1 -1
- package/lib/seam/connect/routes/devices.d.ts +8 -5
- package/lib/seam/connect/routes/devices.js +30 -23
- package/lib/seam/connect/routes/devices.js.map +1 -1
- package/lib/seam/connect/routes/events.d.ts +3 -2
- package/lib/seam/connect/routes/events.js +11 -10
- package/lib/seam/connect/routes/events.js.map +1 -1
- package/lib/seam/connect/routes/index.d.ts +1 -0
- package/lib/seam/connect/routes/index.js +1 -0
- package/lib/seam/connect/routes/index.js.map +1 -1
- package/lib/seam/connect/routes/locks.d.ts +5 -4
- package/lib/seam/connect/routes/locks.js +23 -36
- package/lib/seam/connect/routes/locks.js.map +1 -1
- package/lib/seam/connect/routes/networks.d.ts +3 -2
- package/lib/seam/connect/routes/networks.js +11 -10
- package/lib/seam/connect/routes/networks.js.map +1 -1
- package/lib/seam/connect/routes/noise-sensors-noise-thresholds.d.ts +6 -5
- package/lib/seam/connect/routes/noise-sensors-noise-thresholds.js +26 -23
- package/lib/seam/connect/routes/noise-sensors-noise-thresholds.js.map +1 -1
- package/lib/seam/connect/routes/phones-simulate.d.ts +2 -1
- package/lib/seam/connect/routes/phones-simulate.js +6 -5
- package/lib/seam/connect/routes/phones-simulate.js.map +1 -1
- package/lib/seam/connect/routes/phones.d.ts +3 -2
- package/lib/seam/connect/routes/phones.js +11 -9
- package/lib/seam/connect/routes/phones.js.map +1 -1
- package/lib/seam/connect/routes/thermostats-climate-setting-schedules.d.ts +6 -5
- package/lib/seam/connect/routes/thermostats-climate-setting-schedules.js +26 -23
- package/lib/seam/connect/routes/thermostats-climate-setting-schedules.js.map +1 -1
- package/lib/seam/connect/routes/thermostats.d.ts +9 -8
- package/lib/seam/connect/routes/thermostats.js +46 -76
- package/lib/seam/connect/routes/thermostats.js.map +1 -1
- package/lib/seam/connect/routes/user-identities-enrollment-automations.d.ts +5 -4
- package/lib/seam/connect/routes/user-identities-enrollment-automations.js +21 -19
- package/lib/seam/connect/routes/user-identities-enrollment-automations.js.map +1 -1
- package/lib/seam/connect/routes/user-identities.d.ts +13 -12
- package/lib/seam/connect/routes/user-identities.js +61 -54
- package/lib/seam/connect/routes/user-identities.js.map +1 -1
- package/lib/seam/connect/routes/webhooks.d.ts +6 -5
- package/lib/seam/connect/routes/webhooks.js +26 -23
- package/lib/seam/connect/routes/webhooks.js.map +1 -1
- package/lib/seam/connect/routes/workspaces.d.ts +5 -4
- package/lib/seam/connect/routes/workspaces.js +21 -19
- package/lib/seam/connect/routes/workspaces.js.map +1 -1
- package/lib/seam/connect/seam-http-request.d.ts +26 -0
- package/lib/seam/connect/seam-http-request.js +87 -0
- package/lib/seam/connect/seam-http-request.js.map +1 -0
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +4 -4
- package/src/lib/seam/connect/routes/access-codes-unmanaged.ts +37 -34
- package/src/lib/seam/connect/routes/access-codes.ts +56 -60
- package/src/lib/seam/connect/routes/acs-access-groups.ts +33 -32
- package/src/lib/seam/connect/routes/acs-credential-pools.ts +7 -7
- package/src/lib/seam/connect/routes/acs-credential-provisioning-automations.ts +11 -13
- package/src/lib/seam/connect/routes/acs-credentials.ts +42 -46
- package/src/lib/seam/connect/routes/acs-entrances.ts +31 -28
- package/src/lib/seam/connect/routes/acs-systems.ts +13 -14
- package/src/lib/seam/connect/routes/acs-users.ts +66 -61
- package/src/lib/seam/connect/routes/action-attempts.ts +14 -26
- package/src/lib/seam/connect/routes/client-sessions.ts +45 -49
- package/src/lib/seam/connect/routes/connect-webviews.ts +28 -28
- package/src/lib/seam/connect/routes/connected-accounts.ts +26 -29
- package/src/lib/seam/connect/routes/devices-simulate.ts +174 -0
- package/src/lib/seam/connect/routes/devices-unmanaged.ts +18 -18
- package/src/lib/seam/connect/routes/devices.ts +35 -31
- package/src/lib/seam/connect/routes/events.ts +11 -12
- package/src/lib/seam/connect/routes/index.ts +1 -0
- package/src/lib/seam/connect/routes/locks.ts +25 -50
- package/src/lib/seam/connect/routes/networks.ts +14 -13
- package/src/lib/seam/connect/routes/noise-sensors-noise-thresholds.ts +48 -38
- package/src/lib/seam/connect/routes/phones-simulate.ts +9 -10
- package/src/lib/seam/connect/routes/phones.ts +11 -10
- package/src/lib/seam/connect/routes/thermostats-climate-setting-schedules.ts +47 -55
- package/src/lib/seam/connect/routes/thermostats.ts +53 -110
- package/src/lib/seam/connect/routes/user-identities-enrollment-automations.ts +39 -48
- package/src/lib/seam/connect/routes/user-identities.ts +81 -78
- package/src/lib/seam/connect/routes/webhooks.ts +30 -28
- package/src/lib/seam/connect/routes/workspaces.ts +26 -25
- package/src/lib/seam/connect/seam-http-request.ts +144 -0
- package/src/lib/version.ts +1 -1
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
limitToSeamHttpRequestOptions,
|
|
32
32
|
parseOptions,
|
|
33
33
|
} from 'lib/seam/connect/parse-options.js'
|
|
34
|
+
import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js'
|
|
34
35
|
|
|
35
36
|
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
36
37
|
|
|
@@ -156,67 +157,57 @@ export class SeamHttpUserIdentitiesEnrollmentAutomations {
|
|
|
156
157
|
await clientSessions.get()
|
|
157
158
|
}
|
|
158
159
|
|
|
159
|
-
|
|
160
|
+
delete(
|
|
160
161
|
body?: UserIdentitiesEnrollmentAutomationsDeleteBody,
|
|
161
|
-
):
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
)
|
|
162
|
+
): SeamHttpRequest<void, undefined> {
|
|
163
|
+
return new SeamHttpRequest(this, {
|
|
164
|
+
path: '/user_identities/enrollment_automations/delete',
|
|
165
|
+
method: 'post',
|
|
166
|
+
body,
|
|
167
|
+
responseKey: undefined,
|
|
168
|
+
})
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
-
|
|
171
|
+
get(
|
|
172
172
|
body?: UserIdentitiesEnrollmentAutomationsGetParams,
|
|
173
|
-
):
|
|
174
|
-
UserIdentitiesEnrollmentAutomationsGetResponse
|
|
173
|
+
): SeamHttpRequest<
|
|
174
|
+
UserIdentitiesEnrollmentAutomationsGetResponse,
|
|
175
|
+
'enrollment_automation'
|
|
175
176
|
> {
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
},
|
|
183
|
-
)
|
|
184
|
-
|
|
185
|
-
return data.enrollment_automation
|
|
177
|
+
return new SeamHttpRequest(this, {
|
|
178
|
+
path: '/user_identities/enrollment_automations/get',
|
|
179
|
+
method: 'post',
|
|
180
|
+
body,
|
|
181
|
+
responseKey: 'enrollment_automation',
|
|
182
|
+
})
|
|
186
183
|
}
|
|
187
184
|
|
|
188
|
-
|
|
185
|
+
launch(
|
|
189
186
|
body?: UserIdentitiesEnrollmentAutomationsLaunchBody,
|
|
190
|
-
):
|
|
191
|
-
UserIdentitiesEnrollmentAutomationsLaunchResponse
|
|
187
|
+
): SeamHttpRequest<
|
|
188
|
+
UserIdentitiesEnrollmentAutomationsLaunchResponse,
|
|
189
|
+
'enrollment_automation'
|
|
192
190
|
> {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
},
|
|
200
|
-
)
|
|
201
|
-
|
|
202
|
-
return data.enrollment_automation
|
|
191
|
+
return new SeamHttpRequest(this, {
|
|
192
|
+
path: '/user_identities/enrollment_automations/launch',
|
|
193
|
+
method: 'post',
|
|
194
|
+
body,
|
|
195
|
+
responseKey: 'enrollment_automation',
|
|
196
|
+
})
|
|
203
197
|
}
|
|
204
198
|
|
|
205
|
-
|
|
199
|
+
list(
|
|
206
200
|
body?: UserIdentitiesEnrollmentAutomationsListParams,
|
|
207
|
-
):
|
|
208
|
-
UserIdentitiesEnrollmentAutomationsListResponse
|
|
201
|
+
): SeamHttpRequest<
|
|
202
|
+
UserIdentitiesEnrollmentAutomationsListResponse,
|
|
203
|
+
'enrollment_automations'
|
|
209
204
|
> {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
},
|
|
217
|
-
)
|
|
218
|
-
|
|
219
|
-
return data.enrollment_automations
|
|
205
|
+
return new SeamHttpRequest(this, {
|
|
206
|
+
path: '/user_identities/enrollment_automations/list',
|
|
207
|
+
method: 'post',
|
|
208
|
+
body,
|
|
209
|
+
responseKey: 'enrollment_automations',
|
|
210
|
+
})
|
|
220
211
|
}
|
|
221
212
|
}
|
|
222
213
|
|
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
limitToSeamHttpRequestOptions,
|
|
32
32
|
parseOptions,
|
|
33
33
|
} from 'lib/seam/connect/parse-options.js'
|
|
34
|
+
import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js'
|
|
34
35
|
|
|
35
36
|
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
36
37
|
import { SeamHttpUserIdentitiesEnrollmentAutomations } from './user-identities-enrollment-automations.js'
|
|
@@ -161,132 +162,134 @@ export class SeamHttpUserIdentities {
|
|
|
161
162
|
)
|
|
162
163
|
}
|
|
163
164
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
165
|
+
addAcsUser(
|
|
166
|
+
body?: UserIdentitiesAddAcsUserBody,
|
|
167
|
+
): SeamHttpRequest<void, undefined> {
|
|
168
|
+
return new SeamHttpRequest(this, {
|
|
169
|
+
path: '/user_identities/add_acs_user',
|
|
167
170
|
method: 'post',
|
|
168
|
-
|
|
171
|
+
body,
|
|
172
|
+
responseKey: undefined,
|
|
169
173
|
})
|
|
170
174
|
}
|
|
171
175
|
|
|
172
|
-
|
|
176
|
+
create(
|
|
173
177
|
body?: UserIdentitiesCreateBody,
|
|
174
|
-
):
|
|
175
|
-
|
|
176
|
-
|
|
178
|
+
): SeamHttpRequest<UserIdentitiesCreateResponse, 'user_identity'> {
|
|
179
|
+
return new SeamHttpRequest(this, {
|
|
180
|
+
path: '/user_identities/create',
|
|
177
181
|
method: 'post',
|
|
178
|
-
|
|
182
|
+
body,
|
|
183
|
+
responseKey: 'user_identity',
|
|
179
184
|
})
|
|
180
|
-
|
|
181
|
-
return data.user_identity
|
|
182
185
|
}
|
|
183
186
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
+
delete(body?: UserIdentitiesDeleteBody): SeamHttpRequest<void, undefined> {
|
|
188
|
+
return new SeamHttpRequest(this, {
|
|
189
|
+
path: '/user_identities/delete',
|
|
187
190
|
method: 'post',
|
|
188
|
-
|
|
191
|
+
body,
|
|
192
|
+
responseKey: undefined,
|
|
189
193
|
})
|
|
190
194
|
}
|
|
191
195
|
|
|
192
|
-
|
|
196
|
+
get(
|
|
193
197
|
body?: UserIdentitiesGetParams,
|
|
194
|
-
):
|
|
195
|
-
|
|
196
|
-
|
|
198
|
+
): SeamHttpRequest<UserIdentitiesGetResponse, 'user_identity'> {
|
|
199
|
+
return new SeamHttpRequest(this, {
|
|
200
|
+
path: '/user_identities/get',
|
|
197
201
|
method: 'post',
|
|
198
|
-
|
|
202
|
+
body,
|
|
203
|
+
responseKey: 'user_identity',
|
|
199
204
|
})
|
|
200
|
-
|
|
201
|
-
return data.user_identity
|
|
202
205
|
}
|
|
203
206
|
|
|
204
|
-
|
|
207
|
+
grantAccessToDevice(
|
|
205
208
|
body?: UserIdentitiesGrantAccessToDeviceBody,
|
|
206
|
-
):
|
|
207
|
-
|
|
208
|
-
|
|
209
|
+
): SeamHttpRequest<void, undefined> {
|
|
210
|
+
return new SeamHttpRequest(this, {
|
|
211
|
+
path: '/user_identities/grant_access_to_device',
|
|
209
212
|
method: 'post',
|
|
210
|
-
|
|
213
|
+
body,
|
|
214
|
+
responseKey: undefined,
|
|
211
215
|
})
|
|
212
216
|
}
|
|
213
217
|
|
|
214
|
-
|
|
218
|
+
list(
|
|
215
219
|
body?: UserIdentitiesListParams,
|
|
216
|
-
):
|
|
217
|
-
|
|
218
|
-
|
|
220
|
+
): SeamHttpRequest<UserIdentitiesListResponse, 'user_identities'> {
|
|
221
|
+
return new SeamHttpRequest(this, {
|
|
222
|
+
path: '/user_identities/list',
|
|
219
223
|
method: 'post',
|
|
220
|
-
|
|
224
|
+
body,
|
|
225
|
+
responseKey: 'user_identities',
|
|
221
226
|
})
|
|
222
|
-
|
|
223
|
-
return data.user_identities
|
|
224
227
|
}
|
|
225
228
|
|
|
226
|
-
|
|
229
|
+
listAccessibleDevices(
|
|
227
230
|
body?: UserIdentitiesListAccessibleDevicesParams,
|
|
228
|
-
):
|
|
229
|
-
UserIdentitiesListAccessibleDevicesResponse
|
|
231
|
+
): SeamHttpRequest<
|
|
232
|
+
UserIdentitiesListAccessibleDevicesResponse,
|
|
233
|
+
'accessible_devices'
|
|
230
234
|
> {
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
return data.accessible_devices
|
|
235
|
+
return new SeamHttpRequest(this, {
|
|
236
|
+
path: '/user_identities/list_accessible_devices',
|
|
237
|
+
method: 'post',
|
|
238
|
+
body,
|
|
239
|
+
responseKey: 'accessible_devices',
|
|
240
|
+
})
|
|
239
241
|
}
|
|
240
242
|
|
|
241
|
-
|
|
243
|
+
listAcsSystems(
|
|
242
244
|
body?: UserIdentitiesListAcsSystemsParams,
|
|
243
|
-
):
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
return data.acs_systems
|
|
245
|
+
): SeamHttpRequest<UserIdentitiesListAcsSystemsResponse, 'acs_systems'> {
|
|
246
|
+
return new SeamHttpRequest(this, {
|
|
247
|
+
path: '/user_identities/list_acs_systems',
|
|
248
|
+
method: 'post',
|
|
249
|
+
body,
|
|
250
|
+
responseKey: 'acs_systems',
|
|
251
|
+
})
|
|
252
252
|
}
|
|
253
253
|
|
|
254
|
-
|
|
254
|
+
listAcsUsers(
|
|
255
255
|
body?: UserIdentitiesListAcsUsersParams,
|
|
256
|
-
):
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
return data.acs_users
|
|
256
|
+
): SeamHttpRequest<UserIdentitiesListAcsUsersResponse, 'acs_users'> {
|
|
257
|
+
return new SeamHttpRequest(this, {
|
|
258
|
+
path: '/user_identities/list_acs_users',
|
|
259
|
+
method: 'post',
|
|
260
|
+
body,
|
|
261
|
+
responseKey: 'acs_users',
|
|
262
|
+
})
|
|
265
263
|
}
|
|
266
264
|
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
265
|
+
removeAcsUser(
|
|
266
|
+
body?: UserIdentitiesRemoveAcsUserBody,
|
|
267
|
+
): SeamHttpRequest<void, undefined> {
|
|
268
|
+
return new SeamHttpRequest(this, {
|
|
269
|
+
path: '/user_identities/remove_acs_user',
|
|
270
270
|
method: 'post',
|
|
271
|
-
|
|
271
|
+
body,
|
|
272
|
+
responseKey: undefined,
|
|
272
273
|
})
|
|
273
274
|
}
|
|
274
275
|
|
|
275
|
-
|
|
276
|
+
revokeAccessToDevice(
|
|
276
277
|
body?: UserIdentitiesRevokeAccessToDeviceBody,
|
|
277
|
-
):
|
|
278
|
-
|
|
279
|
-
|
|
278
|
+
): SeamHttpRequest<void, undefined> {
|
|
279
|
+
return new SeamHttpRequest(this, {
|
|
280
|
+
path: '/user_identities/revoke_access_to_device',
|
|
280
281
|
method: 'post',
|
|
281
|
-
|
|
282
|
+
body,
|
|
283
|
+
responseKey: undefined,
|
|
282
284
|
})
|
|
283
285
|
}
|
|
284
286
|
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
287
|
+
update(body?: UserIdentitiesUpdateBody): SeamHttpRequest<void, undefined> {
|
|
288
|
+
return new SeamHttpRequest(this, {
|
|
289
|
+
path: '/user_identities/update',
|
|
288
290
|
method: 'post',
|
|
289
|
-
|
|
291
|
+
body,
|
|
292
|
+
responseKey: undefined,
|
|
290
293
|
})
|
|
291
294
|
}
|
|
292
295
|
}
|
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
limitToSeamHttpRequestOptions,
|
|
32
32
|
parseOptions,
|
|
33
33
|
} from 'lib/seam/connect/parse-options.js'
|
|
34
|
+
import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js'
|
|
34
35
|
|
|
35
36
|
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
36
37
|
|
|
@@ -153,53 +154,54 @@ export class SeamHttpWebhooks {
|
|
|
153
154
|
await clientSessions.get()
|
|
154
155
|
}
|
|
155
156
|
|
|
156
|
-
|
|
157
|
+
create(
|
|
157
158
|
body?: WebhooksCreateBody,
|
|
158
|
-
):
|
|
159
|
-
|
|
160
|
-
|
|
159
|
+
): SeamHttpRequest<WebhooksCreateResponse, 'webhook'> {
|
|
160
|
+
return new SeamHttpRequest(this, {
|
|
161
|
+
path: '/webhooks/create',
|
|
161
162
|
method: 'post',
|
|
162
|
-
|
|
163
|
+
body,
|
|
164
|
+
responseKey: 'webhook',
|
|
163
165
|
})
|
|
164
|
-
|
|
165
|
-
return data.webhook
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
168
|
+
delete(body?: WebhooksDeleteBody): SeamHttpRequest<void, undefined> {
|
|
169
|
+
return new SeamHttpRequest(this, {
|
|
170
|
+
path: '/webhooks/delete',
|
|
171
171
|
method: 'post',
|
|
172
|
-
|
|
172
|
+
body,
|
|
173
|
+
responseKey: undefined,
|
|
173
174
|
})
|
|
174
175
|
}
|
|
175
176
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
177
|
+
get(
|
|
178
|
+
body?: WebhooksGetParams,
|
|
179
|
+
): SeamHttpRequest<WebhooksGetResponse, 'webhook'> {
|
|
180
|
+
return new SeamHttpRequest(this, {
|
|
181
|
+
path: '/webhooks/get',
|
|
179
182
|
method: 'post',
|
|
180
|
-
|
|
183
|
+
body,
|
|
184
|
+
responseKey: 'webhook',
|
|
181
185
|
})
|
|
182
|
-
|
|
183
|
-
return data.webhook
|
|
184
186
|
}
|
|
185
187
|
|
|
186
|
-
|
|
188
|
+
list(
|
|
187
189
|
body?: WebhooksListParams,
|
|
188
|
-
):
|
|
189
|
-
|
|
190
|
-
|
|
190
|
+
): SeamHttpRequest<WebhooksListResponse, 'webhooks'> {
|
|
191
|
+
return new SeamHttpRequest(this, {
|
|
192
|
+
path: '/webhooks/list',
|
|
191
193
|
method: 'post',
|
|
192
|
-
|
|
194
|
+
body,
|
|
195
|
+
responseKey: 'webhooks',
|
|
193
196
|
})
|
|
194
|
-
|
|
195
|
-
return data.webhooks
|
|
196
197
|
}
|
|
197
198
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
199
|
+
update(body?: WebhooksUpdateBody): SeamHttpRequest<void, undefined> {
|
|
200
|
+
return new SeamHttpRequest(this, {
|
|
201
|
+
path: '/webhooks/update',
|
|
201
202
|
method: 'post',
|
|
202
|
-
|
|
203
|
+
body,
|
|
204
|
+
responseKey: undefined,
|
|
203
205
|
})
|
|
204
206
|
}
|
|
205
207
|
}
|
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
limitToSeamHttpRequestOptions,
|
|
32
32
|
parseOptions,
|
|
33
33
|
} from 'lib/seam/connect/parse-options.js'
|
|
34
|
+
import { SeamHttpRequest } from 'lib/seam/connect/seam-http-request.js'
|
|
34
35
|
|
|
35
36
|
import { SeamHttpClientSessions } from './client-sessions.js'
|
|
36
37
|
|
|
@@ -153,47 +154,47 @@ export class SeamHttpWorkspaces {
|
|
|
153
154
|
await clientSessions.get()
|
|
154
155
|
}
|
|
155
156
|
|
|
156
|
-
|
|
157
|
+
create(
|
|
157
158
|
body?: WorkspacesCreateBody,
|
|
158
|
-
):
|
|
159
|
-
|
|
160
|
-
|
|
159
|
+
): SeamHttpRequest<WorkspacesCreateResponse, 'workspace'> {
|
|
160
|
+
return new SeamHttpRequest(this, {
|
|
161
|
+
path: '/workspaces/create',
|
|
161
162
|
method: 'post',
|
|
162
|
-
|
|
163
|
+
body,
|
|
164
|
+
responseKey: 'workspace',
|
|
163
165
|
})
|
|
164
|
-
|
|
165
|
-
return data.workspace
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
-
|
|
168
|
+
get(
|
|
169
169
|
body?: WorkspacesGetParams,
|
|
170
|
-
):
|
|
171
|
-
|
|
172
|
-
|
|
170
|
+
): SeamHttpRequest<WorkspacesGetResponse, 'workspace'> {
|
|
171
|
+
return new SeamHttpRequest(this, {
|
|
172
|
+
path: '/workspaces/get',
|
|
173
173
|
method: 'post',
|
|
174
|
-
|
|
174
|
+
body,
|
|
175
|
+
responseKey: 'workspace',
|
|
175
176
|
})
|
|
176
|
-
|
|
177
|
-
return data.workspace
|
|
178
177
|
}
|
|
179
178
|
|
|
180
|
-
|
|
179
|
+
list(
|
|
181
180
|
body?: WorkspacesListParams,
|
|
182
|
-
):
|
|
183
|
-
|
|
184
|
-
|
|
181
|
+
): SeamHttpRequest<WorkspacesListResponse, 'workspaces'> {
|
|
182
|
+
return new SeamHttpRequest(this, {
|
|
183
|
+
path: '/workspaces/list',
|
|
185
184
|
method: 'post',
|
|
186
|
-
|
|
185
|
+
body,
|
|
186
|
+
responseKey: 'workspaces',
|
|
187
187
|
})
|
|
188
|
-
|
|
189
|
-
return data.workspaces
|
|
190
188
|
}
|
|
191
189
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
190
|
+
resetSandbox(
|
|
191
|
+
body?: WorkspacesResetSandboxBody,
|
|
192
|
+
): SeamHttpRequest<void, undefined> {
|
|
193
|
+
return new SeamHttpRequest(this, {
|
|
194
|
+
path: '/workspaces/reset_sandbox',
|
|
195
195
|
method: 'post',
|
|
196
|
-
|
|
196
|
+
body,
|
|
197
|
+
responseKey: undefined,
|
|
197
198
|
})
|
|
198
199
|
}
|
|
199
200
|
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { serializeUrlSearchParams } from '@seamapi/url-search-params-serializer'
|
|
2
|
+
import type { Method } from 'axios'
|
|
3
|
+
|
|
4
|
+
import type { Client } from './client.js'
|
|
5
|
+
import type { SeamHttpRequestOptions } from './options.js'
|
|
6
|
+
import { resolveActionAttempt } from './resolve-action-attempt.js'
|
|
7
|
+
import { SeamHttpActionAttempts } from './routes/index.js'
|
|
8
|
+
|
|
9
|
+
interface SeamHttpRequestParent {
|
|
10
|
+
readonly client: Client
|
|
11
|
+
readonly defaults: Required<SeamHttpRequestOptions>
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface SeamHttpRequestConfig<TResponseKey> {
|
|
15
|
+
readonly path: string
|
|
16
|
+
readonly method: Method
|
|
17
|
+
readonly body?: unknown
|
|
18
|
+
readonly params?: undefined | Record<string, unknown>
|
|
19
|
+
readonly responseKey: TResponseKey
|
|
20
|
+
readonly options?: Pick<SeamHttpRequestOptions, 'waitForActionAttempt'>
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export class SeamHttpRequest<
|
|
24
|
+
const TResponse,
|
|
25
|
+
const TResponseKey extends keyof TResponse | undefined,
|
|
26
|
+
> implements
|
|
27
|
+
PromiseLike<
|
|
28
|
+
TResponseKey extends keyof TResponse ? TResponse[TResponseKey] : undefined
|
|
29
|
+
>
|
|
30
|
+
{
|
|
31
|
+
readonly #parent: SeamHttpRequestParent
|
|
32
|
+
readonly #config: SeamHttpRequestConfig<TResponseKey>
|
|
33
|
+
|
|
34
|
+
constructor(
|
|
35
|
+
parent: SeamHttpRequestParent,
|
|
36
|
+
config: SeamHttpRequestConfig<TResponseKey>,
|
|
37
|
+
) {
|
|
38
|
+
this.#parent = parent
|
|
39
|
+
this.#config = config
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public get responseKey(): TResponseKey {
|
|
43
|
+
return this.#config.responseKey
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
public get url(): URL {
|
|
47
|
+
const { client } = this.#parent
|
|
48
|
+
const { params } = this.#config
|
|
49
|
+
|
|
50
|
+
const serializer =
|
|
51
|
+
typeof client.defaults.paramsSerializer === 'function'
|
|
52
|
+
? client.defaults.paramsSerializer
|
|
53
|
+
: serializeUrlSearchParams
|
|
54
|
+
|
|
55
|
+
const origin = getUrlPrefix(client.defaults.baseURL ?? '')
|
|
56
|
+
|
|
57
|
+
const pathname = this.#config.path.startsWith('/')
|
|
58
|
+
? this.#config.path
|
|
59
|
+
: `/${this.#config.path}`
|
|
60
|
+
|
|
61
|
+
const path = params == null ? pathname : `${pathname}?${serializer(params)}`
|
|
62
|
+
|
|
63
|
+
return new URL(`${origin}${path}`)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public get method(): Method {
|
|
67
|
+
return this.#config.method
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
public get body(): unknown {
|
|
71
|
+
return this.#config.body
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async execute(): Promise<
|
|
75
|
+
TResponseKey extends keyof TResponse ? TResponse[TResponseKey] : undefined
|
|
76
|
+
> {
|
|
77
|
+
const { client } = this.#parent
|
|
78
|
+
const response = await client.request({
|
|
79
|
+
url: this.#config.path,
|
|
80
|
+
method: this.#config.method,
|
|
81
|
+
data: this.#config.body,
|
|
82
|
+
params: this.#config.params,
|
|
83
|
+
})
|
|
84
|
+
if (this.responseKey === undefined) {
|
|
85
|
+
return undefined as TResponseKey extends keyof TResponse
|
|
86
|
+
? TResponse[TResponseKey]
|
|
87
|
+
: undefined
|
|
88
|
+
}
|
|
89
|
+
const data = response.data[this.responseKey]
|
|
90
|
+
if (this.responseKey === 'action_attempt') {
|
|
91
|
+
const waitForActionAttempt =
|
|
92
|
+
this.#config.options?.waitForActionAttempt ??
|
|
93
|
+
this.#parent.defaults.waitForActionAttempt
|
|
94
|
+
if (waitForActionAttempt !== false) {
|
|
95
|
+
return await resolveActionAttempt(
|
|
96
|
+
data,
|
|
97
|
+
SeamHttpActionAttempts.fromClient(client, {
|
|
98
|
+
...this.#parent.defaults,
|
|
99
|
+
waitForActionAttempt: false,
|
|
100
|
+
}),
|
|
101
|
+
typeof waitForActionAttempt === 'boolean' ? {} : waitForActionAttempt,
|
|
102
|
+
)
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return data
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
then<
|
|
109
|
+
TResult1 = TResponseKey extends keyof TResponse
|
|
110
|
+
? TResponse[TResponseKey]
|
|
111
|
+
: undefined,
|
|
112
|
+
TResult2 = never,
|
|
113
|
+
>(
|
|
114
|
+
onfulfilled?:
|
|
115
|
+
| ((
|
|
116
|
+
value: TResponseKey extends keyof TResponse
|
|
117
|
+
? TResponse[TResponseKey]
|
|
118
|
+
: undefined,
|
|
119
|
+
) => TResult1 | PromiseLike<TResult1>)
|
|
120
|
+
| null
|
|
121
|
+
| undefined,
|
|
122
|
+
onrejected?:
|
|
123
|
+
| ((reason: any) => TResult2 | PromiseLike<TResult2>)
|
|
124
|
+
| null
|
|
125
|
+
| undefined,
|
|
126
|
+
): PromiseLike<TResult1 | TResult2> {
|
|
127
|
+
return this.execute().then(onfulfilled, onrejected)
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const getUrlPrefix = (input: string): string => {
|
|
132
|
+
if (URL.canParse(input)) {
|
|
133
|
+
const url = new URL(input).toString()
|
|
134
|
+
if (url.endsWith('/')) return url.slice(0, -1)
|
|
135
|
+
return url
|
|
136
|
+
}
|
|
137
|
+
if (globalThis.location != null) {
|
|
138
|
+
const pathname = input.startsWith('/') ? input : `/${input}`
|
|
139
|
+
return new URL(`${globalThis.location.origin}${pathname}`).toString()
|
|
140
|
+
}
|
|
141
|
+
throw new Error(
|
|
142
|
+
`Cannot resolve origin from ${input} in a non-browser environment`,
|
|
143
|
+
)
|
|
144
|
+
}
|
package/src/lib/version.ts
CHANGED