1
0

feat: start of cross platform page system (#4731)

* feat: abstract api-client DI into ui package

* feat: cross platform page system

* feat: tanstack as cross platform useAsyncData

* feat: archon servers routes + labrinth billing routes

* fix: dont use partial

* feat: migrate server list page to tanstack + api-client + re-enabled broken features!

* feat: migrate servers manage page to api-client before page system

* feat: migrate manage page to page system

* fix: type issues

* fix: upgrade wrapper bugs

* refactor: move state types into api-client

* feat: disable financial stuff on app frontend

* feat: finalize cross platform page system for now

* fix: lint

* fix: build issues

* feat: remove papaparse

* fix: lint

* fix: interface error

---------

Co-authored-by: Prospector <6166773+Prospector@users.noreply.github.com>
This commit is contained in:
Calum H.
2025-11-14 17:15:09 +00:00
committed by GitHub
parent 26feaf753a
commit 7ccc32675b
79 changed files with 2631 additions and 1259 deletions

View File

@@ -0,0 +1,3 @@
export * from './servers/types'
export * from './servers/v0'
export * from './servers/v1'

View File

@@ -0,0 +1,57 @@
import { AbstractModule } from '../../../core/abstract-module'
import type { Archon } from '../types'
export class ArchonServersV0Module extends AbstractModule {
public getModuleID(): string {
return 'archon_servers_v0'
}
/**
* Get list of servers for the authenticated user
* GET /modrinth/v0/servers
*/
public async list(
options?: Archon.Servers.v0.GetServersOptions,
): Promise<Archon.Servers.v0.ServerGetResponse> {
const params = new URLSearchParams()
if (options?.limit) params.set('limit', options.limit.toString())
if (options?.offset) params.set('offset', options.offset.toString())
const query = params.toString() ? `?${params.toString()}` : ''
return this.client.request<Archon.Servers.v0.ServerGetResponse>(`servers${query}`, {
api: 'archon',
method: 'GET',
version: 'modrinth/v0',
})
}
/**
* Check stock availability for a region
* POST /modrinth/v0/stock
*/
public async checkStock(
region: string,
request: Archon.Servers.v0.StockRequest,
): Promise<Archon.Servers.v0.StockResponse> {
return this.client.request<Archon.Servers.v0.StockResponse>(`/stock?region=${region}`, {
api: 'archon',
version: 'modrinth/v0',
method: 'POST',
body: request,
})
}
/**
* Get filesystem authentication credentials for a server
* Returns URL and JWT token for accessing the server's filesystem via Kyros
* GET /modrinth/v0/servers/:id/fs
*/
public async getFilesystemAuth(serverId: string): Promise<Archon.Servers.v0.JWTAuth> {
return this.client.request<Archon.Servers.v0.JWTAuth>(`/servers/${serverId}/fs`, {
api: 'archon',
version: 'modrinth/v0',
method: 'GET',
})
}
}

View File

@@ -0,0 +1,20 @@
import { AbstractModule } from '../../../core/abstract-module'
import type { Archon } from '../types'
export class ArchonServersV1Module extends AbstractModule {
public getModuleID(): string {
return 'archon_servers_v1'
}
/**
* Get available regions
* GET /v1/regions
*/
public async getRegions(): Promise<Archon.Servers.v1.Region[]> {
return this.client.request<Archon.Servers.v1.Region[]>('/regions', {
api: 'archon',
version: 1,
method: 'GET',
})
}
}

View File

@@ -0,0 +1,128 @@
export namespace Archon {
export namespace Servers {
export namespace v0 {
export type ServerGetResponse = {
servers: Server[]
pagination: Pagination
}
export type Pagination = {
current_page: number
page_size: number
total_pages: number
total_items: number
}
export type Status = 'installing' | 'broken' | 'available' | 'suspended'
export type SuspensionReason =
| 'moderated'
| 'paymentfailed'
| 'cancelled'
| 'upgrading'
| 'other'
export type Loader =
| 'Forge'
| 'NeoForge'
| 'Fabric'
| 'Quilt'
| 'Purpur'
| 'Spigot'
| 'Vanilla'
| 'Paper'
export type Game = 'Minecraft'
export type UpstreamKind = 'modpack' | 'none'
export type Server = {
server_id: string
name: string
owner_id: string
net: Net
game: Game
backup_quota: number
used_backup_quota: number
status: Status
suspension_reason: SuspensionReason | null
loader: Loader | null
loader_version: string | null
mc_version: string | null
upstream: Upstream | null
sftp_username: string
sftp_password: string
sftp_host: string
datacenter: string
notices: Notice[]
node: NodeInfo | null
flows: Flows
is_medal: boolean
medal_expires?: string
}
export type Net = {
ip: string
port: number
domain: string
}
export type Upstream = {
kind: UpstreamKind
version_id: string
project_id: string
}
export type Notice = {
id: number
dismissable: boolean
title: string
message: string
level: string
announced: string
}
export type NodeInfo = {
token: string
instance: string
}
export type Flows = {
intro: boolean
}
export type GetServersOptions = {
limit?: number
offset?: number
}
export type StockRequest = {
cpu?: number
memory_mb?: number
swap_mb?: number
storage_mb?: number
}
export type StockResponse = {
available: number
}
export type JWTAuth = {
url: string // e.g., "node-xyz.modrinth.com/modrinth/v0/fs"
token: string // JWT token for filesystem access
}
}
export namespace v1 {
export type Region = {
shortcode: string
country_code: string
display_name: string
lat: number
lon: number
zone: string
}
}
}
}