import { AsyncLocalStorage } from "node:async_hooks"; import type BasePlugin from "@thorium/.server/classes/Plugins"; import type { DatabaseContext } from "@thorium/typeguards/isDatabaseContext"; import type { DataStore } from "@thorium/utils/.server/db-fs"; export interface ThoriumContext { database: DatabaseContext; thoriumPath: string; getData(this: DataStore): Promise; write( this: Pick, force?: boolean, name?: string, ): Promise; remove(this: DataStore, force?: boolean): Promise; readAsset(asset: string): Promise; uploadAsset(this: DataStore, asset: File | Blob, fileName?: string): Promise; removeAsset(assetPath: string): Promise; loadAllAspects( this: BasePlugin, aspectClasses: Record< string, new ( manifest: { name: string; } & Record, plugin: BasePlugin, ) => unknown >, ): Promise; rename: (this: DataStore, newName: string, otherNames: string[]) => Promise; getFlights: () => Promise; getFlightSnapshots: (flightName: string) => Promise; } export const thoriumContext = new AsyncLocalStorage();