Port basic lib sub-modules to TypeScript

This commit is contained in:
Hornwitser committed 2023-08-06 18:38:20 +02:00
1 parent e0c197b9bc
commit 15ea9a91dc
14 files changed
+636 -488

No files matched your search

+37
View File
@@ -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;
}
+2 -2
View File
@@ -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) {