diff --git a/docs/classes/Seam.md b/docs/classes/Seam.md index c98ed424..a3e44003 100644 --- a/docs/classes/Seam.md +++ b/docs/classes/Seam.md @@ -19,6 +19,7 @@ - [accessCodes](Seam.md#accesscodes) - [actionAttempts](Seam.md#actionattempts) - [client](Seam.md#client) +- [clientSessions](Seam.md#clientsessions) - [connectWebviews](Seam.md#connectwebviews) - [connectedAccounts](Seam.md#connectedaccounts) - [deviceModels](Seam.md#devicemodels) @@ -83,7 +84,7 @@ Routes.accessCodes #### Defined in -[src/seam-connect/routes.ts:282](https://github.com/seamapi/javascript/blob/main/src/seam-connect/routes.ts#L282) +[src/seam-connect/routes.ts:285](https://github.com/seamapi/javascript/blob/main/src/seam-connect/routes.ts#L285) ___ @@ -103,7 +104,7 @@ Routes.actionAttempts #### Defined in -[src/seam-connect/routes.ts:404](https://github.com/seamapi/javascript/blob/main/src/seam-connect/routes.ts#L404) +[src/seam-connect/routes.ts:407](https://github.com/seamapi/javascript/blob/main/src/seam-connect/routes.ts#L407) ___ @@ -117,6 +118,27 @@ ___ ___ +### clientSessions + +• `Readonly` **clientSessions**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `create` | (`params`: [`ClientSessionsCreateRequest`](../modules.md#clientsessionscreaterequest)) => `Promise`<[`ClientSession`](../interfaces/ClientSession.md)\> | +| `getOrCreate` | (`params`: [`ClientSessionsCreateRequest`](../modules.md#clientsessionscreaterequest)) => `Promise`<[`ClientSession`](../interfaces/ClientSession.md)\> | + +#### Inherited from + +Routes.clientSessions + +#### Defined in + +[src/seam-connect/routes.ts:473](https://github.com/seamapi/javascript/blob/main/src/seam-connect/routes.ts#L473) + +___ + ### connectWebviews • `Readonly` **connectWebviews**: `Object` @@ -136,7 +158,7 @@ Routes.connectWebviews #### Defined in -[src/seam-connect/routes.ts:250](https://github.com/seamapi/javascript/blob/main/src/seam-connect/routes.ts#L250) +[src/seam-connect/routes.ts:253](https://github.com/seamapi/javascript/blob/main/src/seam-connect/routes.ts#L253) ___ @@ -158,7 +180,7 @@ Routes.connectedAccounts #### Defined in -[src/seam-connect/routes.ts:379](https://github.com/seamapi/javascript/blob/main/src/seam-connect/routes.ts#L379) +[src/seam-connect/routes.ts:382](https://github.com/seamapi/javascript/blob/main/src/seam-connect/routes.ts#L382) ___ @@ -178,7 +200,7 @@ Routes.deviceModels #### Defined in -[src/seam-connect/routes.ts:470](https://github.com/seamapi/javascript/blob/main/src/seam-connect/routes.ts#L470) +[src/seam-connect/routes.ts:487](https://github.com/seamapi/javascript/blob/main/src/seam-connect/routes.ts#L487) ___ @@ -205,7 +227,7 @@ Routes.devices #### Defined in -[src/seam-connect/routes.ts:191](https://github.com/seamapi/javascript/blob/main/src/seam-connect/routes.ts#L191) +[src/seam-connect/routes.ts:194](https://github.com/seamapi/javascript/blob/main/src/seam-connect/routes.ts#L194) ___ @@ -225,7 +247,7 @@ Routes.events #### Defined in -[src/seam-connect/routes.ts:238](https://github.com/seamapi/javascript/blob/main/src/seam-connect/routes.ts#L238) +[src/seam-connect/routes.ts:241](https://github.com/seamapi/javascript/blob/main/src/seam-connect/routes.ts#L241) ___ @@ -248,7 +270,7 @@ Routes.locks #### Defined in -[src/seam-connect/routes.ts:156](https://github.com/seamapi/javascript/blob/main/src/seam-connect/routes.ts#L156) +[src/seam-connect/routes.ts:159](https://github.com/seamapi/javascript/blob/main/src/seam-connect/routes.ts#L159) ___ @@ -271,7 +293,7 @@ Routes.noiseThresholds #### Defined in -[src/seam-connect/routes.ts:414](https://github.com/seamapi/javascript/blob/main/src/seam-connect/routes.ts#L414) +[src/seam-connect/routes.ts:417](https://github.com/seamapi/javascript/blob/main/src/seam-connect/routes.ts#L417) ___ @@ -294,7 +316,7 @@ Routes.webhooks #### Defined in -[src/seam-connect/routes.ts:445](https://github.com/seamapi/javascript/blob/main/src/seam-connect/routes.ts#L445) +[src/seam-connect/routes.ts:448](https://github.com/seamapi/javascript/blob/main/src/seam-connect/routes.ts#L448) ___ @@ -316,7 +338,7 @@ Routes.workspaces #### Defined in -[src/seam-connect/routes.ts:140](https://github.com/seamapi/javascript/blob/main/src/seam-connect/routes.ts#L140) +[src/seam-connect/routes.ts:143](https://github.com/seamapi/javascript/blob/main/src/seam-connect/routes.ts#L143) ## Methods @@ -352,7 +374,7 @@ ___ ### getClientSessionToken -▸ `Static` **getClientSessionToken**(`options`): `Promise`<[`APIResponse`](../modules.md#apiresponse)<[`ClientSessionResponse`](../interfaces/ClientSessionResponse.md)\>\> +▸ `Static` **getClientSessionToken**(`options`): `Promise`<[`APIResponse`](../modules.md#apiresponse)<[`ClientSessionsResponse`](../modules.md#clientsessionsresponse)\>\> #### Parameters @@ -367,7 +389,7 @@ ___ #### Returns -`Promise`<[`APIResponse`](../modules.md#apiresponse)<[`ClientSessionResponse`](../interfaces/ClientSessionResponse.md)\>\> +`Promise`<[`APIResponse`](../modules.md#apiresponse)<[`ClientSessionsResponse`](../modules.md#clientsessionsresponse)\>\> #### Defined in diff --git a/docs/interfaces/ClientSession.md b/docs/interfaces/ClientSession.md index 04bcd297..1f5168b2 100644 --- a/docs/interfaces/ClientSession.md +++ b/docs/interfaces/ClientSession.md @@ -6,36 +6,36 @@ ### Properties +- [client\_session\_id](ClientSession.md#client_session_id) - [created\_at](ClientSession.md#created_at) - [token](ClientSession.md#token) -- [user\_id](ClientSession.md#user_id) ## Properties -### created\_at +### client\_session\_id -• **created\_at**: `string` +• **client\_session\_id**: `string` #### Defined in -[src/types/models.ts:351](https://github.com/seamapi/javascript/blob/main/src/types/models.ts#L351) +[src/types/models.ts:350](https://github.com/seamapi/javascript/blob/main/src/types/models.ts#L350) ___ -### token +### created\_at -• **token**: `string` +• **created\_at**: `string` #### Defined in -[src/types/models.ts:349](https://github.com/seamapi/javascript/blob/main/src/types/models.ts#L349) +[src/types/models.ts:351](https://github.com/seamapi/javascript/blob/main/src/types/models.ts#L351) ___ -### user\_id +### token -• **user\_id**: `string` +• **token**: `string` #### Defined in -[src/types/models.ts:350](https://github.com/seamapi/javascript/blob/main/src/types/models.ts#L350) +[src/types/models.ts:349](https://github.com/seamapi/javascript/blob/main/src/types/models.ts#L349) diff --git a/docs/interfaces/ClientSessionResponse.md b/docs/interfaces/ClientSessionResponse.md deleted file mode 100644 index 1f8899aa..00000000 --- a/docs/interfaces/ClientSessionResponse.md +++ /dev/null @@ -1,19 +0,0 @@ -[seamapi](../README.md) / [Exports](../modules.md) / ClientSessionResponse - -# Interface: ClientSessionResponse - -## Table of contents - -### Properties - -- [client\_session](ClientSessionResponse.md#client_session) - -## Properties - -### client\_session - -• **client\_session**: [`ClientSession`](ClientSession.md) - -#### Defined in - -[src/types/route-responses.ts:133](https://github.com/seamapi/javascript/blob/main/src/types/route-responses.ts#L133) diff --git a/docs/modules.md b/docs/modules.md index 11957454..e9f2404a 100644 --- a/docs/modules.md +++ b/docs/modules.md @@ -40,7 +40,6 @@ - [ActionAttemptResultTypeMap](interfaces/ActionAttemptResultTypeMap.md) - [ActionAttemptWithError](interfaces/ActionAttemptWithError.md) - [ClientSession](interfaces/ClientSession.md) -- [ClientSessionResponse](interfaces/ClientSessionResponse.md) - [ConnectWebview](interfaces/ConnectWebview.md) - [ConnectWebviewCreateRequest](interfaces/ConnectWebviewCreateRequest.md) - [ConnectWebviewCreateResponse](interfaces/ConnectWebviewCreateResponse.md) @@ -110,6 +109,9 @@ - [ActionType](modules.md#actiontype) - [AnyDevice](modules.md#anydevice) - [BatteryStatus](modules.md#batterystatus) +- [ClientSessionsCreateRequest](modules.md#clientsessionscreaterequest) +- [ClientSessionsGetOrCreateRequest](modules.md#clientsessionsgetorcreaterequest) +- [ClientSessionsResponse](modules.md#clientsessionsresponse) - [CommonDeviceProperties](modules.md#commondeviceproperties) - [CustomMetadata](modules.md#custommetadata) - [DeviceDeleteRequest](modules.md#devicedeleterequest) @@ -364,6 +366,50 @@ ___ ___ +### ClientSessionsCreateRequest + +Ƭ **ClientSessionsCreateRequest**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `connect_webview_ids?` | `string`[] | +| `connected_account_ids?` | `string`[] | +| `user_identifier_key` | `string` | + +#### Defined in + +[src/types/route-requests.ts:214](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L214) + +___ + +### ClientSessionsGetOrCreateRequest + +Ƭ **ClientSessionsGetOrCreateRequest**: [`ClientSessionsCreateRequest`](modules.md#clientsessionscreaterequest) + +#### Defined in + +[src/types/route-requests.ts:220](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L220) + +___ + +### ClientSessionsResponse + +Ƭ **ClientSessionsResponse**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `client_session` | [`ClientSession`](interfaces/ClientSession.md) | + +#### Defined in + +[src/types/route-responses.ts:138](https://github.com/seamapi/javascript/blob/main/src/types/route-responses.ts#L138) + +___ + ### CommonDeviceProperties Ƭ **CommonDeviceProperties**: `Object` @@ -454,7 +500,7 @@ ___ #### Defined in -[src/types/route-requests.ts:214](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L214) +[src/types/route-requests.ts:222](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L222) ___ @@ -470,7 +516,7 @@ ___ #### Defined in -[src/types/route-responses.ts:140](https://github.com/seamapi/javascript/blob/main/src/types/route-responses.ts#L140) +[src/types/route-responses.ts:142](https://github.com/seamapi/javascript/blob/main/src/types/route-responses.ts#L142) ___ @@ -632,7 +678,7 @@ ___ #### Defined in -[src/types/route-responses.ts:136](https://github.com/seamapi/javascript/blob/main/src/types/route-responses.ts#L136) +[src/types/route-responses.ts:133](https://github.com/seamapi/javascript/blob/main/src/types/route-responses.ts#L133) ___ diff --git a/src/seam-connect/client.ts b/src/seam-connect/client.ts index 4f55d7ca..1b9bcfc8 100644 --- a/src/seam-connect/client.ts +++ b/src/seam-connect/client.ts @@ -13,7 +13,7 @@ import { SuccessfulAPIResponse, } from "../types/globals" import { version } from "../../package.json" -import { ClientSessionResponse } from "../types" +import { ClientSessionsResponse } from "../types" export interface SeamClientOptions { /* Seam API Key */ @@ -102,7 +102,7 @@ export class Seam extends Routes { endpoint?: string workspaceId?: string apiKey?: string - }): Promise> { + }): Promise> { const { apiKey, endpoint, axiosOptions } = getSeamClientOptionsWithDefaults(options) diff --git a/src/seam-connect/routes.ts b/src/seam-connect/routes.ts index 5f00a82b..872ab9c4 100644 --- a/src/seam-connect/routes.ts +++ b/src/seam-connect/routes.ts @@ -42,6 +42,8 @@ import { NoiseThresholdsDeleteRequest, NoiseThresholdsCreateRequest, NoiseThresholdsUpdateRequest, + ClientSessionsCreateRequest, + ClientSessionsGetOrCreateRequest, UnmanagedAccessCodeConvertToManagedRequest, DeviceModelsListRequest, } from "../types/route-requests" @@ -72,6 +74,7 @@ import { WorkspaceResetSandboxResponse, WorkspacesListResponse, NoiseThresholdsListResponse, + ClientSessionsResponse, DeviceModelsListResponse, } from "../types/route-responses" @@ -467,6 +470,21 @@ export abstract class Routes { }), } + public readonly clientSessions = { + create: (params: ClientSessionsCreateRequest) => + this.makeRequestAndFormat("client_session", { + url: "/client_sessions/create", + method: "POST", + params, + }), + getOrCreate: (params: ClientSessionsGetOrCreateRequest) => + this.makeRequestAndFormat("client_session", { + url: "/client_sessions/create", + method: "PUT", + params, + }), + } + public readonly deviceModels = { list: (params?: DeviceModelsListRequest) => this.makeRequestAndFormat("device_models", { diff --git a/src/types/models.ts b/src/types/models.ts index 29ec3bf5..5ab91bd5 100644 --- a/src/types/models.ts +++ b/src/types/models.ts @@ -347,7 +347,7 @@ export type Event = Flatten export interface ClientSession { token: string - user_id: string + client_session_id: string created_at: string } diff --git a/src/types/route-requests.ts b/src/types/route-requests.ts index 5400089c..9e7d32dd 100644 --- a/src/types/route-requests.ts +++ b/src/types/route-requests.ts @@ -211,6 +211,14 @@ export type NoiseThresholdsDeleteRequest = { noise_threshold_id: string } +export type ClientSessionsCreateRequest = { + user_identifier_key: string + connect_webview_ids?: string[] + connected_account_ids?: string[] +} + +export type ClientSessionsGetOrCreateRequest = ClientSessionsCreateRequest + export type DeviceModelsListRequest = { main_category?: string support_level?: string diff --git a/src/types/route-responses.ts b/src/types/route-responses.ts index ee78d5d4..b58d8278 100644 --- a/src/types/route-responses.ts +++ b/src/types/route-responses.ts @@ -129,14 +129,16 @@ export interface EventsListResponse { events: Event[] } -export interface ClientSessionResponse { - client_session: ClientSession -} - +// Noise Thresholds export type NoiseThresholdsListResponse = { noise_thresholds: NoiseThresholds[] } +// Client Sessions +export type ClientSessionsResponse = { + client_session: ClientSession +} + export type DeviceModelsListResponse = { device_models: DeviceModel[] } diff --git a/tests/routes.test.ts b/tests/routes.test.ts index f9901b2c..eff473c3 100644 --- a/tests/routes.test.ts +++ b/tests/routes.test.ts @@ -361,3 +361,15 @@ test( }, "{}" ) + +// Client Sessions +test( + testAPIMethod("clientSessions.create"), + { modifiesState: true }, + "ClientSession" +) +test( + testAPIMethod("clientSessions.getOrCreate"), + { modifiesState: true }, + "ClientSession" +)