Documentation
¶
Overview ¶
Package models defines the shared entity and API types used by the Uncord server and clients. Both Go and TypeScript implementations import these types as the single source of truth for API request and response shapes.
Index ¶
- type AuthResponse
- type Category
- type Channel
- type CreateCategoryRequest
- type CreateChannelRequest
- type CreateRoleRequest
- type DeleteAccountRequest
- type LoginRequest
- type MFAConfirmRequest
- type MFAConfirmResponse
- type MFADisableRequest
- type MFAEnableRequest
- type MFARegenerateCodesRequest
- type MFARegenerateCodesResponse
- type MFARequiredResponse
- type MFASetupResponse
- type MFAVerifyRequest
- type MessageResponse
- type RefreshRequest
- type RegisterRequest
- type Role
- type ServerConfig
- type TokenPairResponse
- type UpdateCategoryRequest
- type UpdateChannelRequest
- type UpdateRoleRequest
- type UpdateServerConfigRequest
- type UpdateUserRequest
- type User
- type VerifyEmailRequest
- type VerifyPasswordRequest
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuthResponse ¶
type AuthResponse struct {
User User `json:"user"`
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token"`
}
AuthResponse is the response body for register and login endpoints.
type Category ¶ added in v0.2.3
type Category struct {
ID string `json:"id"`
Name string `json:"name"`
Position int `json:"position"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
Category represents a channel category returned by the API.
type Channel ¶ added in v0.2.3
type Channel struct {
ID string `json:"id"`
CategoryID *string `json:"category_id"`
Name string `json:"name"`
Type string `json:"type"`
Topic string `json:"topic"`
Position int `json:"position"`
SlowmodeSeconds int `json:"slowmode_seconds"`
NSFW bool `json:"nsfw"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
Channel represents a channel returned by the API.
type CreateCategoryRequest ¶ added in v0.2.3
type CreateCategoryRequest struct {
Name string `json:"name"`
}
CreateCategoryRequest is the body for POST /api/v1/server/categories.
type CreateChannelRequest ¶ added in v0.2.3
type CreateChannelRequest struct {
Name string `json:"name"`
Type *string `json:"type"`
CategoryID *string `json:"category_id"`
Topic *string `json:"topic"`
SlowmodeSeconds *int `json:"slowmode_seconds"`
NSFW *bool `json:"nsfw"`
}
CreateChannelRequest is the body for POST /api/v1/server/channels.
type CreateRoleRequest ¶ added in v0.2.6
type CreateRoleRequest struct {
Name string `json:"name"`
Colour *int `json:"colour"`
Permissions *int64 `json:"permissions"`
Hoist *bool `json:"hoist"`
}
CreateRoleRequest is the body for POST /api/v1/server/roles.
type DeleteAccountRequest ¶ added in v0.2.5
type DeleteAccountRequest struct {
Password string `json:"password"`
}
DeleteAccountRequest is the JSON body for DELETE /api/v1/users/@me. The authenticated user's password is required to confirm the irreversible account deletion.
type LoginRequest ¶
LoginRequest is the JSON body for POST /api/v1/auth/login.
type MFAConfirmRequest ¶ added in v0.2.4
type MFAConfirmRequest struct {
Code string `json:"code"`
}
MFAConfirmRequest is the JSON body for POST /api/v1/users/@me/mfa/confirm. The code is a six-digit TOTP code from the user's authenticator app, proving they successfully saved the secret.
type MFAConfirmResponse ¶ added in v0.2.4
type MFAConfirmResponse struct {
RecoveryCodes []string `json:"recovery_codes"`
}
MFAConfirmResponse is the response for the MFA confirm endpoint, containing the one-time-use recovery codes that the user must store securely.
type MFADisableRequest ¶ added in v0.2.4
MFADisableRequest is the JSON body for POST /api/v1/users/@me/mfa/disable. Both password and a valid TOTP code are required to disable MFA.
type MFAEnableRequest ¶ added in v0.2.4
type MFAEnableRequest struct {
Password string `json:"password"`
}
MFAEnableRequest is the JSON body for POST /api/v1/users/@me/mfa/enable. The password field confirms the user's identity before generating TOTP credentials.
type MFARegenerateCodesRequest ¶ added in v0.2.4
type MFARegenerateCodesRequest struct {
Password string `json:"password"`
}
MFARegenerateCodesRequest is the JSON body for POST /api/v1/users/@me/mfa/recovery-codes.
type MFARegenerateCodesResponse ¶ added in v0.2.4
type MFARegenerateCodesResponse struct {
RecoveryCodes []string `json:"recovery_codes"`
}
MFARegenerateCodesResponse is the response for the recovery code regeneration endpoint.
type MFARequiredResponse ¶ added in v0.2.4
type MFARequiredResponse struct {
MFARequired bool `json:"mfa_required"`
Ticket string `json:"ticket"`
}
MFARequiredResponse is the response when login succeeds but MFA verification is needed. The ticket is a single-use opaque token that the client must present to the MFA verify endpoint.
type MFASetupResponse ¶ added in v0.2.4
MFASetupResponse is the response for the MFA enable endpoint, containing the TOTP secret and provisioning URI for authenticator app registration.
type MFAVerifyRequest ¶ added in v0.2.4
MFAVerifyRequest is the JSON body for POST /api/v1/auth/mfa/verify.
type MessageResponse ¶
type MessageResponse struct {
Message string `json:"message"`
}
MessageResponse is a generic response containing a status message.
type RefreshRequest ¶
type RefreshRequest struct {
RefreshToken string `json:"refresh_token"`
}
RefreshRequest is the JSON body for POST /api/v1/auth/refresh.
type RegisterRequest ¶
type RegisterRequest struct {
Email string `json:"email"`
Username string `json:"username"`
Password string `json:"password"`
}
RegisterRequest is the JSON body for POST /api/v1/auth/register.
type Role ¶ added in v0.2.6
type Role struct {
ID string `json:"id"`
Name string `json:"name"`
Colour int `json:"colour"`
Position int `json:"position"`
Hoist bool `json:"hoist"`
Permissions int64 `json:"permissions"`
IsEveryone bool `json:"is_everyone"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
Role represents a server role returned by the API.
type ServerConfig ¶ added in v0.2.2
type ServerConfig struct {
ID string `json:"id"`
Name string `json:"name"`
Description string `json:"description"`
IconKey *string `json:"icon_key"`
BannerKey *string `json:"banner_key"`
OwnerID string `json:"owner_id"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
ServerConfig represents the server configuration returned by the API.
type TokenPairResponse ¶
type TokenPairResponse struct {
AccessToken string `json:"access_token"`
RefreshToken string `json:"refresh_token"`
}
TokenPairResponse is the response body for the refresh endpoint.
type UpdateCategoryRequest ¶ added in v0.2.3
UpdateCategoryRequest is the body for PATCH /api/v1/categories/:categoryID.
type UpdateChannelRequest ¶ added in v0.2.3
type UpdateChannelRequest struct {
Name *string `json:"name"`
CategoryID *string `json:"category_id"`
Topic *string `json:"topic"`
Position *int `json:"position"`
SlowmodeSeconds *int `json:"slowmode_seconds"`
NSFW *bool `json:"nsfw"`
}
UpdateChannelRequest is the body for PATCH /api/v1/channels/:channelID.
type UpdateRoleRequest ¶ added in v0.2.6
type UpdateRoleRequest struct {
Name *string `json:"name"`
Colour *int `json:"colour"`
Position *int `json:"position"`
Permissions *int64 `json:"permissions"`
Hoist *bool `json:"hoist"`
}
UpdateRoleRequest is the body for PATCH /api/v1/server/roles/:roleID.
type UpdateServerConfigRequest ¶ added in v0.2.2
type UpdateServerConfigRequest struct {
Name *string `json:"name"`
Description *string `json:"description"`
IconKey *string `json:"icon_key"`
BannerKey *string `json:"banner_key"`
}
UpdateServerConfigRequest is the body for PATCH /api/v1/server.
type UpdateUserRequest ¶ added in v0.2.2
type UpdateUserRequest struct {
DisplayName *string `json:"display_name"`
AvatarKey *string `json:"avatar_key"`
Pronouns *string `json:"pronouns"`
BannerKey *string `json:"banner_key"`
About *string `json:"about"`
ThemeColourPrimary *int `json:"theme_colour_primary"`
ThemeColourSecondary *int `json:"theme_colour_secondary"`
}
UpdateUserRequest is the body for PATCH /api/v1/users/@me.
type User ¶
type User struct {
ID string `json:"id"`
Email string `json:"email"`
Username string `json:"username"`
DisplayName *string `json:"display_name"`
AvatarKey *string `json:"avatar_key"`
Pronouns *string `json:"pronouns"`
BannerKey *string `json:"banner_key"`
About *string `json:"about"`
ThemeColourPrimary *int `json:"theme_colour_primary"`
ThemeColourSecondary *int `json:"theme_colour_secondary"`
MFAEnabled bool `json:"mfa_enabled"`
EmailVerified bool `json:"email_verified"`
}
User represents the public user profile returned by the API.
type VerifyEmailRequest ¶
type VerifyEmailRequest struct {
Token string `json:"token"`
}
VerifyEmailRequest is the JSON body for POST /api/v1/auth/verify-email.
type VerifyPasswordRequest ¶ added in v0.2.4
type VerifyPasswordRequest struct {
Password string `json:"password"`
}
VerifyPasswordRequest is the JSON body for POST /api/v1/auth/verify-password. The authenticated user's password is verified without performing any other action, allowing clients to gate sensitive workflows behind a password prompt.