mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-22 08:13:12 +09:00
Port remaining plugins to Typescript (#499)
* .js to .ts * Allow access to _items entries; getItemCount return number * add permission field to PluginPage interface * port plugins to typescript * update Request classes * fix IpcFlowType
This commit is contained in:
1 parent
50f12c719b
commit
0b3550b472
51 files changed
+1033
-1026
No files matched your search
@@ -0,0 +1,63 @@
|
||||
import { Type, Static } from "@sinclair/typebox";
|
||||
|
||||
class FetchPlayerCodeResponse {
|
||||
constructor(
|
||||
public playerCode: string,
|
||||
public controllerUrl: string
|
||||
) {
|
||||
}
|
||||
|
||||
static jsonSchema = Type.Object({
|
||||
"playerCode": Type.String(),
|
||||
"controllerUrl": Type.String(),
|
||||
})
|
||||
|
||||
static fromJSON(json: Static<typeof FetchPlayerCodeResponse.jsonSchema>): FetchPlayerCodeResponse {
|
||||
return new this(json.playerCode, json.controllerUrl);
|
||||
}
|
||||
};
|
||||
|
||||
export class FetchPlayerCodeRequest {
|
||||
declare ["constructor"]: typeof FetchPlayerCodeRequest;
|
||||
static type = "request" as const;
|
||||
static src = "instance" as const;
|
||||
static dst = "controller" as const;
|
||||
static plugin = "player_auth" as const;
|
||||
static Response = FetchPlayerCodeResponse;
|
||||
|
||||
constructor(
|
||||
public player: string
|
||||
) {
|
||||
}
|
||||
|
||||
static jsonSchema = Type.Object({
|
||||
"player": Type.String(),
|
||||
})
|
||||
|
||||
static fromJSON(json: Static<typeof FetchPlayerCodeRequest.jsonSchema>): FetchPlayerCodeRequest {
|
||||
return new this(json.player);
|
||||
}
|
||||
}
|
||||
|
||||
export class SetVerifyCodeRequest {
|
||||
declare ["constructor"]: typeof SetVerifyCodeRequest;
|
||||
static type = "request" as const;
|
||||
static src = "instance" as const;
|
||||
static dst = "controller" as const;
|
||||
static plugin = "player_auth" as const;
|
||||
|
||||
constructor(
|
||||
public player: string,
|
||||
public verifyCode: string
|
||||
) {
|
||||
}
|
||||
|
||||
static jsonSchema = Type.Object({
|
||||
"player": Type.String(),
|
||||
"verifyCode": Type.String(),
|
||||
})
|
||||
|
||||
static fromJSON(json: Static<typeof SetVerifyCodeRequest.jsonSchema>): SetVerifyCodeRequest {
|
||||
return new this(json.player, json.verifyCode);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user