Skip to content
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 <hello@internxt.com>",
"version": "1.21.1",
"version": "1.22.0",
"description": "An sdk for interacting with Internxt's services",
"repository": {
"type": "git",
Expand Down
86 changes: 86 additions & 0 deletions src/drive/storage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ import {
FavoriteFolderDto,
FavoriteItemType,
FavoriteStatusResponse,
FetchFilesSyncResponse,
FetchFolderContentResponse,
FetchFolderFilesCursorResponse,
FetchFolderFoldersCursorResponse,
FetchFoldersSyncResponse,
FetchLimitResponse,
FetchPaginatedFilesContent,
FetchPaginatedFolderContentResponse,
Expand All @@ -29,8 +33,12 @@ import {
FileEntryByUuid,
FileMeta,
FileVersion,
FilesSyncQuery,
FolderAncestor,
FolderAncestorWorkspace,
FolderFilesCursorQuery,
FolderFoldersCursorQuery,
FoldersSyncQuery,
GlobalSearchOptions,
FolderMeta,
FolderStatsResponse,
Expand Down Expand Up @@ -283,6 +291,7 @@ export class Storage {
* @param {string} [sort=plainName] - The reference column to sort it.
* @param {string} [order=ASC] - The order to be followed.
* @returns {[Promise<FetchPaginatedFilesContent>, RequestCanceler]} An array containing a promise to get the API response and a function to cancel the request.
* @deprecated Use `getFolderFilesByUuidWithCursor` instead.
*/
public getFolderFilesByUuid(
folderUuid: UUID,
Expand Down Expand Up @@ -347,6 +356,7 @@ export class Storage {
* @param {string} [sort=plainName] - The reference column to sort it.
* @param {string} [order=ASC] - The order to be followed.
* @returns {[Promise<FetchPaginatedFoldersContent>, RequestCanceler]} An array containing a promise to get the API response and a function to cancel the request.
* @deprecated Use `getFolderFoldersByUuidWithCursor` instead.
*/
public getFolderFoldersByUuid(
folderUuid: UUID,
Expand All @@ -370,6 +380,82 @@ export class Storage {
return [promise, requestCanceler];
}

/**
* Gets a page of the files in a folder using cursor based pagination, sorted by plain name.
* Follow `nextCursor` until it is null to get every file. Only existing files are returned.
*
* @param {UUID} folderUuid - The UUID of the folder.
* @param {FolderFilesCursorQuery} [query] - Page size (50-1000), order, cursor and optional extra data.
* @returns {[Promise<FetchFolderFilesCursorResponse>, RequestCanceler]} An array containing a promise to get the API response and a function to cancel the request.
*/
public getFolderFilesByUuidWithCursor(
folderUuid: UUID,
query: FolderFilesCursorQuery = {},
): [Promise<FetchFolderFilesCursorResponse>, RequestCanceler] {
const { promise, requestCanceler } = this.client.getCancellable<FetchFolderFilesCursorResponse>(
`/folders/v2/content/${folderUuid}/files`,
this.headers(),
query,
);

return [promise, requestCanceler];
}

/**
* Gets a page of the subfolders of a folder using cursor based pagination, sorted by plain name.
* Follow `nextCursor` until it is null to get every subfolder. Only existing folders are returned.
*
* @param {UUID} folderUuid - The UUID of the folder.
* @param {FolderFoldersCursorQuery} [query] - Page size (50-1000), order, cursor and optional extra data.
* @returns {[Promise<FetchFolderFoldersCursorResponse>, RequestCanceler]} An array containing a promise to get the API response and a function to cancel the request.
*/
public getFolderFoldersByUuidWithCursor(
folderUuid: UUID,
query: FolderFoldersCursorQuery = {},
): [Promise<FetchFolderFoldersCursorResponse>, RequestCanceler] {
const { promise, requestCanceler } = this.client.getCancellable<FetchFolderFoldersCursorResponse>(
`/folders/v2/content/${folderUuid}/folders`,
this.headers(),
query,
);

return [promise, requestCanceler];
}

/**
* Gets a page of the user's files updated after a date, using cursor based pagination.
* Pass `updatedAt` on the first request, then only `nextCursor` (with the same `status`) until it is null.
*
* @param {FilesSyncQuery} query - updatedAt or cursor, optional status filter and page size (max 1000).
* @returns {[Promise<FetchFilesSyncResponse>, RequestCanceler]} An array containing a promise to get the API response and a function to cancel the request.
*/
public getFilesSync(query: FilesSyncQuery): [Promise<FetchFilesSyncResponse>, RequestCanceler] {
const { promise, requestCanceler } = this.client.getCancellable<FetchFilesSyncResponse>(
'/files/sync',
this.headers(),
query,
);

return [promise, requestCanceler];
}

/**
* Gets a page of the user's folders updated after a date, using cursor based pagination. Root folders are excluded.
* Pass `updatedAt` on the first request, then only `nextCursor` (with the same `status`) until it is null.
*
* @param {FoldersSyncQuery} query - updatedAt or cursor, optional status filter and page size (max 1000).
* @returns {[Promise<FetchFoldersSyncResponse>, RequestCanceler]} An array containing a promise to get the API response and a function to cancel the request.
*/
public getFoldersSync(query: FoldersSyncQuery): [Promise<FetchFoldersSyncResponse>, RequestCanceler] {
const { promise, requestCanceler } = this.client.getCancellable<FetchFoldersSyncResponse>(
'/folders/sync',
this.headers(),
query,
);

return [promise, requestCanceler];
}

/**
* Removes a specific folder from the centralized persistence
* @param folderId
Expand Down
22 changes: 22 additions & 0 deletions src/drive/storage/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,28 @@ export type FetchPaginatedFilesContent =
export type FetchPaginatedFoldersContent =
paths['/folders/content/{uuid}/folders']['get']['responses']['200']['content']['application/json'];

export type FolderFilesCursorQuery = NonNullable<
paths['/folders/v2/content/{uuid}/files']['get']['parameters']['query']
>;

export type FolderFoldersCursorQuery = NonNullable<
paths['/folders/v2/content/{uuid}/folders']['get']['parameters']['query']
>;

export type FetchFolderFilesCursorResponse =
paths['/folders/v2/content/{uuid}/files']['get']['responses']['200']['content']['application/json'];

export type FetchFolderFoldersCursorResponse =
paths['/folders/v2/content/{uuid}/folders']['get']['responses']['200']['content']['application/json'];

export type FilesSyncQuery = NonNullable<paths['/files/sync']['get']['parameters']['query']>;

export type FoldersSyncQuery = NonNullable<paths['/folders/sync']['get']['parameters']['query']>;

export type FetchFilesSyncResponse = paths['/files/sync']['get']['responses']['200']['content']['application/json'];

export type FetchFoldersSyncResponse = paths['/folders/sync']['get']['responses']['200']['content']['application/json'];

export interface FetchTrashContentResponse {
result: {
id: number;
Expand Down
Loading
Loading