mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-18 07:33:12 +09:00
Port basic lib sub-modules to TypeScript
This commit is contained in:
1 parent
e0c197b9bc
commit
15ea9a91dc
14 files changed
+636
-488
No files matched your search
@@ -14,3 +14,40 @@ export * from "./messages_instance";
|
||||
export * from "./messages_mod";
|
||||
export * from "./messages_user";
|
||||
export * from "./version";
|
||||
|
||||
// TODO: Remove/migrate after lib/data is migrated to ts
|
||||
import type { User } from "../users";
|
||||
export type AddressType = "controller" | "host" | "instance" | "control" | "broadcast";
|
||||
export interface Serialisable {
|
||||
jsonSchema: object,
|
||||
fromJSON(json: any): object,
|
||||
}
|
||||
|
||||
import type { Address } from "./messages_core";
|
||||
export type AddressShorthand =
|
||||
| "controller"
|
||||
| { instanceId: number }
|
||||
| { hostId: number }
|
||||
| { controlId: number }
|
||||
| Address
|
||||
|
||||
export class Request {
|
||||
static type: "request";
|
||||
static src: AddressType | AddressType[];
|
||||
static dst: AddressType | AddressType[];
|
||||
static permission: null | "string" | ((user: User, message: Request) => void);
|
||||
static plugin?: string;
|
||||
static jsonSchema?: object;
|
||||
static fromJSON?: (json: any) => Request;
|
||||
static Response?: Serialisable;
|
||||
}
|
||||
|
||||
export class Event {
|
||||
static type: "event";
|
||||
static src: AddressType | AddressType[];
|
||||
static dst: AddressType | AddressType[];
|
||||
static permission: null | "string" | ((user: User, message: Event) => void);
|
||||
static plugin?: string;
|
||||
static jsonSchema?: object;
|
||||
static fromJSON?: (json: any) => Event;
|
||||
}
|
||||
@@ -19,10 +19,10 @@ class Address {
|
||||
/** @type {number} */
|
||||
type;
|
||||
|
||||
/** @type {string} */
|
||||
/** @type {number} */
|
||||
id;
|
||||
|
||||
/** @type {string|undefined} */
|
||||
/** @type {number|undefined} */
|
||||
requestId;
|
||||
|
||||
constructor(type, id, requestId) {
|
||||
|
||||
Reference in new issue
Block a user