mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-19 07:33:12 +09:00
Add notes to hosts, instances, users and other resources (#1000)
This commit is contained in:
1 parent
ee39945c83
commit
cbf2b10782
25 files changed
+830
-52
No files matched your search
@@ -0,0 +1,59 @@
|
||||
import { Type, Static } from "@sinclair/typebox";
|
||||
import { jsonArray } from "./composites.js";
|
||||
import Note from "./Note.js";
|
||||
|
||||
export class NoteListRequest {
|
||||
declare ["constructor"]: typeof NoteListRequest;
|
||||
static type = "request" as const;
|
||||
static src = "control" as const;
|
||||
static dst = "controller" as const;
|
||||
static permission = "core.note.list" as const;
|
||||
static Response = jsonArray(Note);
|
||||
}
|
||||
|
||||
export class NoteUpdatesEvent {
|
||||
declare ["constructor"]: typeof NoteUpdatesEvent;
|
||||
static type = "event" as const;
|
||||
static src = "controller" as const;
|
||||
static dst = "control" as const;
|
||||
static permission = "core.note.subscribe" as const;
|
||||
|
||||
constructor(
|
||||
public updates: Note[],
|
||||
) { }
|
||||
|
||||
static jsonSchema = Type.Object({
|
||||
"updates": Type.Array(Note.jsonSchema),
|
||||
});
|
||||
|
||||
static fromJSON(json: Static<typeof this.jsonSchema>) {
|
||||
return new this(json.updates.map(update => Note.fromJSON(update)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the note of a resource. An empty content removes the note.
|
||||
*/
|
||||
export class NoteSetRequest {
|
||||
declare ["constructor"]: typeof NoteSetRequest;
|
||||
static type = "request" as const;
|
||||
static src = "control" as const;
|
||||
static dst = "controller" as const;
|
||||
static permission = "core.note.update" as const;
|
||||
|
||||
constructor(
|
||||
public resourceType: string,
|
||||
public resourceId: string,
|
||||
public content: string,
|
||||
) { }
|
||||
|
||||
static jsonSchema = Type.Object({
|
||||
"resourceType": Type.String(),
|
||||
"resourceId": Type.String(),
|
||||
"content": Type.String(),
|
||||
});
|
||||
|
||||
static fromJSON(json: Static<typeof this.jsonSchema>) {
|
||||
return new this(json.resourceType, json.resourceId, json.content);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user