From 80bb9e3e32f8bca6db290d317661fcd0c9250926 Mon Sep 17 00:00:00 2001 From: Rafa Date: Mon, 1 Jul 2024 17:15:50 +0200 Subject: [PATCH 1/4] [PB-2082] add workspace pending invitations --- src/workspaces/index.ts | 17 +++++++++++++++++ src/workspaces/types.ts | 19 +++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/src/workspaces/index.ts b/src/workspaces/index.ts index b3b8103..eaeb1e0 100644 --- a/src/workspaces/index.ts +++ b/src/workspaces/index.ts @@ -13,6 +13,7 @@ import { WorkspaceSetupInfo, WorkspaceTeamResponse, WorkspacesResponse, + WorkspacePendingInvitations, } from './types'; export class Workspaces { @@ -280,6 +281,22 @@ export class Workspaces { return [promise, requestCanceler]; } + + public getWorkspacePendingInvitations( + workspaceId: string, + limit: number, + offset: number, + ): Promise { + const limitQuery = `?limit=${limit}`; + const offsetQuery = `&offset=${offset}`; + + const query = `${limitQuery}${offsetQuery}`; + + return this.client.get( + `workspaces/${workspaceId}/invitations/${query}`, + this.headers(), + ); + } } export * from './types'; diff --git a/src/workspaces/types.ts b/src/workspaces/types.ts index 65b539a..18cdf02 100644 --- a/src/workspaces/types.ts +++ b/src/workspaces/types.ts @@ -173,3 +173,22 @@ export interface CreateFolderPayload { plainName: string; parentFolderUuid: string; } + +export interface WorkspacePendingInvitations { + id: string; + workspaceId: string; + invitedUser: string; + encryptionAlgorithm: string; + encryptionKey: string; + spaceLimit: string; + createdAt: Date; + updatedAt: Date; + user: { + name: string; + lastname: string; + email: string; + uuid: string; + avatar: string | null; + }; + isGuessInvite: boolean; +} From 3720c93a3cfd53a5db5bb5e768c138a29938b372 Mon Sep 17 00:00:00 2001 From: Rafa Date: Mon, 1 Jul 2024 18:05:41 +0200 Subject: [PATCH 2/4] add validation for invitation to workspace --- src/workspaces/index.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/workspaces/index.ts b/src/workspaces/index.ts index eaeb1e0..7ba56c5 100644 --- a/src/workspaces/index.ts +++ b/src/workspaces/index.ts @@ -297,6 +297,10 @@ export class Workspaces { this.headers(), ); } + + public validateWorkspaceInvitation(inviteId: string): Promise<{ uuid: string }> { + return this.client.get<{ uuid: string }>(`workspaces/invitations/${inviteId}/validate`, this.headers()); + } } export * from './types'; From c294fdc93971e551cd948d6089e12a9897601dea Mon Sep 17 00:00:00 2001 From: Rafa Date: Tue, 2 Jul 2024 09:30:34 +0200 Subject: [PATCH 3/4] add message inviting member to workspace --- src/workspaces/index.test.ts | 3 +++ src/workspaces/index.ts | 2 ++ src/workspaces/types.ts | 1 + 3 files changed, 6 insertions(+) diff --git a/src/workspaces/index.test.ts b/src/workspaces/index.test.ts index 7a000e0..64240c7 100644 --- a/src/workspaces/index.test.ts +++ b/src/workspaces/index.test.ts @@ -350,6 +350,7 @@ describe('Workspaces service tests', () => { const encryptionAlgorithm = 'aes-256-gcm'; const { client, headers } = clientAndHeaders(); const postCall = sinon.stub(httpClient, 'post').resolves(); + const message = 'Test message'; await client.inviteMemberToWorkspace({ workspaceId, @@ -357,6 +358,7 @@ describe('Workspaces service tests', () => { spaceLimitBytes, encryptedMnemonicInBase64, encryptionAlgorithm, + message, }); expect(postCall.firstCall.args).toEqual([ @@ -366,6 +368,7 @@ describe('Workspaces service tests', () => { spaceLimit: spaceLimitBytes, encryptionKey: encryptedMnemonicInBase64, encryptionAlgorithm: 'aes-256-gcm', + message: message, }, headers, ]); diff --git a/src/workspaces/index.ts b/src/workspaces/index.ts index 7ba56c5..fc6dacf 100644 --- a/src/workspaces/index.ts +++ b/src/workspaces/index.ts @@ -138,6 +138,7 @@ export class Workspaces { spaceLimitBytes, encryptedMnemonicInBase64, encryptionAlgorithm = 'aes-256-gcm', + message, }: InviteMemberBody): Promise { return this.client.post( `workspaces/${workspaceId}/members/invite`, @@ -146,6 +147,7 @@ export class Workspaces { spaceLimit: spaceLimitBytes, encryptionKey: encryptedMnemonicInBase64, encryptionAlgorithm, + message: message, }, this.headers(), ); diff --git a/src/workspaces/types.ts b/src/workspaces/types.ts index 18cdf02..17c055d 100644 --- a/src/workspaces/types.ts +++ b/src/workspaces/types.ts @@ -139,6 +139,7 @@ export type InviteMemberBody = { spaceLimitBytes: number; encryptedMnemonicInBase64: string; encryptionAlgorithm: string; + message: string; }; export type FileEntry = { From 69c8327f4863fb4d3eda9a53a745fe9fe63192cc Mon Sep 17 00:00:00 2001 From: Rafa Date: Tue, 2 Jul 2024 17:12:30 +0200 Subject: [PATCH 4/4] fix getPendingInvites --- package.json | 2 +- src/workspaces/index.ts | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index fda3725..f552e2b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@internxt/sdk", - "version": "1.4.89", + "version": "1.4.90", "description": "An sdk for interacting with Internxt's services", "repository": { "type": "git", diff --git a/src/workspaces/index.ts b/src/workspaces/index.ts index 2700adb..15bfe34 100644 --- a/src/workspaces/index.ts +++ b/src/workspaces/index.ts @@ -77,7 +77,10 @@ export class Workspaces { } public getPendingInvites(): Promise { - return this.client.get('workspaces/invitations', this.headers()); + const limitQuery = '?limit=25'; + const offsetQuery = '&offset=0'; + const query = `${limitQuery}${offsetQuery}`; + return this.client.get(`workspaces/invitations/${query}`, this.headers()); } public validateWorkspaceInvite(inviteId: string): Promise {