diff --git a/package.json b/package.json index e088d5f8..e96b9a63 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", diff --git a/src/drive/share/index.ts b/src/drive/share/index.ts index 262f7355..cb5ea007 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,28 +267,17 @@ 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. * * @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.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({ folderUUID, roleId, newRoleId }: UpdateUserRolePayload): Promise { + public updateUserRole({ sharingId, newRoleId }: UpdateUserRolePayload): Promise { return this.client.put( - `sharings/${folderUUID}/roles/${roleId}`, + `sharings/${sharingId}/role`, { roleId: newRoleId, }, @@ -340,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()); } @@ -410,6 +399,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 71fac56c..6b1bf547 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; + sharingId: string; newRoleId: string; }; @@ -211,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; @@ -252,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; -};