/**
* Generated by orval v7.2.0 🍺
* Do not edit manually.
* storyden
* Storyden social API for building community driven platforms.
The Storyden API does not adhere to semantic versioning but instead applies a rolling strategy with deprecations and minimal breaking changes. This has been done mainly for a simpler development process and it may be changed to a more fixed versioning strategy in the future. Ultimately, the primary way Storyden tracks versions is dates, there are no set release tags currently.
* OpenAPI spec version: v1.26.2-canary
*/
import type {
AccountGetOKResponse,
AdminAccessKeyListOKResponse,
AdminSettingsGetOKResponse,
AdminSettingsUpdateBody,
AdminSettingsUpdateOKResponse,
AuditEventCreatedOKResponse,
AuditEventGetOKResponse,
AuditEventListOKResponse,
AuditEventListParams,
ModerationActionCreateBody,
NoContentResponse,
} from "../openapi-schema";
import { fetcher } from "../server";
/**
* Retrieve all configuration settings for installation. This includes the
publicly accessible information for the instance as well as admin-only
access to sensitive configuration (environment variables) and settings.
*/
export type adminSettingsGetResponse = {
data: AdminSettingsGetOKResponse;
status: number;
};
export const getAdminSettingsGetUrl = () => {
return `/admin`;
};
export const adminSettingsGet = async (
options?: RequestInit,
): Promise<adminSettingsGetResponse> => {
return fetcher<Promise<adminSettingsGetResponse>>(getAdminSettingsGetUrl(), {
...options,
method: "GET",
});
};
/**
* Update non-env configuration settings for installation.
*/
export type adminSettingsUpdateResponse = {
data: AdminSettingsUpdateOKResponse;
status: number;
};
export const getAdminSettingsUpdateUrl = () => {
return `/admin`;
};
export const adminSettingsUpdate = async (
adminSettingsUpdateBody: AdminSettingsUpdateBody,
options?: RequestInit,
): Promise<adminSettingsUpdateResponse> => {
return fetcher<Promise<adminSettingsUpdateResponse>>(
getAdminSettingsUpdateUrl(),
{
...options,
method: "PATCH",
headers: { "Content-Type": "application/json", ...options?.headers },
body: JSON.stringify(adminSettingsUpdateBody),
},
);
};
/**
* List audit events for the installation. Audit events track important
actions taken by accounts with elevated permissions such as admin
accounts and moderators. It also provides error logs for system internal
components that could not be responded to the client directly such as
background job failures and configuration issues.
*/
export type auditEventListResponse = {
data: AuditEventListOKResponse;
status: number;
};
export const getAuditEventListUrl = (params?: AuditEventListParams) => {
const normalizedParams = new URLSearchParams();
Object.entries(params || {}).forEach(([key, value]) => {
const explodeParameters = ["types"];
if (value instanceof Array && explodeParameters.includes(key)) {
value.forEach((v) =>
normalizedParams.append(key, v === null ? "null" : v.toString()),
);
return;
}
if (value !== undefined) {
normalizedParams.append(key, value === null ? "null" : value.toString());
}
});
return normalizedParams.size
? `/admin/audit-events?${normalizedParams.toString()}`
: `/admin/audit-events`;
};
export const auditEventList = async (
params?: AuditEventListParams,
options?: RequestInit,
): Promise<auditEventListResponse> => {
return fetcher<Promise<auditEventListResponse>>(
getAuditEventListUrl(params),
{
...options,
method: "GET",
},
);
};
/**
* Retrieve a specific audit event by ID.
*/
export type auditEventGetResponse = {
data: AuditEventGetOKResponse;
status: number;
};
export const getAuditEventGetUrl = (auditEventId: string) => {
return `/admin/audit-events/${auditEventId}`;
};
export const auditEventGet = async (
auditEventId: string,
options?: RequestInit,
): Promise<auditEventGetResponse> => {
return fetcher<Promise<auditEventGetResponse>>(
getAuditEventGetUrl(auditEventId),
{
...options,
method: "GET",
},
);
};
/**
* Create a new moderation action such as a ban or content purge.
*/
export type moderationActionCreateResponse = {
data: AuditEventCreatedOKResponse;
status: number;
};
export const getModerationActionCreateUrl = () => {
return `/admin/actions`;
};
export const moderationActionCreate = async (
moderationActionCreateBody: ModerationActionCreateBody,
options?: RequestInit,
): Promise<moderationActionCreateResponse> => {
return fetcher<Promise<moderationActionCreateResponse>>(
getModerationActionCreateUrl(),
{
...options,
method: "POST",
headers: { "Content-Type": "application/json", ...options?.headers },
body: JSON.stringify(moderationActionCreateBody),
},
);
};
/**
* Suspend an account - soft delete. This disables the ability for the
account owner to log in and use the platform. It keeps the account on
record for linkage to content so UI doesn't break. It does not change
anything else about the account such as the avatar, name, etc.
*/
export type adminAccountBanCreateResponse = {
data: AccountGetOKResponse;
status: number;
};
export const getAdminAccountBanCreateUrl = (accountHandle: string) => {
return `/admin/bans/${accountHandle}`;
};
export const adminAccountBanCreate = async (
accountHandle: string,
options?: RequestInit,
): Promise<adminAccountBanCreateResponse> => {
return fetcher<Promise<adminAccountBanCreateResponse>>(
getAdminAccountBanCreateUrl(accountHandle),
{
...options,
method: "POST",
},
);
};
/**
* Given the account is suspended, remove the suspended state.
*/
export type adminAccountBanRemoveResponse = {
data: AccountGetOKResponse;
status: number;
};
export const getAdminAccountBanRemoveUrl = (accountHandle: string) => {
return `/admin/bans/${accountHandle}`;
};
export const adminAccountBanRemove = async (
accountHandle: string,
options?: RequestInit,
): Promise<adminAccountBanRemoveResponse> => {
return fetcher<Promise<adminAccountBanRemoveResponse>>(
getAdminAccountBanRemoveUrl(accountHandle),
{
...options,
method: "DELETE",
},
);
};
/**
* List all access keys for the entire instance. This is only available to
admin accounts and is used to manage access keys from other accounts.
*/
export type adminAccessKeyListResponse = {
data: AdminAccessKeyListOKResponse;
status: number;
};
export const getAdminAccessKeyListUrl = () => {
return `/admin/access-keys`;
};
export const adminAccessKeyList = async (
options?: RequestInit,
): Promise<adminAccessKeyListResponse> => {
return fetcher<Promise<adminAccessKeyListResponse>>(
getAdminAccessKeyListUrl(),
{
...options,
method: "GET",
},
);
};
/**
* Revoke an access key. This will immediately invalidate the key and it
will no longer be usable for authentication.
*/
export type adminAccessKeyDeleteResponse = {
data: NoContentResponse;
status: number;
};
export const getAdminAccessKeyDeleteUrl = (accessKeyId: string) => {
return `/admin/access-keys/${accessKeyId}`;
};
export const adminAccessKeyDelete = async (
accessKeyId: string,
options?: RequestInit,
): Promise<adminAccessKeyDeleteResponse> => {
return fetcher<Promise<adminAccessKeyDeleteResponse>>(
getAdminAccessKeyDeleteUrl(accessKeyId),
{
...options,
method: "DELETE",
},
);
};