mirror of
https://github.com/versia-pub/api.git
synced 2025-12-06 08:28:19 +01:00
feat(client): ✨ Add full 0.8 Role API
This commit is contained in:
parent
122842c00e
commit
382374e4d6
|
|
@ -3,9 +3,9 @@ export type VersiaRole = {
|
||||||
name: string;
|
name: string;
|
||||||
permissions: RolePermission[];
|
permissions: RolePermission[];
|
||||||
priority: number;
|
priority: number;
|
||||||
description: string | null;
|
description?: string;
|
||||||
visible: boolean;
|
visible: boolean;
|
||||||
icon: string | null;
|
icon?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Last updated: 2024-11-28
|
// Last updated: 2024-11-28
|
||||||
|
|
|
||||||
|
|
@ -104,16 +104,22 @@ export class Client extends BaseClient {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* POST /api/v1/roles/:roleId
|
* POST /api/v1/accounts/:account_id/roles/:role_id
|
||||||
*
|
*
|
||||||
* Versia API only.
|
* Versia API only.
|
||||||
* @param roleId ID of the role to add to the requesting account.
|
* @param account_id The account ID.
|
||||||
|
* @param role_id The role ID.
|
||||||
*/
|
*/
|
||||||
public addRole(
|
public assignRole(
|
||||||
|
account_id: string,
|
||||||
role_id: string,
|
role_id: string,
|
||||||
extra?: RequestInit,
|
extra?: RequestInit,
|
||||||
): Promise<Output<void>> {
|
): Promise<Output<void>> {
|
||||||
return this.post<void>(`/api/v1/roles/${role_id}`, undefined, extra);
|
return this.post<void>(
|
||||||
|
`/api/v1/accounts/${account_id}/roles/${role_id}`,
|
||||||
|
undefined,
|
||||||
|
extra,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -242,6 +248,36 @@ export class Client extends BaseClient {
|
||||||
return this.post<List>("/api/v1/lists", { title }, extra);
|
return this.post<List>("/api/v1/lists", { title }, extra);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* POST /api/v1/roles
|
||||||
|
*
|
||||||
|
* Versia API only.
|
||||||
|
* @param name Name of the role.
|
||||||
|
* @param options.permissions Array of permissions.
|
||||||
|
* @param options.priority Role priority.
|
||||||
|
* @param options.description Role description.
|
||||||
|
* @param options.visible Role visibility.
|
||||||
|
* @param options.icon Role icon (URL).
|
||||||
|
* @returns Role
|
||||||
|
*/
|
||||||
|
public createRole(
|
||||||
|
name: string,
|
||||||
|
options: Partial<{
|
||||||
|
permissions: string[];
|
||||||
|
priority: number;
|
||||||
|
description: string;
|
||||||
|
visible: boolean;
|
||||||
|
icon: string;
|
||||||
|
}>,
|
||||||
|
extra?: RequestInit,
|
||||||
|
): Promise<Output<VersiaRole>> {
|
||||||
|
return this.post<VersiaRole>(
|
||||||
|
"/api/v1/roles",
|
||||||
|
{ name, ...options },
|
||||||
|
extra,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DELETE /api/v1/lists/:id/accounts
|
* DELETE /api/v1/lists/:id/accounts
|
||||||
*
|
*
|
||||||
|
|
@ -279,6 +315,7 @@ export class Client extends BaseClient {
|
||||||
/**
|
/**
|
||||||
* DELETE /api/v1/emojis/:id
|
* DELETE /api/v1/emojis/:id
|
||||||
*
|
*
|
||||||
|
* Versia API only.
|
||||||
* @param id The emoji to delete's ID.
|
* @param id The emoji to delete's ID.
|
||||||
* @return Empty.
|
* @return Empty.
|
||||||
*/
|
*/
|
||||||
|
|
@ -338,6 +375,17 @@ export class Client extends BaseClient {
|
||||||
return this.delete<void>("/api/v1/push/subscription", undefined, extra);
|
return this.delete<void>("/api/v1/push/subscription", undefined, extra);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DELETE /api/v1/roles/:id
|
||||||
|
*
|
||||||
|
* Versia API only.
|
||||||
|
* @param id The role ID.
|
||||||
|
* @return Empty.
|
||||||
|
*/
|
||||||
|
public deleteRole(id: string, extra?: RequestInit): Promise<Output<void>> {
|
||||||
|
return this.delete<void>(`/api/v1/roles/${id}`, undefined, extra);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DELETE /api/v1/statuses/:id
|
* DELETE /api/v1/statuses/:id
|
||||||
*
|
*
|
||||||
|
|
@ -423,11 +471,7 @@ export class Client extends BaseClient {
|
||||||
}>,
|
}>,
|
||||||
extra?: RequestInit,
|
extra?: RequestInit,
|
||||||
): Promise<Output<Status>> {
|
): Promise<Output<Status>> {
|
||||||
return this.put<Status>(
|
return this.put<Status>(`/api/v1/statuses/${id}`, options, extra);
|
||||||
`/api/v1/statuses/${id}`,
|
|
||||||
{ ...options },
|
|
||||||
extra,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -497,7 +541,7 @@ export class Client extends BaseClient {
|
||||||
): Promise<Output<Relationship>> {
|
): Promise<Output<Relationship>> {
|
||||||
return this.post<Relationship>(
|
return this.post<Relationship>(
|
||||||
`/api/v1/accounts/${id}/follow`,
|
`/api/v1/accounts/${id}/follow`,
|
||||||
{ ...options },
|
options,
|
||||||
extra,
|
extra,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -664,6 +708,20 @@ export class Client extends BaseClient {
|
||||||
return this.get<List[]>(`/api/v1/accounts/${id}/lists`, extra);
|
return this.get<List[]>(`/api/v1/accounts/${id}/lists`, extra);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GET /api/v1/accounts/:id/roles
|
||||||
|
*
|
||||||
|
* Versia API only.
|
||||||
|
* @param id The account ID.
|
||||||
|
* @return Array of roles.
|
||||||
|
*/
|
||||||
|
public getAccountRoles(
|
||||||
|
id: string,
|
||||||
|
extra?: RequestInit,
|
||||||
|
): Promise<Output<VersiaRole[]>> {
|
||||||
|
return this.get<VersiaRole[]>(`/api/v1/accounts/${id}/roles`, extra);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GET /api/v1/accounts/:id/statuses
|
* GET /api/v1/accounts/:id/statuses
|
||||||
*
|
*
|
||||||
|
|
@ -916,6 +974,7 @@ export class Client extends BaseClient {
|
||||||
/**
|
/**
|
||||||
* GET /api/v1/emojis/:id
|
* GET /api/v1/emojis/:id
|
||||||
*
|
*
|
||||||
|
* Versia API only.
|
||||||
* @param id The emoji ID.
|
* @param id The emoji ID.
|
||||||
* @return Emoji.
|
* @return Emoji.
|
||||||
*/
|
*/
|
||||||
|
|
@ -1589,6 +1648,7 @@ export class Client extends BaseClient {
|
||||||
/**
|
/**
|
||||||
* GET /api/v1/roles/:id
|
* GET /api/v1/roles/:id
|
||||||
*
|
*
|
||||||
|
* Versia API only.
|
||||||
* @param id Target role ID.
|
* @param id Target role ID.
|
||||||
* @return Role.
|
* @return Role.
|
||||||
*/
|
*/
|
||||||
|
|
@ -1932,7 +1992,7 @@ export class Client extends BaseClient {
|
||||||
): Promise<Output<Relationship>> {
|
): Promise<Output<Relationship>> {
|
||||||
return this.post<Relationship>(
|
return this.post<Relationship>(
|
||||||
`/api/v1/accounts/${id}/mute`,
|
`/api/v1/accounts/${id}/mute`,
|
||||||
{ ...options },
|
options,
|
||||||
extra,
|
extra,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -2063,7 +2123,7 @@ export class Client extends BaseClient {
|
||||||
): Promise<Output<Status>> {
|
): Promise<Output<Status>> {
|
||||||
return this.post<Status>(
|
return this.post<Status>(
|
||||||
`/api/v1/statuses/${id}/reblog`,
|
`/api/v1/statuses/${id}/reblog`,
|
||||||
{ ...options },
|
options,
|
||||||
extra,
|
extra,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -2470,6 +2530,26 @@ export class Client extends BaseClient {
|
||||||
|
|
||||||
// TODO: tagStreaming
|
// TODO: tagStreaming
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DELETE /api/v1/accounts/:account_id/roles/:role_id
|
||||||
|
*
|
||||||
|
* Versia API only.
|
||||||
|
* @param account_id Account ID to remove the role from.
|
||||||
|
* @param role_id Role ID to remove from the account.
|
||||||
|
* @returns No content.
|
||||||
|
*/
|
||||||
|
public unassignRole(
|
||||||
|
account_id: string,
|
||||||
|
role_id: string,
|
||||||
|
extra?: RequestInit,
|
||||||
|
): Promise<Output<void>> {
|
||||||
|
return this.delete<void>(
|
||||||
|
`/api/v1/accounts/${account_id}/roles/${role_id}`,
|
||||||
|
undefined,
|
||||||
|
extra,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* POST /api/v1/accounts/:id/unblock
|
* POST /api/v1/accounts/:id/unblock
|
||||||
*
|
*
|
||||||
|
|
@ -2663,6 +2743,7 @@ export class Client extends BaseClient {
|
||||||
/**
|
/**
|
||||||
* PATCH /api/v1/emojis/:id
|
* PATCH /api/v1/emojis/:id
|
||||||
*
|
*
|
||||||
|
* Versia API only.
|
||||||
* @param id Target emoji ID.
|
* @param id Target emoji ID.
|
||||||
* @param options.shortcode Emoji shortcode.
|
* @param options.shortcode Emoji shortcode.
|
||||||
* @param options.image Emoji image, as a File, or a URL.
|
* @param options.image Emoji image, as a File, or a URL.
|
||||||
|
|
@ -2716,7 +2797,7 @@ export class Client extends BaseClient {
|
||||||
},
|
},
|
||||||
extra?: RequestInit,
|
extra?: RequestInit,
|
||||||
): Promise<Output<List>> {
|
): Promise<Output<List>> {
|
||||||
return this.put<List>(`/api/v1/lists/${id}`, { ...options }, extra);
|
return this.put<List>(`/api/v1/lists/${id}`, options, extra);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -2787,9 +2868,38 @@ export class Client extends BaseClient {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PATCH /api/v1/roles/:id
|
||||||
|
*
|
||||||
|
* Versia API only.
|
||||||
|
* @param id Role ID to update.
|
||||||
|
* @param options.name New role name.
|
||||||
|
* @param options.permissions New role permissions.
|
||||||
|
* @param options.priority New role priority.
|
||||||
|
* @param options.description New role description.
|
||||||
|
* @param options.visible New role visibility.
|
||||||
|
* @param options.icon New role icon.
|
||||||
|
* @returns New role data.
|
||||||
|
*/
|
||||||
|
public updateRole(
|
||||||
|
id: string,
|
||||||
|
options: Partial<{
|
||||||
|
name: string;
|
||||||
|
permissions: string[];
|
||||||
|
priority: number;
|
||||||
|
description: string;
|
||||||
|
visible: boolean;
|
||||||
|
icon: string;
|
||||||
|
}>,
|
||||||
|
extra?: RequestInit,
|
||||||
|
): Promise<Output<VersiaRole>> {
|
||||||
|
return this.patch<VersiaRole>(`/api/v1/roles/${id}`, options, extra);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* POST /api/v1/emojis
|
* POST /api/v1/emojis
|
||||||
*
|
*
|
||||||
|
* Versia API only.
|
||||||
* @param shortcode The shortcode of the emoji.
|
* @param shortcode The shortcode of the emoji.
|
||||||
* @param image The image file to be uploaded, as a File or URL.
|
* @param image The image file to be uploaded, as a File or URL.
|
||||||
* @param options.category A category for the emoji.
|
* @param options.category A category for the emoji.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue