feat: migrate files to v1

This commit is contained in:
Calum H. (IMB11)
2026-06-26 17:09:23 +01:00
parent e5f91eadb9
commit af6aec8dec
4 changed files with 232 additions and 76 deletions
+2
View File
@@ -15,6 +15,7 @@ import { ArchonTransfersInternalModule } from './archon/transfers/internal'
import { ISO3166Module } from './iso3166'
import { KyrosContentV1Module } from './kyros/content/v1'
import { KyrosFilesV0Module } from './kyros/files/v0'
import { KyrosFilesV1Module } from './kyros/files/v1'
import { KyrosLogsV1Module } from './kyros/logs/v1'
import { KyrosUploadSessionsV1Module } from './kyros/upload-sessions/v1'
import { LabrinthVersionsV2Module, LabrinthVersionsV3Module } from './labrinth'
@@ -88,6 +89,7 @@ export const MODULE_REGISTRY = {
launchermeta_manifest_v0: LauncherMetaManifestV0Module,
kyros_content_v1: KyrosContentV1Module,
kyros_files_v0: KyrosFilesV0Module,
kyros_files_v1: KyrosFilesV1Module,
kyros_logs_v1: KyrosLogsV1Module,
kyros_upload_sessions_v1: KyrosUploadSessionsV1Module,
labrinth_affiliate_internal: LabrinthAffiliateInternalModule,
@@ -0,0 +1,93 @@
import { AbstractModule } from '../../../core/abstract-module'
import type { Kyros } from '../types'
export class KyrosFilesV1Module extends AbstractModule {
public getModuleID(): string {
return 'kyros_files_v1'
}
public async listDescendants(
worldId: string,
path: string,
page: number = 1,
itemsPerPage: number = 100,
): Promise<Kyros.Files.v1.FileListingResponse> {
return this.client.request<Kyros.Files.v1.FileListingResponse>(
`/worlds/${worldId}/files/list`,
{
api: '',
version: 'v1',
method: 'POST',
body: {
path,
page,
items_per_page: itemsPerPage,
},
useNodeAuth: true,
},
)
}
public async downloadRawFileContents(worldId: string, path: string): Promise<Blob> {
return this.client.request<Blob>(`/worlds/${worldId}/files/contents-raw`, {
api: '',
version: 'v1',
method: 'GET',
params: { path },
useNodeAuth: true,
})
}
public async downloadTokenizedContents(worldId: string, downloadId: string): Promise<Blob> {
return this.client.request<Blob>(`/worlds/${worldId}/files/contents/${downloadId}`, {
api: '',
version: 'v1',
method: 'GET',
useNodeAuth: true,
})
}
public async deleteFile(worldId: string, path: string): Promise<void> {
return this.client.request<void>(`/worlds/${worldId}/files/delete`, {
api: '',
version: 'v1',
method: 'POST',
body: { path },
useNodeAuth: true,
})
}
public async moveFile(
worldId: string,
source: string,
destination: string,
): Promise<Kyros.Files.v1.FileMutationResponse> {
return this.client.request<Kyros.Files.v1.FileMutationResponse>(
`/worlds/${worldId}/files/move`,
{
api: '',
version: 'v1',
method: 'POST',
body: { source, destination },
useNodeAuth: true,
},
)
}
public async renameFile(
worldId: string,
path: string,
name: string,
): Promise<Kyros.Files.v1.FileMutationResponse> {
return this.client.request<Kyros.Files.v1.FileMutationResponse>(
`/worlds/${worldId}/files/rename`,
{
api: '',
version: 'v1',
method: 'POST',
body: { path, name },
useNodeAuth: true,
},
)
}
}
@@ -28,6 +28,61 @@ export namespace Kyros {
}
export namespace Files {
export namespace v1 {
export type DescendantType = 'regular' | 'directory' | 'symlink' | 'other'
export interface CreateDownloadSessionRequest {
path: string
zipped: boolean
}
export interface DeleteFileRequest {
path: string
}
export interface FileListingItem {
name: string
full_path: string
size_bytes: number
type: DescendantType
mtime: string
ctime: string
descendants: number
}
export interface FileListingRequest {
path: string
page: number
items_per_page: number
}
export interface FileListingResponse {
items: FileListingItem[]
page: number
items_per_page: number
page_total: number
items_total: number
too_many_descendants: boolean
descendants_limit: number
digest?: string | null
}
export interface FileMutationResponse {
source: string
destination: string
}
export interface MoveFileRequest {
source: string
destination: string
}
export interface RenameFileRequest {
path: string
name: string
}
}
export namespace v0 {
export interface DirectoryItem {
name: string