mirror of
https://github.com/modrinth/code.git
synced 2026-08-31 03:55:59 +00:00
Merge branch 'main' into truman/new-server-card-states
This commit is contained in:
@@ -126,6 +126,7 @@ export abstract class AbstractModrinthClient extends AbstractUploadClient {
|
||||
...options.headers,
|
||||
},
|
||||
}
|
||||
this.attachArchonSentryCaptureHeader(mergedOptions)
|
||||
|
||||
const headers = mergedOptions.headers
|
||||
if (headers && 'Content-Type' in headers && headers['Content-Type'] === '') {
|
||||
@@ -309,6 +310,21 @@ export abstract class AbstractModrinthClient extends AbstractUploadClient {
|
||||
return headers
|
||||
}
|
||||
|
||||
protected attachArchonSentryCaptureHeader(options: RequestOptions): void {
|
||||
if (options.api !== 'archon' || !options.headers || !this.shouldCaptureArchonRequests()) {
|
||||
return
|
||||
}
|
||||
|
||||
options.headers['modrinth-sentry-capture'] = '1'
|
||||
}
|
||||
|
||||
private shouldCaptureArchonRequests(): boolean {
|
||||
const archonSentryCapture = this.config.archonSentryCapture
|
||||
return typeof archonSentryCapture === 'function'
|
||||
? archonSentryCapture()
|
||||
: archonSentryCapture === true
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the actual HTTP request
|
||||
*
|
||||
|
||||
@@ -54,4 +54,16 @@ export class ArchonServersV1Module extends AbstractModule {
|
||||
method: 'DELETE',
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset a world to onboarding
|
||||
* POST /v1/servers/:id/worlds/:wid/onboard
|
||||
*/
|
||||
public async resetToOnboarding(serverId: string, worldId: string): Promise<void> {
|
||||
await this.client.request(`/servers/${serverId}/worlds/${worldId}/onboard`, {
|
||||
api: 'archon',
|
||||
version: 1,
|
||||
method: 'POST',
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,8 @@ export namespace Archon {
|
||||
disabled: boolean
|
||||
kind: AddonKind
|
||||
from_modpack: boolean
|
||||
pack_client_retained: boolean
|
||||
pack_client_depends: boolean
|
||||
has_update: string | null
|
||||
name: string | null
|
||||
project_id: string | null
|
||||
@@ -68,12 +70,21 @@ export namespace Archon {
|
||||
| 'purpur'
|
||||
| 'vanilla'
|
||||
|
||||
export type ModpackSpec = {
|
||||
export type ModpackSpecModrinth = {
|
||||
platform: 'modrinth'
|
||||
project_id: string
|
||||
version_id: string
|
||||
}
|
||||
|
||||
export type ModpackSpecLocalFile = {
|
||||
platform: 'local_file'
|
||||
filename: string
|
||||
name: string
|
||||
description: string | null
|
||||
}
|
||||
|
||||
export type ModpackSpec = ModpackSpecModrinth | ModpackSpecLocalFile
|
||||
|
||||
export type ModpackOwner = {
|
||||
id: string
|
||||
name: string
|
||||
|
||||
@@ -14,18 +14,18 @@ import { LabrinthAffiliateInternalModule } from './labrinth/affiliate/internal'
|
||||
import { LabrinthAuthInternalModule } from './labrinth/auth/internal'
|
||||
import { LabrinthAuthV2Module } from './labrinth/auth/v2'
|
||||
import { LabrinthBillingInternalModule } from './labrinth/billing/internal'
|
||||
import { LabrinthCollectionsModule } from './labrinth/collections'
|
||||
import { LabrinthGlobalsInternalModule } from './labrinth/globals/internal'
|
||||
import { LabrinthLimitsV3Module } from './labrinth/limits/v3'
|
||||
import { LabrinthNotificationsV2Module } from './labrinth/notifications/v2'
|
||||
import { LabrinthOAuthInternalModule } from './labrinth/oauth/internal'
|
||||
import { LabrinthCollectionsModule } from './labrinth/collections'
|
||||
import { LabrinthOrganizationsV3Module } from './labrinth/organizations/v3'
|
||||
import { LabrinthPatsV2Module } from './labrinth/pats/v2'
|
||||
import { LabrinthLimitsV3Module } from './labrinth/limits/v3'
|
||||
import { LabrinthPayoutV3Module } from './labrinth/payout/v3'
|
||||
import { LabrinthPayoutsV3Module } from './labrinth/payouts/v3'
|
||||
import { LabrinthReportsV3Module } from './labrinth/reports/v3'
|
||||
import { LabrinthProjectsV2Module } from './labrinth/projects/v2'
|
||||
import { LabrinthProjectsV3Module } from './labrinth/projects/v3'
|
||||
import { LabrinthReportsV3Module } from './labrinth/reports/v3'
|
||||
import { LabrinthServerPingInternalModule } from './labrinth/server-ping/internal'
|
||||
import { LabrinthSessionsV2Module } from './labrinth/sessions/v2'
|
||||
import { LabrinthStateModule } from './labrinth/state'
|
||||
|
||||
@@ -3,11 +3,11 @@ export * from './auth/v2'
|
||||
export * from './billing/internal'
|
||||
export * from './collections'
|
||||
export * from './globals/internal'
|
||||
export * from './limits/v3'
|
||||
export * from './notifications/v2'
|
||||
export * from './oauth/internal'
|
||||
export * from './organizations/v3'
|
||||
export * from './pats/v2'
|
||||
export * from './limits/v3'
|
||||
export * from './payout/v3'
|
||||
export * from './payouts/v3'
|
||||
export * from './projects/v2'
|
||||
|
||||
@@ -593,6 +593,7 @@ export namespace Labrinth {
|
||||
categories: string[]
|
||||
additional_categories: string[]
|
||||
loaders: string[]
|
||||
mrpack_loaders: string[]
|
||||
versions: string[]
|
||||
icon_url?: string
|
||||
link_urls: Record<string, Link>
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
export namespace Paper {
|
||||
export namespace Versions {
|
||||
export namespace v3 {
|
||||
export type Project = {
|
||||
project: { id: string; name: string }
|
||||
versions: Record<string, string[]>
|
||||
}
|
||||
|
||||
export type VersionBuilds = {
|
||||
builds: number[]
|
||||
}
|
||||
|
||||
@@ -12,6 +12,13 @@ export class PaperVersionsV3Module extends AbstractModule {
|
||||
return 'paper_versions_v3'
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Paper project info including all supported Minecraft versions.
|
||||
*/
|
||||
public async getProject(): Promise<Paper.Versions.v3.Project> {
|
||||
return $fetch<Paper.Versions.v3.Project>(`${BASE_URL}/projects/paper`)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get available Paper builds for a Minecraft version.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
export namespace Purpur {
|
||||
export namespace Versions {
|
||||
export namespace v2 {
|
||||
export type Project = {
|
||||
project: string
|
||||
versions: string[]
|
||||
}
|
||||
|
||||
export type VersionBuilds = {
|
||||
builds: {
|
||||
all: string[]
|
||||
|
||||
@@ -12,6 +12,13 @@ export class PurpurVersionsV2Module extends AbstractModule {
|
||||
return 'purpur_versions_v2'
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Purpur project info including all supported Minecraft versions.
|
||||
*/
|
||||
public async getProject(): Promise<Purpur.Versions.v2.Project> {
|
||||
return $fetch<Purpur.Versions.v2.Project>(`${BASE_URL}/purpur`)
|
||||
}
|
||||
|
||||
/**
|
||||
* Get available Purpur builds for a Minecraft version.
|
||||
*
|
||||
|
||||
@@ -46,6 +46,7 @@ export abstract class XHRUploadClient extends AbstractModrinthClient {
|
||||
...options.headers,
|
||||
},
|
||||
}
|
||||
this.attachArchonSentryCaptureHeader(mergedOptions)
|
||||
|
||||
const context = this.buildUploadContext(url, path, mergedOptions)
|
||||
|
||||
|
||||
@@ -55,6 +55,14 @@ export interface ClientConfig {
|
||||
*/
|
||||
headers?: Record<string, string>
|
||||
|
||||
/**
|
||||
* Whether to attach `modrinth-sentry-capture: 1` to Archon requests.
|
||||
* Can be a callback so apps can drive this from runtime feature flags.
|
||||
*
|
||||
* @default false
|
||||
*/
|
||||
archonSentryCapture?: boolean | (() => boolean)
|
||||
|
||||
/**
|
||||
* Features to enable for this client
|
||||
* Features are applied in the order they appear in this array
|
||||
|
||||
@@ -11,4 +11,10 @@ export type { ClientConfig, RequestHooks } from './client'
|
||||
export type { ApiErrorData, ModrinthErrorResponse } from './errors'
|
||||
export { isModrinthErrorResponse } from './errors'
|
||||
export type { HttpMethod, RequestContext, RequestOptions, ResponseData } from './request'
|
||||
export type { UploadHandle, UploadMetadata, UploadProgress, UploadRequestOptions } from './upload'
|
||||
export type {
|
||||
UploadHandle,
|
||||
UploadMetadata,
|
||||
UploadProgress,
|
||||
UploadRequestOptions,
|
||||
UploadState,
|
||||
} from './upload'
|
||||
|
||||
@@ -86,3 +86,16 @@ export interface UploadHandle<T> {
|
||||
/** Cancel the upload */
|
||||
cancel: () => void
|
||||
}
|
||||
|
||||
/**
|
||||
* State of a batch file upload operation
|
||||
*/
|
||||
export interface UploadState {
|
||||
isUploading: boolean
|
||||
currentFileName: string | null
|
||||
currentFileProgress: number
|
||||
uploadedBytes: number
|
||||
totalBytes: number
|
||||
completedFiles: number
|
||||
totalFiles: number
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user