mirror of
https://github.com/modrinth/code.git
synced 2026-08-31 03:55:59 +00:00
Merge branch 'main' into boris/dev-1126-v2
This commit is contained in:
@@ -3,6 +3,7 @@ export * from './backups/v1'
|
||||
export * from './backups-queue/v1'
|
||||
export * from './content/v1'
|
||||
export * from './properties/v1'
|
||||
export * from './servers/internal'
|
||||
export * from './servers/v0'
|
||||
export * from './servers/v1'
|
||||
export * from './types'
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
import { AbstractModule } from '../../../core/abstract-module'
|
||||
import type { Archon } from '../types'
|
||||
|
||||
export class ArchonServersInternalModule extends AbstractModule {
|
||||
public getModuleID(): string {
|
||||
return 'archon_servers_internal'
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the server assigned to a subdomain.
|
||||
* GET /_internal/servers/by-subdomain/:subdomain
|
||||
*/
|
||||
public async getBySubdomain(subdomain: string): Promise<Archon.Servers.Internal.Lookup> {
|
||||
return this.client.request<Archon.Servers.Internal.Lookup>(
|
||||
`/servers/by-subdomain/${encodeURIComponent(subdomain)}`,
|
||||
{
|
||||
api: 'archon',
|
||||
version: 'internal',
|
||||
method: 'GET',
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -573,6 +573,12 @@ export namespace Archon {
|
||||
}
|
||||
|
||||
export namespace Servers {
|
||||
export namespace Internal {
|
||||
export type Lookup = {
|
||||
id: string
|
||||
}
|
||||
}
|
||||
|
||||
export namespace v0 {
|
||||
export type ServerGetResponse = {
|
||||
servers: Server[]
|
||||
|
||||
@@ -9,6 +9,7 @@ import { ArchonNoticesV0Module } from './archon/notices/v0'
|
||||
import { ArchonOptionsV1Module } from './archon/options/v1'
|
||||
import { ArchonPropertiesV1Module } from './archon/properties/v1'
|
||||
import { ArchonServerUsersV1Module } from './archon/server-users/v1'
|
||||
import { ArchonServersInternalModule } from './archon/servers/internal'
|
||||
import { ArchonServersV0Module } from './archon/servers/v0'
|
||||
import { ArchonServersV1Module } from './archon/servers/v1'
|
||||
import { ArchonTransfersInternalModule } from './archon/transfers/internal'
|
||||
@@ -87,6 +88,7 @@ export const MODULE_REGISTRY = {
|
||||
archon_options_v1: ArchonOptionsV1Module,
|
||||
archon_properties_v1: ArchonPropertiesV1Module,
|
||||
archon_server_users_v1: ArchonServerUsersV1Module,
|
||||
archon_servers_internal: ArchonServersInternalModule,
|
||||
archon_servers_v0: ArchonServersV0Module,
|
||||
archon_servers_v1: ArchonServersV1Module,
|
||||
archon_transfers_internal: ArchonTransfersInternalModule,
|
||||
|
||||
@@ -1355,8 +1355,8 @@ export namespace Labrinth {
|
||||
}
|
||||
|
||||
export type ProjectDisclosureData = ProjectDisclosure & {
|
||||
set_by_moderator: boolean
|
||||
lock_status: DisclosureLockStatus
|
||||
set_by_moderator?: boolean | null
|
||||
lock_status?: DisclosureLockStatus | null
|
||||
updated_at: string
|
||||
updated_by?: string | null
|
||||
deleted_at?: string | null
|
||||
@@ -1713,6 +1713,70 @@ export namespace Labrinth {
|
||||
export type Role = Common.Role
|
||||
export type AuthProvider = Common.AuthProvider
|
||||
export type UserPayoutData = Common.UserPayoutData
|
||||
export type Theme = 'light' | 'dark' | 'oled' | 'retro'
|
||||
export type LayoutOption = 'grid' | 'rows'
|
||||
export type FriendPrivacy = 'none' | 'mutual' | 'everyone'
|
||||
export type InvitePrivacy = 'none' | 'friends' | 'everyone'
|
||||
|
||||
export type AppearancePreferences = {
|
||||
auto: boolean
|
||||
theme: Theme
|
||||
}
|
||||
|
||||
export type BehaviorPreferences = {
|
||||
minimize_app: boolean
|
||||
hide_right_sidebar: boolean
|
||||
show_jump_in: boolean
|
||||
compact_instance_cards: boolean
|
||||
show_play_time: boolean
|
||||
hide_nametag: boolean
|
||||
warn_on_unknown_modpacks: boolean
|
||||
skip_non_essential_warnings: boolean
|
||||
}
|
||||
|
||||
export type LocalizationPreferences = {
|
||||
locale: string
|
||||
}
|
||||
|
||||
export type LayoutPreferences = {
|
||||
mods: LayoutOption
|
||||
plugins: LayoutOption
|
||||
datapacks: LayoutOption
|
||||
shaders: LayoutOption
|
||||
resourcepacks: LayoutOption
|
||||
modpacks: LayoutOption
|
||||
servers: LayoutOption
|
||||
users: LayoutOption
|
||||
}
|
||||
|
||||
export type SidebarPreferences = {
|
||||
right_aligned_search: boolean
|
||||
left_aligned_content: boolean
|
||||
}
|
||||
|
||||
export type SocialPreferences = {
|
||||
friend_privacy: FriendPrivacy
|
||||
shared_instances_privacy: InvitePrivacy
|
||||
hosting_access_privacy: InvitePrivacy
|
||||
}
|
||||
|
||||
export type UserPreferences = {
|
||||
appearance: AppearancePreferences
|
||||
behavior: BehaviorPreferences
|
||||
localization: LocalizationPreferences
|
||||
layouts: LayoutPreferences
|
||||
sidebars: SidebarPreferences
|
||||
social: SocialPreferences
|
||||
}
|
||||
|
||||
export type PartialUserPreferences = {
|
||||
appearance?: Partial<AppearancePreferences>
|
||||
behavior?: Partial<BehaviorPreferences>
|
||||
localization?: Partial<LocalizationPreferences>
|
||||
layouts?: Partial<LayoutPreferences>
|
||||
sidebars?: Partial<SidebarPreferences>
|
||||
social?: Partial<SocialPreferences>
|
||||
}
|
||||
|
||||
export type Pride26CampaignDonation = {
|
||||
last_donated_at: string
|
||||
@@ -1887,6 +1951,7 @@ export namespace Labrinth {
|
||||
license: string
|
||||
client_side: string
|
||||
server_side: string
|
||||
disclosure_types: string[]
|
||||
gallery: string[]
|
||||
featured_gallery: string | null
|
||||
color: number | null
|
||||
@@ -1902,7 +1967,7 @@ export namespace Labrinth {
|
||||
|
||||
export namespace v3 {
|
||||
export interface ResultSearchProject {
|
||||
version_id: string
|
||||
version_id?: string
|
||||
project_id: string
|
||||
project_types: string[]
|
||||
all_project_types: string[]
|
||||
@@ -1932,6 +1997,7 @@ export namespace Labrinth {
|
||||
minecraft_java_server?: Projects.v3.MinecraftJavaServer | null
|
||||
minecraft_bedrock_server?: Projects.v3.MinecraftBedrockServer | null
|
||||
minecraft_mod?: unknown | null
|
||||
disclosure_types: string[]
|
||||
}
|
||||
|
||||
export interface SearchResults {
|
||||
|
||||
@@ -37,6 +37,43 @@ export class LabrinthUsersV3Module extends AbstractModule {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a user's account preferences. The authenticated user may access their
|
||||
* own preferences, while moderators may access another user's preferences.
|
||||
*
|
||||
* GET /v3/user/{id}/preferences
|
||||
*/
|
||||
public async getPreferences(idOrUsername: string): Promise<Labrinth.Users.v3.UserPreferences> {
|
||||
return this.client.request<Labrinth.Users.v3.UserPreferences>(
|
||||
`/user/${encodeURIComponent(idOrUsername)}/preferences`,
|
||||
{
|
||||
api: 'labrinth',
|
||||
version: 3,
|
||||
method: 'GET',
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a user's account preferences and return the fully resolved result.
|
||||
*
|
||||
* PATCH /v3/user/{id}/preferences
|
||||
*/
|
||||
public async patchPreferences(
|
||||
idOrUsername: string,
|
||||
preferences: Labrinth.Users.v3.PartialUserPreferences,
|
||||
): Promise<Labrinth.Users.v3.UserPreferences> {
|
||||
return this.client.request<Labrinth.Users.v3.UserPreferences>(
|
||||
`/user/${encodeURIComponent(idOrUsername)}/preferences`,
|
||||
{
|
||||
api: 'labrinth',
|
||||
version: 3,
|
||||
method: 'PATCH',
|
||||
body: preferences,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Search users by username prefix.
|
||||
*
|
||||
@@ -56,6 +93,54 @@ export class LabrinthUsersV3Module extends AbstractModule {
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a user's projects.
|
||||
*
|
||||
* @param idOrUsername - The user's ID or username
|
||||
* @returns Promise resolving to an array of the user's projects
|
||||
*
|
||||
* GET /v3/user/{id}/projects
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const projects = await client.labrinth.users_v3.getProjects('my_user')
|
||||
* ```
|
||||
*/
|
||||
public async getProjects(idOrUsername: string): Promise<Labrinth.Projects.v3.Project[]> {
|
||||
return this.client.request<Labrinth.Projects.v3.Project[]>(
|
||||
`/user/${encodeURIComponent(idOrUsername)}/projects`,
|
||||
{
|
||||
api: 'labrinth',
|
||||
version: 3,
|
||||
method: 'GET',
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get projects a user follows.
|
||||
*
|
||||
* @param idOrUsername - The user's ID or username
|
||||
* @returns Promise resolving to an array of followed projects
|
||||
*
|
||||
* GET /v3/user/{id}/follows
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const projects = await client.labrinth.users_v3.getFollowedProjects('my_user')
|
||||
* ```
|
||||
*/
|
||||
public async getFollowedProjects(idOrUsername: string): Promise<Labrinth.Projects.v3.Project[]> {
|
||||
return this.client.request<Labrinth.Projects.v3.Project[]>(
|
||||
`/user/${encodeURIComponent(idOrUsername)}/follows`,
|
||||
{
|
||||
api: 'labrinth',
|
||||
version: 3,
|
||||
method: 'GET',
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all projects the authenticated user can access directly or through
|
||||
* their organizations.
|
||||
|
||||
Reference in New Issue
Block a user