Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PB-2424] Feat: user can't shared item details #268

Merged
merged 8 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@internxt/sdk",
"author": "Internxt <[email protected]>",
"version": "1.9.5",
"version": "1.9.6",
"description": "An sdk for interacting with Internxt's services",
"repository": {
"type": "git",
Expand Down
9 changes: 2 additions & 7 deletions src/drive/share/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
UpdateUserRolePayload,
UpdateUserRoleResponse,
} from './types';
import { ItemType } from 'src/workspaces';

export * as ShareTypes from './types';

Expand Down Expand Up @@ -363,13 +364,7 @@ export class Share {
* @returns {Promise<{ data: SharingInvite[] }>} A promise containing the private folder data.
*/

public getSharedFolderInvitations({
itemId,
itemType,
}: {
itemId: string;
itemType: 'folder' | 'file';
}): Promise<any[]> {
public getSharedFolderInvitations({ itemId, itemType }: { itemId: string; itemType: ItemType }): Promise<any[]> {
return this.client.get(`sharings/${itemType}/${itemId}/invites`, this.headers());
}

Expand Down
27 changes: 23 additions & 4 deletions src/drive/share/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { FolderChild } from '../storage/types';
import { ItemType } from './../../workspaces/types';

export interface GenerateShareLinkPayload {
itemId: string;
Expand Down Expand Up @@ -78,6 +79,21 @@ export interface ShareDomainsResponse {
list: string[];
}

export interface WorkspaceItemUser {
id: string;
itemId: string;
itemType: ItemType;
workspaceId: string;
createdAt: string | null;
updatedAt: string | null;
creator: {
uuid: string;
name: string;
lastname: string;
email: string;
};
}

export type ListShareLinksItem = Pick<
ShareLink,
'id' | 'token' | 'views' | 'timesValid' | 'active' | 'isFolder' | 'createdAt' | 'updatedAt' | 'fileSize'
Expand Down Expand Up @@ -115,6 +131,7 @@ export type SharedFolders = {
user: { avatar: string | null; email: string; lastname: string; name: string; uuid: string };
userId: number;
uuid: string;
token: string | null;
};

export type SharedFiles = {
Expand All @@ -139,8 +156,10 @@ export type SharedFiles = {
thumbnails: [];
type: string;
updatedAt: string;
user: { avatar: string | null; email: string; lastname: string; name: string; uuid: string };
userId: number;
uuid: string;
token: string | null;
};

export type ListSharedItemsResponse = {
Expand All @@ -160,7 +179,7 @@ export type ListAllSharedFoldersResponse = {

export type ShareFolderWithUserPayload = {
itemId: string;
itemType: 'folder' | 'file';
itemType: ItemType;
notifyUser: boolean;
notificationMessage?: string;
sharedWith: string;
Expand All @@ -172,7 +191,7 @@ export type ShareFolderWithUserPayload = {

export type CreateSharingPayload = {
itemId: string;
itemType: 'folder' | 'file';
itemType: ItemType;
encryptionKey: string;
encryptionAlgorithm: string;
encryptedCode: string;
Expand Down Expand Up @@ -312,7 +331,7 @@ export type SharingInvitation = {
export type SharingInvite = {
id: string;
itemId: string;
itemType: 'file' | 'folder';
itemType: ItemType;
sharedWith: string;
encryptionKey: string;
encryptionAlgorithm: string;
Expand All @@ -325,7 +344,7 @@ export type SharingInvite = {
export type SharingMeta = {
id: string;
itemId: string;
itemType: 'file' | 'folder';
itemType: ItemType;
ownerId: string;
sharedWith: string;
encryptionKey: string;
Expand Down
43 changes: 32 additions & 11 deletions src/drive/storage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ApiSecurity, ApiUrl, AppDetails } from '../../shared';
import { CustomHeaders, addResourcesTokenToHeaders, headersWithToken } from '../../shared/headers';
import { HttpClient, RequestCanceler } from '../../shared/http/client';
import { UUID } from '../../shared/types/userSettings';
import { ItemType } from './../../workspaces/types';
import {
AddItemsToTrashPayload,
CheckDuplicatedFilesPayload,
Expand All @@ -23,6 +24,7 @@ import {
FileEntryByUuid,
FileMeta,
FolderAncestor,
FolderAncestorWorkspace,
FolderMeta,
FolderTreeResponse,
MoveFilePayload,
Expand Down Expand Up @@ -202,8 +204,8 @@ export class Storage {

const customHeaders = workspacesToken
? {
'x-internxt-workspace': workspacesToken,
}
'x-internxt-workspace': workspacesToken,
}
: undefined;
const { promise, requestCanceler } = this.client.getCancellable<FetchFolderContentResponse>(
`/folders/content/${folderUuid}?${query}`,
Expand All @@ -223,8 +225,8 @@ export class Storage {
public getFile(fileId: string, workspacesToken?: string): [Promise<FileMeta>, RequestCanceler] {
const customHeaders = workspacesToken
? {
'x-internxt-workspace': workspacesToken,
}
'x-internxt-workspace': workspacesToken,
}
: undefined;
const { promise, requestCanceler } = this.client.getCancellable<FileMeta>(
`/files/${fileId}/meta`,
Expand Down Expand Up @@ -489,8 +491,8 @@ export class Storage {
*/
public updateFileMetaByUUID(
fileUuid: string,
payload: { plainName?: string; type?: string | null; },
resourcesToken?: Token
payload: { plainName?: string; type?: string | null },
resourcesToken?: Token,
): Promise<void> {
return this.client.put(
`/files/${fileUuid}/meta`,
Expand Down Expand Up @@ -635,11 +637,30 @@ export class Storage {
* Gets the ancestors of a given folder UUID
*
* @param {string} uuid - UUID of the folder.
* @param {boolean} [isShared=false] - Whether the folder is a shared item or not.
* @returns {Promise<FolderAncestor[]>} A promise that resolves with an array of ancestors of the given folder.
*/
public getFolderAncestors(uuid: string, isShared = false): Promise<FolderAncestor[]> {
return this.client.get<FolderAncestor[]>(`folders/${uuid}/ancestors?isSharedItem=${isShared}`, this.headers());
public getFolderAncestors(uuid: string): Promise<FolderAncestor[]> {
return this.client.get<FolderAncestor[]>(`folders/${uuid}/ancestors`, this.headers());
}

/**
* Gets the ancestors of an item with the given UUID and type in a Workspace
*
* @param {string} workspaceId - UUID of the workspace.
* @param {string} itemType - itemType to know if the item is file or folder
* @param {string} uuid - UUID of the item.
* @returns {Promise<FolderAncestor[]>} A promise that resolves with an array of ancestors of the given folder.
*/
public getFolderAncestorsInWorkspace(
workspaceId: string,
itemType: ItemType,
uuid: string,
resourcesToken?: Token,
): Promise<FolderAncestorWorkspace[]> {
return this.client.get<FolderAncestorWorkspace[]>(
`workspaces/${workspaceId}/${itemType}/${uuid}/ancestors`,
addResourcesTokenToHeaders(this.headers(), resourcesToken),
);
}

/**
Expand All @@ -651,8 +672,8 @@ export class Storage {
public getFolderMeta(uuid: string, workspacesToken?: string, resourcesToken?: string): Promise<FolderMeta> {
const customHeaders = workspacesToken
? {
'x-internxt-workspace': workspacesToken,
}
'x-internxt-workspace': workspacesToken,
}
: undefined;

return this.client.get<FolderMeta>(
Expand Down
7 changes: 7 additions & 0 deletions src/drive/storage/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { SharingMeta } from '../share/types';
import { UserResumeData } from '../users/types';

export interface DriveFolderData {
id: number;
Expand All @@ -19,6 +20,7 @@ export interface DriveFolderData {
userId: number;
user_id: number;
uuid: string;
user?: UserResumeData;
}

export interface DriveFileData {
Expand All @@ -45,6 +47,7 @@ export interface DriveFileData {
shares?: Array<ShareLink>;
sharings?: { type: string; id: string }[];
uuid: string;
user?: UserResumeData;
}

export interface Thumbnail {
Expand Down Expand Up @@ -431,6 +434,10 @@ export interface FolderAncestor {
userId: number;
uuid: string;
}
export interface FolderAncestorWorkspace {
uuid: string;
plainName: string;
}
export interface FolderMeta {
id: number;
uuid: string;
Expand Down
8 changes: 8 additions & 0 deletions src/drive/users/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import { UUID, UserSettings } from '../../shared/types/userSettings';

export interface UserResumeData {
avatar: string | null;
email: string;
lastname: string | null;
name: string;
uuid: string;
}

export type Token = string;

export interface InitializeUserResponse {
Expand Down
Loading
Loading