Add subscriptions and luacheck

This commit is contained in:
Cooldude2606 committed 2024-02-17 03:11:54 +00:00
1 parent 58231cc02c
commit f392b258f7
15 files changed
+3644 -39

No files matched your search

@@ -1,6 +1,6 @@
"use strict";
const { plainJson, jsonArray, JsonBoolean, JsonNumber, JsonString, StringEnum } = require("@clusterio/lib");
const { Type, Static } = require("@sinclair/typebox");
const { Type } = require("@sinclair/typebox");
class PluginExampleEvent {
static type = "event";
@@ -49,9 +49,49 @@ class PluginExampleRequest {
"myResponseString": Type.String(),
"myResponseNumbers": Type.Array(Type.Number()),
}));
}// [subscribable] //
class ExampleSubscribableValue {
constructor(id, updatedAtMs, isDeleted) {
this.id = id;
this.updatedAtMs = updatedAtMs;
this.isDeleted = isDeleted;
}
static jsonSchema = Type.Object({
id: Type.String(),
updatedAtMs: Type.Number(),
isDeleted: Type.Boolean(),
});
static fromJSON(json) {
return new this(json.id, json.updatedAtMs, json.isDeleted);
}
}
class ExampleSubscribableUpdate {
static type = "event";
static src = "controller";
static dst = "control";
static plugin = "// plugin_name //";
static permission = "// plugin_name //.example.permission.subscribe";
constructor(updates) {
this.updates = updates;
}
static jsonSchema = Type.Object({
"updates": Type.Array(ExampleSubscribableValue.jsonSchema),
});
static fromJSON(json) {
return new this(json.updates.map(update => ExampleSubscribableValue.fromJSON(update)));
}
}// [] //
module.exports = {
PluginExampleEvent,
PluginExampleRequest,
PluginExampleRequest,// [subscribable] //
ExampleSubscribableValue,
ExampleSubscribableUpdate,// [] //
};