diff --git a/packages/lib/data/messages_core.js b/packages/lib/data/messages_core.js index 2b74c125..1bd925c6 100644 --- a/packages/lib/data/messages_core.js +++ b/packages/lib/data/messages_core.js @@ -67,7 +67,6 @@ class Address { static jsonSchema = { type: "array", minItems: 2, - maxItems: 3, items: [ { type: "integer", minimum: 0, maximum: 4 }, { type: "integer" }, @@ -175,6 +174,7 @@ class HelloData { } static jsonSchema = { + type: "object", required: ["version", "plugins"], properties: { "version": { type: "string" }, @@ -354,14 +354,13 @@ class AccountDetails { } static jsonSchema = { - additionalProperties: false, + type: "object", required: ["name", "roles"], properties: { "name": { type: "string" }, "roles": { type: "array", items: { - additionalProperties: false, type: "object", required: ["name", "id", "permissions"], properties: { @@ -404,7 +403,7 @@ class ReadyData { } static jsonSchema = { - additionalProperties: false, + type: "object", required: ["src", "sessionToken", "sessionTimeout", "heartbeatInterval"], properties: { "src": Address.jsonSchema, @@ -519,6 +518,7 @@ class ContinueData { } static jsonSchema = { + type: "object", required: ["sessionTimeout", "heartbeatInterval"], properties: { "sessionTimeout": { type: "number" }, @@ -701,6 +701,7 @@ class ResponseError { } static jsonSchema = { + type: "object", required: ["message"], properties: { "message": { type: "string" }, diff --git a/packages/lib/data/messages_host.js b/packages/lib/data/messages_host.js index 40b0b855..fe91ed68 100644 --- a/packages/lib/data/messages_host.js +++ b/packages/lib/data/messages_host.js @@ -27,6 +27,7 @@ class HostDetails { } static jsonSchema = { + type: "object", required: ["agent", "version", "name", "id", "connected"], properties: { "agent": { type: "string" }, @@ -156,6 +157,7 @@ class ControllerConnectionEvent { } static jsonSchema = { + type: "object", required: ["event"], properties: { "event": { type: "string" }, @@ -194,6 +196,7 @@ class SyncUserListsEvent { } static jsonSchema = { + type: "object", required: ["adminlist", "banlist", "whitelist"], properties: { "adminlist": { @@ -204,7 +207,7 @@ class SyncUserListsEvent { type: "array", items: { type: "array", - additionalItems: false, + minItems: 2, items: [{ type: "string" }, { type: "string" }], }, }, diff --git a/packages/lib/data/messages_instance.js b/packages/lib/data/messages_instance.js index 967f972a..d7bbaf0c 100644 --- a/packages/lib/data/messages_instance.js +++ b/packages/lib/data/messages_instance.js @@ -182,6 +182,7 @@ class InstanceConfigGetRequest { } static jsonSchema = { + type: "object", required: ["instanceId"], properties: { "instanceId": { type: "integer" }, @@ -235,6 +236,7 @@ class InstanceConfigSetFieldRequest { } static jsonSchema = { + type: "object", required: ["instanceId", "field", "value"], properties: { "instanceId": { type: "integer" }, @@ -274,6 +276,7 @@ class InstanceConfigSetPropRequest { } static jsonSchema = { + type: "object", required: ["instanceId", "field", "prop"], properties: { "instanceId": { type: "integer" }, @@ -306,6 +309,7 @@ class InstanceAssignRequest { } static jsonSchema = { + type: "object", required: ["instanceId", "hostId"], properties: { "instanceId": { type: "number" }, @@ -556,7 +560,7 @@ class InstanceRenameSaveRequest { properties: { "instanceId": { type: "integer" }, "oldName": { type: "string" }, - "newname": { type: "string" }, + "newName": { type: "string" }, }, }; @@ -1167,6 +1171,7 @@ class InstanceBanlistUpdateEvent { } static jsonSchema = { + type: "object", required: ["name", "banned", "reason"], properties: { "name": { type: "string" }, @@ -1198,6 +1203,7 @@ class InstanceAdminlistUpdateEvent { } static jsonSchema = { + type: "object", required: ["name", "admin"], properties: { "name": { type: "string" }, @@ -1228,6 +1234,7 @@ class InstanceWhitelistUpdateEvent { } static jsonSchema = { + type: "object", required: ["name", "whitelisted"], properties: { "name": { type: "string" }, @@ -1266,6 +1273,7 @@ class InstancePlayerUpdateEvent { } static jsonSchema = { + type: "object", required: ["type", "name"], properties: { "type": { type: "string", enum: ["join", "leave", "import"] }, diff --git a/packages/lib/data/messages_user.js b/packages/lib/data/messages_user.js index e45e1b4d..c651ed95 100644 --- a/packages/lib/data/messages_user.js +++ b/packages/lib/data/messages_user.js @@ -18,6 +18,7 @@ class RawPermission { // TODO refactor into lib/user.Permission } static jsonSchema = { + type: "object", required: ["name", "title", "description"], properties: { name: { type: "string" }, @@ -277,6 +278,7 @@ class RawUser { // TODO refactor into lib/user.User type: "array", items: { type: "array", + minItems: 2, items: [{ type: "integer" }, PlayerStats.jsonSchema], }, }, diff --git a/packages/lib/schema.js b/packages/lib/schema.js index 694bfceb..65f90937 100644 --- a/packages/lib/schema.js +++ b/packages/lib/schema.js @@ -7,6 +7,7 @@ const Ajv = require("ajv"); const ajv = new Ajv({ allowUnionTypes: true, strict: "log", + strictTuples: false, verbose: true, }); diff --git a/plugins/inventory_sync/messages.js b/plugins/inventory_sync/messages.js index a7f003c0..f1e58e98 100644 --- a/plugins/inventory_sync/messages.js +++ b/plugins/inventory_sync/messages.js @@ -47,6 +47,7 @@ AcquireRequest.Response = class Response { } static jsonSchema = { + type: "object", required: ["status"], properties: { "status": { @@ -165,6 +166,7 @@ DownloadRequest.Response = class Response { } static jsonSchema = { + type: "object", required: ["playerData"], properties: { "playerData": { type: ["object", "null"] }, diff --git a/plugins/research_sync/messages.js b/plugins/research_sync/messages.js index 33a77078..c131021e 100644 --- a/plugins/research_sync/messages.js +++ b/plugins/research_sync/messages.js @@ -55,6 +55,7 @@ class ProgressEvent { technologies: { type: "array", items: { + type: "object", required: ["name", "level", "progress"], properties: { name: { type: "string" }, diff --git a/plugins/subspace_storage/messages.js b/plugins/subspace_storage/messages.js index 643b8cf4..44a8ec8b 100644 --- a/plugins/subspace_storage/messages.js +++ b/plugins/subspace_storage/messages.js @@ -46,6 +46,7 @@ class PlaceEvent { } static jsonSchema = { + type: "object", required: ["items"], properties: { "items": { @@ -74,6 +75,7 @@ class RemoveRequest { } static jsonSchema = { + type: "object", required: ["items"], properties: { "items": { @@ -113,6 +115,7 @@ class UpdateStorageEvent { } static jsonSchema = { + type: "object", required: ["items"], properties: { "items": { @@ -142,6 +145,7 @@ class SetStorageSubscriptionRequest { } static jsonSchema = { + type: "object", required: ["storage"], properties: { "storage": { type: "boolean" },