From 7fc089bac9536505ffe1cc6dbd92ddb26d5f5fc5 Mon Sep 17 00:00:00 2001 From: Xavi <77491413+masterprog-cmd@users.noreply.github.com> Date: Mon, 4 Sep 2023 17:15:26 +0200 Subject: [PATCH 1/5] feat: add endpoint to decline invitations And the endpoint to update the role has also been updated. --- src/drive/share/index.ts | 11 +++++++---- src/drive/share/types.ts | 3 +-- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/drive/share/index.ts b/src/drive/share/index.ts index 262f735..e6db99e 100644 --- a/src/drive/share/index.ts +++ b/src/drive/share/index.ts @@ -281,14 +281,13 @@ export class Share { * Update the role of a user on a folder. * * @param {UpdateUserRolePayload} options - The options for updating the user's role on the folder. - * @param {string} options.folderUUID - The unique identifier of the folder. - * @param {string} options.roleId - The identifier of the role to assign to the user. + * @param {string} options.sharedWith - The unique identifier of the user to whom we will update the role. * @param {string} options.newRoleId - The new role Id. * @returns {Promise} A promise that resolves when the user's role is updated. */ - public updateUserRole({ folderUUID, roleId, newRoleId }: UpdateUserRolePayload): Promise { + public updateUserRole({ sharedWith, newRoleId }: UpdateUserRolePayload): Promise { return this.client.put( - `sharings/${folderUUID}/roles/${roleId}`, + `sharings/${sharedWith}/roles`, { roleId: newRoleId, }, @@ -410,6 +409,10 @@ export class Share { ); } + public declineSharedFolderInvite(invitationId: string): Promise { + return this.client.delete(`sharings/invites/${invitationId}`, this.headers()); + } + /** * Fetches roles for sharing items. * diff --git a/src/drive/share/types.ts b/src/drive/share/types.ts index 71fac56..0f7123a 100644 --- a/src/drive/share/types.ts +++ b/src/drive/share/types.ts @@ -178,8 +178,7 @@ export type GrantSharePrivilegesToUserResponse = { message: string }; export type UpdateUserRoleResponse = { message: string }; export type UpdateUserRolePayload = { - folderUUID: string; - roleId: string; + sharedWith: string; newRoleId: string; }; From b7506baa7873fa7a0f3fcf937489d3447c7bdf43 Mon Sep 17 00:00:00 2001 From: Xavi <77491413+masterprog-cmd@users.noreply.github.com> Date: Mon, 4 Sep 2023 17:21:52 +0200 Subject: [PATCH 2/5] feat: update package.json for release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c0fc5fd..e088d5f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@internxt/sdk", - "version": "1.4.44", + "version": "1.4.45", "description": "An sdk for interacting with Internxt's services", "repository": { "type": "git", From fbb3d1045a2a45fc5b8ea76cdcf609ed98093d8d Mon Sep 17 00:00:00 2001 From: Xavi <77491413+masterprog-cmd@users.noreply.github.com> Date: Mon, 4 Sep 2023 18:05:23 +0200 Subject: [PATCH 3/5] fix: endpoint to update role --- src/drive/share/index.ts | 16 ++------ src/drive/share/types.ts | 84 +++++++++++++++++++++++----------------- 2 files changed, 52 insertions(+), 48 deletions(-) diff --git a/src/drive/share/index.ts b/src/drive/share/index.ts index e6db99e..7a1079b 100644 --- a/src/drive/share/index.ts +++ b/src/drive/share/index.ts @@ -11,7 +11,6 @@ import { ListAllSharedFoldersResponse, ListPrivateSharedFoldersResponse, ListShareLinksResponse, - PrivateSharedFolder, SharedFolderUser, ShareDomainsResponse, ShareLink, @@ -24,6 +23,7 @@ import { RemoveUserRolePayload, Role, SharingInvite, + SharedFoldersInvitationsAsInvitedUserResponse, } from './types'; import { ApiSecurity, ApiUrl, AppDetails } from '../../shared'; import { HttpClient } from '../../shared/http/client'; @@ -267,16 +267,6 @@ export class Share { ); } - /** - * Get private folder data. - * - * @param {string} folderUUID - The UUID of the folder. - * @returns {Promise<{ data: PrivateSharedFolder }>} A promise containing the private folder data. - */ - public getPrivateSharedFolder(folderUUID: string): Promise<{ data: PrivateSharedFolder }> { - return this.client.get(`private-sharing/by-folder-id/${folderUUID}`, this.headers()); - } - /** * Update the role of a user on a folder. * @@ -287,7 +277,7 @@ export class Share { */ public updateUserRole({ sharedWith, newRoleId }: UpdateUserRolePayload): Promise { return this.client.put( - `sharings/${sharedWith}/roles`, + `sharings/${sharedWith}/role`, { roleId: newRoleId, }, @@ -339,7 +329,7 @@ export class Share { }: { limit?: number; offset?: number; - }): Promise<{ invites: any }> { + }): Promise<{ invites: SharedFoldersInvitationsAsInvitedUserResponse[] }> { return this.client.get(`sharings/invites?limit=${limit}&offset=${offset}`, this.headers()); } diff --git a/src/drive/share/types.ts b/src/drive/share/types.ts index 0f7123a..b5883db 100644 --- a/src/drive/share/types.ts +++ b/src/drive/share/types.ts @@ -210,6 +210,55 @@ export type Role = { export type getSharedFolderUsersResponse = { users: SharedFolderUser[] }; +export type SharedFoldersInvitationsAsInvitedUserResponse = { + createdAt: Date; + encryptionAlgorithm: string; + encryptionKey: string; + id: string; + invited: { avatar: string | null; email: string; lastname: string; name: string; uuid: string }; + item: ItemInvitation; + itemId: string; + itemType: string; + roleId: string; + sharedWith: string; + type: string; + updatedAt: Date; +}; + +type ItemInvitation = { + bucket: string | null; + createdAt: Date; + deleted: boolean; + deletedAt: Date | null; + encryptVersion: string; + id: number; + name: string; + parent: null; + parentId: number; + plainName: string; + removed: boolean; + removedAt: Date | null; + size: number; + type: string; + updatedAt: Date; + user: { avatar: string | null; email: string; lastname: string; name: string; uuid: string } | null; + userId: number; + uuid: string; +}; + +export type FolderUserInfo = { + avatar: string | null; + email: string; + grantedFrom: string; + grantedFromPlainName: string; + id: number; + lastname: string; + name: string; + roleId: string; + roleName: string; + uuid: string; +}; + export type SharingInvitation = { id: number; userId: string; @@ -251,38 +300,3 @@ export type SharingInvite = { createdAt: Date; updatedAt: Date; }; - -export type PrivateSharedFolder = { - id: string; - folderId: string; - ownerId: string; - sharedWith: string; - encryptionKey: string; - createdAt: string; - updatedAt: string; - folder: { - id: number; - uuid: string; - parentId: number; - parentUuid: string | null; - name: string; - bucket: string | null; - userId: number; - encryptVersion: string; - plainName: string | null; - deleted: boolean; - removed: boolean; - deletedAt: string | null; - createdAt: string; - updatedAt: string; - removedAt: string | null; - }; - owner: { - uuid: string; - email: string; - name: string; - lastname: string; - avatar: string | null; - }; - fileSize: number; -}; From b82487dbec8aa17636283541c72b55134f8307c7 Mon Sep 17 00:00:00 2001 From: Xavi <77491413+masterprog-cmd@users.noreply.github.com> Date: Tue, 5 Sep 2023 12:56:32 +0200 Subject: [PATCH 4/5] feat: update "updateUserRole" endpoint --- src/drive/share/index.ts | 6 +++--- src/drive/share/types.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/drive/share/index.ts b/src/drive/share/index.ts index 7a1079b..cb5ea00 100644 --- a/src/drive/share/index.ts +++ b/src/drive/share/index.ts @@ -271,13 +271,13 @@ export class Share { * Update the role of a user on a folder. * * @param {UpdateUserRolePayload} options - The options for updating the user's role on the folder. - * @param {string} options.sharedWith - The unique identifier of the user to whom we will update the role. + * @param {string} options.sharingId - The unique identifier of the user to whom we will update the role. * @param {string} options.newRoleId - The new role Id. * @returns {Promise} A promise that resolves when the user's role is updated. */ - public updateUserRole({ sharedWith, newRoleId }: UpdateUserRolePayload): Promise { + public updateUserRole({ sharingId, newRoleId }: UpdateUserRolePayload): Promise { return this.client.put( - `sharings/${sharedWith}/role`, + `sharings/${sharingId}/role`, { roleId: newRoleId, }, diff --git a/src/drive/share/types.ts b/src/drive/share/types.ts index b5883db..6b1bf54 100644 --- a/src/drive/share/types.ts +++ b/src/drive/share/types.ts @@ -178,7 +178,7 @@ export type GrantSharePrivilegesToUserResponse = { message: string }; export type UpdateUserRoleResponse = { message: string }; export type UpdateUserRolePayload = { - sharedWith: string; + sharingId: string; newRoleId: string; }; From beb3935aff2fbecfbeb3a160637ed4b11b4f17c8 Mon Sep 17 00:00:00 2001 From: Xavi <77491413+masterprog-cmd@users.noreply.github.com> Date: Wed, 6 Sep 2023 09:09:04 +0200 Subject: [PATCH 5/5] feat: update package version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e088d5f..e96b9a6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@internxt/sdk", - "version": "1.4.45", + "version": "1.4.46", "description": "An sdk for interacting with Internxt's services", "repository": { "type": "git",