Enhance ChatEvent with JSON schema and fromJSON method

Added JSON schema validation and deserialization to ChatEvent.
This commit is contained in:
phidias authored and GitHub committed 2026-10-12 15:23:55 +09:00
1 parent 6ad2d7ac5e
commit 0bef499aac
1 file changed
+8 -6
+8 -6
View File
@@ -16,13 +16,15 @@ export class ChatEvent {
public content: string,
) {}
static async fromContext(context: InstancePluginContext) {
return new ChatEvent(context.instance, context.action, context.content);
}
}
static jsonSchema = Type.Object({
'instance': Type.Any(),
'action': Type.String(),
'content': Type.String(),
});
export default async function (context: InstancePluginContext) {
await ChatEvent.fromContext(context);
static fromJSON(json: Static<typeof ChatEvent.jsonSchema>) {
return new this(json.instance, json.action, json.content);
}
}
declare module '@clusterio/lib' {