From 32a8e481ae75656bebf2657d679f0f699cb7b5bf Mon Sep 17 00:00:00 2001 From: andrii-balitskyi <10balian10@gmail.com> Date: Fri, 19 May 2023 17:11:44 +0200 Subject: [PATCH 1/4] Add clientSessions.create and *.getOrCreate --- docs/classes/Seam.md | 46 ++++++++++++++++------ docs/interfaces/ClientSession.md | 20 +++++----- docs/interfaces/ClientSessionResponse.md | 19 --------- docs/modules.md | 50 +++++++++++++++++++++++- src/seam-connect/client.ts | 4 +- src/seam-connect/routes.ts | 18 +++++++++ src/types/models.ts | 2 +- src/types/route-requests.ts | 8 ++++ src/types/route-responses.ts | 10 +++-- tests/routes.test.ts | 12 ++++++ 10 files changed, 139 insertions(+), 50 deletions(-) delete mode 100644 docs/interfaces/ClientSessionResponse.md diff --git a/docs/classes/Seam.md b/docs/classes/Seam.md index fe8f4881..2c8894be 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) - [devices](Seam.md#devices) @@ -81,7 +82,7 @@ Routes.accessCodes #### Defined in -[src/seam-connect/routes.ts:279](https://github.com/seamapi/javascript/blob/main/src/seam-connect/routes.ts#L279) +[src/seam-connect/routes.ts:282](https://github.com/seamapi/javascript/blob/main/src/seam-connect/routes.ts#L282) ___ @@ -101,7 +102,7 @@ Routes.actionAttempts #### Defined in -[src/seam-connect/routes.ts:394](https://github.com/seamapi/javascript/blob/main/src/seam-connect/routes.ts#L394) +[src/seam-connect/routes.ts:397](https://github.com/seamapi/javascript/blob/main/src/seam-connect/routes.ts#L397) ___ @@ -115,6 +116,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:463](https://github.com/seamapi/javascript/blob/main/src/seam-connect/routes.ts#L463) + +___ + ### connectWebviews • `Readonly` **connectWebviews**: `Object` @@ -134,7 +156,7 @@ Routes.connectWebviews #### Defined in -[src/seam-connect/routes.ts:247](https://github.com/seamapi/javascript/blob/main/src/seam-connect/routes.ts#L247) +[src/seam-connect/routes.ts:250](https://github.com/seamapi/javascript/blob/main/src/seam-connect/routes.ts#L250) ___ @@ -156,7 +178,7 @@ Routes.connectedAccounts #### Defined in -[src/seam-connect/routes.ts:369](https://github.com/seamapi/javascript/blob/main/src/seam-connect/routes.ts#L369) +[src/seam-connect/routes.ts:372](https://github.com/seamapi/javascript/blob/main/src/seam-connect/routes.ts#L372) ___ @@ -183,7 +205,7 @@ Routes.devices #### Defined in -[src/seam-connect/routes.ts:188](https://github.com/seamapi/javascript/blob/main/src/seam-connect/routes.ts#L188) +[src/seam-connect/routes.ts:191](https://github.com/seamapi/javascript/blob/main/src/seam-connect/routes.ts#L191) ___ @@ -203,7 +225,7 @@ Routes.events #### Defined in -[src/seam-connect/routes.ts:235](https://github.com/seamapi/javascript/blob/main/src/seam-connect/routes.ts#L235) +[src/seam-connect/routes.ts:238](https://github.com/seamapi/javascript/blob/main/src/seam-connect/routes.ts#L238) ___ @@ -226,7 +248,7 @@ Routes.locks #### Defined in -[src/seam-connect/routes.ts:153](https://github.com/seamapi/javascript/blob/main/src/seam-connect/routes.ts#L153) +[src/seam-connect/routes.ts:156](https://github.com/seamapi/javascript/blob/main/src/seam-connect/routes.ts#L156) ___ @@ -249,7 +271,7 @@ Routes.noiseThresholds #### 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) ___ @@ -272,7 +294,7 @@ Routes.webhooks #### Defined in -[src/seam-connect/routes.ts:435](https://github.com/seamapi/javascript/blob/main/src/seam-connect/routes.ts#L435) +[src/seam-connect/routes.ts:438](https://github.com/seamapi/javascript/blob/main/src/seam-connect/routes.ts#L438) ___ @@ -294,7 +316,7 @@ Routes.workspaces #### Defined in -[src/seam-connect/routes.ts:137](https://github.com/seamapi/javascript/blob/main/src/seam-connect/routes.ts#L137) +[src/seam-connect/routes.ts:140](https://github.com/seamapi/javascript/blob/main/src/seam-connect/routes.ts#L140) ## Methods @@ -330,7 +352,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 @@ -345,7 +367,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 27c495c9..28d5fb7e 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:342](https://github.com/seamapi/javascript/blob/main/src/types/models.ts#L342) +[src/types/models.ts:341](https://github.com/seamapi/javascript/blob/main/src/types/models.ts#L341) ___ -### token +### created\_at -• **token**: `string` +• **created\_at**: `string` #### Defined in -[src/types/models.ts:340](https://github.com/seamapi/javascript/blob/main/src/types/models.ts#L340) +[src/types/models.ts:342](https://github.com/seamapi/javascript/blob/main/src/types/models.ts#L342) ___ -### user\_id +### token -• **user\_id**: `string` +• **token**: `string` #### Defined in -[src/types/models.ts:341](https://github.com/seamapi/javascript/blob/main/src/types/models.ts#L341) +[src/types/models.ts:340](https://github.com/seamapi/javascript/blob/main/src/types/models.ts#L340) diff --git a/docs/interfaces/ClientSessionResponse.md b/docs/interfaces/ClientSessionResponse.md deleted file mode 100644 index 33e395ee..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:132](https://github.com/seamapi/javascript/blob/main/src/types/route-responses.ts#L132) diff --git a/docs/modules.md b/docs/modules.md index 59201f9b..606f5c32 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) @@ -109,6 +108,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) @@ -360,6 +362,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:208](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L208) + +___ + +### ClientSessionsGetOrCreateRequest + +Ƭ **ClientSessionsGetOrCreateRequest**: [`ClientSessionsCreateRequest`](modules.md#clientsessionscreaterequest) + +#### Defined in + +[src/types/route-requests.ts:214](https://github.com/seamapi/javascript/blob/main/src/types/route-requests.ts#L214) + +___ + +### ClientSessionsResponse + +Ƭ **ClientSessionsResponse**: `Object` + +#### Type declaration + +| Name | Type | +| :------ | :------ | +| `client_session` | [`ClientSession`](interfaces/ClientSession.md) | + +#### Defined in + +[src/types/route-responses.ts:137](https://github.com/seamapi/javascript/blob/main/src/types/route-responses.ts#L137) + +___ + ### CommonDeviceProperties Ƭ **CommonDeviceProperties**: `Object` @@ -592,7 +638,7 @@ ___ #### Defined in -[src/types/route-responses.ts:135](https://github.com/seamapi/javascript/blob/main/src/types/route-responses.ts#L135) +[src/types/route-responses.ts:132](https://github.com/seamapi/javascript/blob/main/src/types/route-responses.ts#L132) ___ 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 796ba958..6774f504 100644 --- a/src/seam-connect/routes.ts +++ b/src/seam-connect/routes.ts @@ -42,6 +42,8 @@ import { NoiseThresholdsDeleteRequest, NoiseThresholdsCreateRequest, NoiseThresholdsUpdateRequest, + ClientSessionsCreateRequest, + ClientSessionsGetOrCreateRequest, } from "../types/route-requests" import { AccessCodeCreateMultipleResponse, @@ -70,6 +72,7 @@ import { WorkspaceResetSandboxResponse, WorkspacesListResponse, NoiseThresholdsListResponse, + ClientSessionsResponse, } from "../types/route-responses" export abstract class Routes { @@ -456,4 +459,19 @@ export abstract class Routes { params, }), } + + 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, + }), + } } diff --git a/src/types/models.ts b/src/types/models.ts index ab91c8b1..730a4d30 100644 --- a/src/types/models.ts +++ b/src/types/models.ts @@ -338,7 +338,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 62941d87..40ab978a 100644 --- a/src/types/route-requests.ts +++ b/src/types/route-requests.ts @@ -204,3 +204,11 @@ export type NoiseThresholdsDeleteRequest = { device_id: string noise_threshold_id: string } + +export type ClientSessionsCreateRequest = { + user_identifier_key: string + connect_webview_ids?: string[] + connected_account_ids?: string[] +} + +export type ClientSessionsGetOrCreateRequest = ClientSessionsCreateRequest diff --git a/src/types/route-responses.ts b/src/types/route-responses.ts index 2e75b782..511b8478 100644 --- a/src/types/route-responses.ts +++ b/src/types/route-responses.ts @@ -128,10 +128,12 @@ 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 +} diff --git a/tests/routes.test.ts b/tests/routes.test.ts index 4a010b5f..eb70df7a 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" +) From ea92a19090e581b15fa98dc69b8dd034b31cbc61 Mon Sep 17 00:00:00 2001 From: andrii-balitskyi <10balian10@gmail.com> Date: Fri, 19 May 2023 17:25:33 +0200 Subject: [PATCH 2/4] Fix tests --- tests/routes.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/routes.test.ts b/tests/routes.test.ts index eb70df7a..eff473c3 100644 --- a/tests/routes.test.ts +++ b/tests/routes.test.ts @@ -331,7 +331,7 @@ test( { args: (seed) => [ { - email: "user-3@example.com", + email: "user-4@example.com", }, ], }, From 9e879802787e7376bb98e2c788778bbbd44b732b Mon Sep 17 00:00:00 2001 From: Andrii Balitskyi <10balian10@gmail.com> Date: Tue, 6 Jun 2023 12:55:51 +0200 Subject: [PATCH 3/4] Add container logs to CI --- .github/workflows/npm-test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/npm-test.yml b/.github/workflows/npm-test.yml index e16e9151..ecb63014 100644 --- a/.github/workflows/npm-test.yml +++ b/.github/workflows/npm-test.yml @@ -66,7 +66,7 @@ jobs: cache: "yarn" - run: yarn install --frozen-lockfile - - run: yarn test -T 3m + - run: DEBUG=testcontainers* yarn test -T 3m id: test env: SEAM_CONNECT_IMAGE: ${{ env.SEAM_CONNECT_IMAGE }} From 5e96e3e6c0655409f83489ef0a3161a52b1ace56 Mon Sep 17 00:00:00 2001 From: Andrii Balitskyi <84702959+andrii-balitskyi@users.noreply.github.com> Date: Thu, 8 Jun 2023 14:24:48 +0200 Subject: [PATCH 4/4] Update src/seam-connect/routes.ts Co-authored-by: Evan Sosenko --- src/seam-connect/routes.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/seam-connect/routes.ts b/src/seam-connect/routes.ts index 8678f161..872ab9c4 100644 --- a/src/seam-connect/routes.ts +++ b/src/seam-connect/routes.ts @@ -481,6 +481,7 @@ export abstract class Routes { this.makeRequestAndFormat("client_session", { url: "/client_sessions/create", method: "PUT", + params, }), }