mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-19 07:33:12 +09:00
Add typing for serialized collector type
Setup TypeScript tyings and JSON schema for serializeResult and deserializeResult and use these in the metrics related requests.
This commit is contained in:
1 parent
b66138587b
commit
b78ca31b09
7 files changed
+46
-26
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import { Type, Static } from "@sinclair/typebox";
|
||||
import { jsonArray, StringEnum } from "./composites";
|
||||
import { CollectorResultSerialized } from "../prometheus";
|
||||
|
||||
export class HostDetails {
|
||||
constructor(
|
||||
@@ -75,11 +76,11 @@ export class HostMetricsRequest {
|
||||
static dst = "host" as const;
|
||||
static Response = class Response { // TODO: Use JSON class pattern in Prometheus
|
||||
constructor(
|
||||
public results: object[],
|
||||
public results: CollectorResultSerialized[],
|
||||
) { }
|
||||
|
||||
static jsonSchema = Type.Object({
|
||||
"results": Type.Array(Type.Object({})),
|
||||
"results": Type.Array(CollectorResultSerialized),
|
||||
});
|
||||
|
||||
static fromJSON(json: Static<typeof this.jsonSchema>) {
|
||||
|
||||
@@ -4,7 +4,7 @@ import { JsonString, StringEnum, jsonArray } from "./composites";
|
||||
import { RawConfig } from "../config";
|
||||
import type { User } from "../users";
|
||||
import type { MessageRequest } from "./messages_core";
|
||||
import type { SerializedConfig } from "../config";
|
||||
import { CollectorResultSerialized } from "../prometheus";
|
||||
|
||||
|
||||
export type InstanceStatus =
|
||||
@@ -216,11 +216,11 @@ export class InstanceMetricsRequest {
|
||||
|
||||
static Response = class Response { // TODO: Use JSON class pattern in Prometheus
|
||||
constructor(
|
||||
public results: object[],
|
||||
public results: CollectorResultSerialized[],
|
||||
) { }
|
||||
|
||||
static jsonSchema = Type.Object({
|
||||
"results": Type.Array(Type.Object({})),
|
||||
"results": Type.Array(CollectorResultSerialized),
|
||||
});
|
||||
|
||||
static fromJSON(json: Static<typeof this.jsonSchema>) {
|
||||
|
||||
Reference in new issue
Block a user