feat(web): add invites + checkInvite to api client
This commit is contained in:
@@ -56,6 +56,13 @@ import type {
|
|||||||
ApprovalRequest,
|
ApprovalRequest,
|
||||||
PeeringSubscription,
|
PeeringSubscription,
|
||||||
PeeringNotification,
|
PeeringNotification,
|
||||||
|
InviteLinkSummary,
|
||||||
|
InviteRedemption,
|
||||||
|
CreateInviteRequest,
|
||||||
|
UpdateInviteRequest,
|
||||||
|
ReinstateInviteRequest,
|
||||||
|
ReinstateInviteResponse,
|
||||||
|
CheckInviteResponse,
|
||||||
} from '@backspace/shared';
|
} from '@backspace/shared';
|
||||||
|
|
||||||
export type { FederationPeer, ApprovalRequest, PeeringSubscription, PeeringNotification };
|
export type { FederationPeer, ApprovalRequest, PeeringSubscription, PeeringNotification };
|
||||||
@@ -74,6 +81,7 @@ export class BackspaceApiClient {
|
|||||||
register: (data: RegisterRequest) => Promise<AuthResponse>;
|
register: (data: RegisterRequest) => Promise<AuthResponse>;
|
||||||
login: (data: LoginRequest) => Promise<AuthResponse>;
|
login: (data: LoginRequest) => Promise<AuthResponse>;
|
||||||
checkUsername: (username: string) => Promise<{ available: boolean; reason?: string }>;
|
checkUsername: (username: string) => Promise<{ available: boolean; reason?: string }>;
|
||||||
|
checkInvite: (token: string) => Promise<CheckInviteResponse>;
|
||||||
};
|
};
|
||||||
|
|
||||||
readonly users: {
|
readonly users: {
|
||||||
@@ -232,6 +240,16 @@ export class BackspaceApiClient {
|
|||||||
markAllPeeringNotificationsRead: () => Promise<{ success: boolean; count: number }>;
|
markAllPeeringNotificationsRead: () => Promise<{ success: boolean; count: number }>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
readonly invites: {
|
||||||
|
list: (status?: 'active' | 'archived') => Promise<{ invites: InviteLinkSummary[] }>;
|
||||||
|
create: (body: CreateInviteRequest) => Promise<InviteLinkSummary>;
|
||||||
|
patch: (id: string, body: UpdateInviteRequest) => Promise<InviteLinkSummary>;
|
||||||
|
revoke: (id: string) => Promise<{ invite: InviteLinkSummary }>;
|
||||||
|
reinstate: (id: string, body: ReinstateInviteRequest) => Promise<ReinstateInviteResponse>;
|
||||||
|
delete: (id: string) => Promise<{ success: boolean }>;
|
||||||
|
redemptions: (id: string) => Promise<{ redemptions: InviteRedemption[] }>;
|
||||||
|
};
|
||||||
|
|
||||||
readonly admin: {
|
readonly admin: {
|
||||||
storageStats: () => Promise<StorageStats>;
|
storageStats: () => Promise<StorageStats>;
|
||||||
storageOrphans: () => Promise<{ orphans: OrphanedFile[] }>;
|
storageOrphans: () => Promise<{ orphans: OrphanedFile[] }>;
|
||||||
@@ -393,6 +411,8 @@ export class BackspaceApiClient {
|
|||||||
request<AuthResponse>('POST', '/auth/login', data, false),
|
request<AuthResponse>('POST', '/auth/login', data, false),
|
||||||
checkUsername: (username: string) =>
|
checkUsername: (username: string) =>
|
||||||
request<{ available: boolean; reason?: string }>('GET', `/auth/check-username?username=${encodeURIComponent(username)}`, undefined, false),
|
request<{ available: boolean; reason?: string }>('GET', `/auth/check-username?username=${encodeURIComponent(username)}`, undefined, false),
|
||||||
|
checkInvite: (token: string) =>
|
||||||
|
request<CheckInviteResponse>('GET', `/auth/check-invite?token=${encodeURIComponent(token)}`, undefined, false),
|
||||||
};
|
};
|
||||||
|
|
||||||
this.users = {
|
this.users = {
|
||||||
@@ -720,6 +740,23 @@ export class BackspaceApiClient {
|
|||||||
),
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.invites = {
|
||||||
|
list: (status: 'active' | 'archived' = 'active') =>
|
||||||
|
request<{ invites: InviteLinkSummary[] }>('GET', `/admin/invites?status=${status}`),
|
||||||
|
create: (body: CreateInviteRequest) =>
|
||||||
|
request<InviteLinkSummary>('POST', '/admin/invites', body),
|
||||||
|
patch: (id: string, body: UpdateInviteRequest) =>
|
||||||
|
request<InviteLinkSummary>('PATCH', `/admin/invites/${id}`, body),
|
||||||
|
revoke: (id: string) =>
|
||||||
|
request<{ invite: InviteLinkSummary }>('POST', `/admin/invites/${id}/revoke`),
|
||||||
|
reinstate: (id: string, body: ReinstateInviteRequest) =>
|
||||||
|
request<ReinstateInviteResponse>('POST', `/admin/invites/${id}/reinstate`, body),
|
||||||
|
delete: (id: string) =>
|
||||||
|
request<{ success: boolean }>('DELETE', `/admin/invites/${id}`),
|
||||||
|
redemptions: (id: string) =>
|
||||||
|
request<{ redemptions: InviteRedemption[] }>('GET', `/admin/invites/${id}/redemptions`),
|
||||||
|
};
|
||||||
|
|
||||||
this.admin = {
|
this.admin = {
|
||||||
storageStats: () => request<StorageStats>('GET', '/admin/storage/stats'),
|
storageStats: () => request<StorageStats>('GET', '/admin/storage/stats'),
|
||||||
storageOrphans: () => request<{ orphans: OrphanedFile[] }>('GET', '/admin/storage/orphans'),
|
storageOrphans: () => request<{ orphans: OrphanedFile[] }>('GET', '/admin/storage/orphans'),
|
||||||
|
|||||||
Reference in New Issue
Block a user