mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-13 15:14:52 +09:00
Fix strict mode warnings from Ajv
Add type object to schemas specifying properties and minItems to schemas specifying tuples. Disable strictTuples because it's desirable to be able to add additional items to the tuples in the future.
This commit is contained in:
1 parent
1a9cbd26b3
commit
2de029b96e
8 files changed
+28
-6
No files matched your search
@@ -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" },
|
||||
|
||||
@@ -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" }],
|
||||
},
|
||||
},
|
||||
|
||||
@@ -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"] },
|
||||
|
||||
@@ -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],
|
||||
},
|
||||
},
|
||||
|
||||
@@ -7,6 +7,7 @@ const Ajv = require("ajv");
|
||||
const ajv = new Ajv({
|
||||
allowUnionTypes: true,
|
||||
strict: "log",
|
||||
strictTuples: false,
|
||||
verbose: true,
|
||||
});
|
||||
|
||||
|
||||
@@ -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"] },
|
||||
|
||||
@@ -55,6 +55,7 @@ class ProgressEvent {
|
||||
technologies: {
|
||||
type: "array",
|
||||
items: {
|
||||
type: "object",
|
||||
required: ["name", "level", "progress"],
|
||||
properties: {
|
||||
name: { type: "string" },
|
||||
|
||||
@@ -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" },
|
||||
|
||||
Reference in new issue
Block a user