Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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.16",
"version": "1.9.17",
"description": "An sdk for interacting with Internxt's services",
"repository": {
"type": "git",
Expand Down
9 changes: 9 additions & 0 deletions src/drive/storage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import {
UpdateFilePayload,
UpdateFolderMetadataPayload,
UsageResponse,
UsageResponseV2,
} from './types';

export * as StorageTypes from './types';
Expand Down Expand Up @@ -615,13 +616,21 @@ export class Storage {
return this.client.get('/usage', this.headers());
}

public spaceUsageV2(): Promise<UsageResponseV2> {
return this.client.get('/users/usage', this.headers());
}

/**
* Returns the current space limit for the user
*/
public spaceLimit(): Promise<FetchLimitResponse> {
return this.client.get('/limit', this.headers());
}

public spaceLimitV2(): Promise<FetchLimitResponse> {
return this.client.get('/users/limit', this.headers());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember to add the jsdoc and the deprecated tag
to old endpoints

}

/**
* Get global search items.
*
Expand Down
7 changes: 6 additions & 1 deletion src/drive/storage/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,6 @@ export interface ThumbnailEntry {
}

export interface CreateThumbnailEntryPayload {
fileId: number;
fileUuid: string;
type: string;
size: number;
Expand Down Expand Up @@ -397,6 +396,12 @@ export type UsageResponse = {
[k in 'drive' | 'backups' | 'total']: number;
};

export type UsageResponseV2 = {
drive: number;
backups: number;
total: number;
};

export interface FetchLimitResponse {
maxSpaceBytes: number;
}
Expand Down
33 changes: 32 additions & 1 deletion test/drive/storage/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -719,6 +719,22 @@ describe('# storage service tests', () => {
});
});

describe('space usage v2', () => {
it('should call with right params & return response', async () => {
const { client, headers } = clientAndHeaders({});
const callStub = sinon.stub(httpClient, 'get').resolves({
drive: 10,
});

const body = await client.spaceUsageV2();

expect(callStub.firstCall.args).toEqual(['/users/usage', headers]);
expect(body).toEqual({
drive: 10,
});
});
});

describe('space limit', () => {
it('should call with right params & return response', async () => {
// Arrange
Expand All @@ -738,6 +754,22 @@ describe('# storage service tests', () => {
});
});

describe('space limit v2', () => {
it('should call with right params & return response', async () => {
const { client, headers } = clientAndHeaders({});
const callStub = sinon.stub(httpClient, 'get').resolves({
maxSpaceBytes: 10,
});

const body = await client.spaceLimitV2();

expect(callStub.firstCall.args).toEqual(['/users/limit', headers]);
expect(body).toEqual({
maxSpaceBytes: 10,
});
});
});

describe('Trash', () => {
describe('get Trash', () => {
it('Should return the expected elements', async () => {
Expand Down Expand Up @@ -797,7 +829,6 @@ describe('# storage service tests', () => {
describe('createThumbnailEntryWithUUID', () => {
it('Should create a thumbnail entry with UUID and handle resourcesToken', async () => {
const thumbnailEntryPayload: StorageTypes.CreateThumbnailEntryPayload = {
fileId: 123,
fileUuid: v4(),
type: 'image/jpeg',
size: 1024,
Expand Down