mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-22 16:13:12 +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 = {
|
static jsonSchema = {
|
||||||
type: "array",
|
type: "array",
|
||||||
minItems: 2,
|
minItems: 2,
|
||||||
maxItems: 3,
|
|
||||||
items: [
|
items: [
|
||||||
{ type: "integer", minimum: 0, maximum: 4 },
|
{ type: "integer", minimum: 0, maximum: 4 },
|
||||||
{ type: "integer" },
|
{ type: "integer" },
|
||||||
@@ -175,6 +174,7 @@ class HelloData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static jsonSchema = {
|
static jsonSchema = {
|
||||||
|
type: "object",
|
||||||
required: ["version", "plugins"],
|
required: ["version", "plugins"],
|
||||||
properties: {
|
properties: {
|
||||||
"version": { type: "string" },
|
"version": { type: "string" },
|
||||||
@@ -354,14 +354,13 @@ class AccountDetails {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static jsonSchema = {
|
static jsonSchema = {
|
||||||
additionalProperties: false,
|
type: "object",
|
||||||
required: ["name", "roles"],
|
required: ["name", "roles"],
|
||||||
properties: {
|
properties: {
|
||||||
"name": { type: "string" },
|
"name": { type: "string" },
|
||||||
"roles": {
|
"roles": {
|
||||||
type: "array",
|
type: "array",
|
||||||
items: {
|
items: {
|
||||||
additionalProperties: false,
|
|
||||||
type: "object",
|
type: "object",
|
||||||
required: ["name", "id", "permissions"],
|
required: ["name", "id", "permissions"],
|
||||||
properties: {
|
properties: {
|
||||||
@@ -404,7 +403,7 @@ class ReadyData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static jsonSchema = {
|
static jsonSchema = {
|
||||||
additionalProperties: false,
|
type: "object",
|
||||||
required: ["src", "sessionToken", "sessionTimeout", "heartbeatInterval"],
|
required: ["src", "sessionToken", "sessionTimeout", "heartbeatInterval"],
|
||||||
properties: {
|
properties: {
|
||||||
"src": Address.jsonSchema,
|
"src": Address.jsonSchema,
|
||||||
@@ -519,6 +518,7 @@ class ContinueData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static jsonSchema = {
|
static jsonSchema = {
|
||||||
|
type: "object",
|
||||||
required: ["sessionTimeout", "heartbeatInterval"],
|
required: ["sessionTimeout", "heartbeatInterval"],
|
||||||
properties: {
|
properties: {
|
||||||
"sessionTimeout": { type: "number" },
|
"sessionTimeout": { type: "number" },
|
||||||
@@ -701,6 +701,7 @@ class ResponseError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static jsonSchema = {
|
static jsonSchema = {
|
||||||
|
type: "object",
|
||||||
required: ["message"],
|
required: ["message"],
|
||||||
properties: {
|
properties: {
|
||||||
"message": { type: "string" },
|
"message": { type: "string" },
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ class HostDetails {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static jsonSchema = {
|
static jsonSchema = {
|
||||||
|
type: "object",
|
||||||
required: ["agent", "version", "name", "id", "connected"],
|
required: ["agent", "version", "name", "id", "connected"],
|
||||||
properties: {
|
properties: {
|
||||||
"agent": { type: "string" },
|
"agent": { type: "string" },
|
||||||
@@ -156,6 +157,7 @@ class ControllerConnectionEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static jsonSchema = {
|
static jsonSchema = {
|
||||||
|
type: "object",
|
||||||
required: ["event"],
|
required: ["event"],
|
||||||
properties: {
|
properties: {
|
||||||
"event": { type: "string" },
|
"event": { type: "string" },
|
||||||
@@ -194,6 +196,7 @@ class SyncUserListsEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static jsonSchema = {
|
static jsonSchema = {
|
||||||
|
type: "object",
|
||||||
required: ["adminlist", "banlist", "whitelist"],
|
required: ["adminlist", "banlist", "whitelist"],
|
||||||
properties: {
|
properties: {
|
||||||
"adminlist": {
|
"adminlist": {
|
||||||
@@ -204,7 +207,7 @@ class SyncUserListsEvent {
|
|||||||
type: "array",
|
type: "array",
|
||||||
items: {
|
items: {
|
||||||
type: "array",
|
type: "array",
|
||||||
additionalItems: false,
|
minItems: 2,
|
||||||
items: [{ type: "string" }, { type: "string" }],
|
items: [{ type: "string" }, { type: "string" }],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -182,6 +182,7 @@ class InstanceConfigGetRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static jsonSchema = {
|
static jsonSchema = {
|
||||||
|
type: "object",
|
||||||
required: ["instanceId"],
|
required: ["instanceId"],
|
||||||
properties: {
|
properties: {
|
||||||
"instanceId": { type: "integer" },
|
"instanceId": { type: "integer" },
|
||||||
@@ -235,6 +236,7 @@ class InstanceConfigSetFieldRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static jsonSchema = {
|
static jsonSchema = {
|
||||||
|
type: "object",
|
||||||
required: ["instanceId", "field", "value"],
|
required: ["instanceId", "field", "value"],
|
||||||
properties: {
|
properties: {
|
||||||
"instanceId": { type: "integer" },
|
"instanceId": { type: "integer" },
|
||||||
@@ -274,6 +276,7 @@ class InstanceConfigSetPropRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static jsonSchema = {
|
static jsonSchema = {
|
||||||
|
type: "object",
|
||||||
required: ["instanceId", "field", "prop"],
|
required: ["instanceId", "field", "prop"],
|
||||||
properties: {
|
properties: {
|
||||||
"instanceId": { type: "integer" },
|
"instanceId": { type: "integer" },
|
||||||
@@ -306,6 +309,7 @@ class InstanceAssignRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static jsonSchema = {
|
static jsonSchema = {
|
||||||
|
type: "object",
|
||||||
required: ["instanceId", "hostId"],
|
required: ["instanceId", "hostId"],
|
||||||
properties: {
|
properties: {
|
||||||
"instanceId": { type: "number" },
|
"instanceId": { type: "number" },
|
||||||
@@ -556,7 +560,7 @@ class InstanceRenameSaveRequest {
|
|||||||
properties: {
|
properties: {
|
||||||
"instanceId": { type: "integer" },
|
"instanceId": { type: "integer" },
|
||||||
"oldName": { type: "string" },
|
"oldName": { type: "string" },
|
||||||
"newname": { type: "string" },
|
"newName": { type: "string" },
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1167,6 +1171,7 @@ class InstanceBanlistUpdateEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static jsonSchema = {
|
static jsonSchema = {
|
||||||
|
type: "object",
|
||||||
required: ["name", "banned", "reason"],
|
required: ["name", "banned", "reason"],
|
||||||
properties: {
|
properties: {
|
||||||
"name": { type: "string" },
|
"name": { type: "string" },
|
||||||
@@ -1198,6 +1203,7 @@ class InstanceAdminlistUpdateEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static jsonSchema = {
|
static jsonSchema = {
|
||||||
|
type: "object",
|
||||||
required: ["name", "admin"],
|
required: ["name", "admin"],
|
||||||
properties: {
|
properties: {
|
||||||
"name": { type: "string" },
|
"name": { type: "string" },
|
||||||
@@ -1228,6 +1234,7 @@ class InstanceWhitelistUpdateEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static jsonSchema = {
|
static jsonSchema = {
|
||||||
|
type: "object",
|
||||||
required: ["name", "whitelisted"],
|
required: ["name", "whitelisted"],
|
||||||
properties: {
|
properties: {
|
||||||
"name": { type: "string" },
|
"name": { type: "string" },
|
||||||
@@ -1266,6 +1273,7 @@ class InstancePlayerUpdateEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static jsonSchema = {
|
static jsonSchema = {
|
||||||
|
type: "object",
|
||||||
required: ["type", "name"],
|
required: ["type", "name"],
|
||||||
properties: {
|
properties: {
|
||||||
"type": { type: "string", enum: ["join", "leave", "import"] },
|
"type": { type: "string", enum: ["join", "leave", "import"] },
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ class RawPermission { // TODO refactor into lib/user.Permission
|
|||||||
}
|
}
|
||||||
|
|
||||||
static jsonSchema = {
|
static jsonSchema = {
|
||||||
|
type: "object",
|
||||||
required: ["name", "title", "description"],
|
required: ["name", "title", "description"],
|
||||||
properties: {
|
properties: {
|
||||||
name: { type: "string" },
|
name: { type: "string" },
|
||||||
@@ -277,6 +278,7 @@ class RawUser { // TODO refactor into lib/user.User
|
|||||||
type: "array",
|
type: "array",
|
||||||
items: {
|
items: {
|
||||||
type: "array",
|
type: "array",
|
||||||
|
minItems: 2,
|
||||||
items: [{ type: "integer" }, PlayerStats.jsonSchema],
|
items: [{ type: "integer" }, PlayerStats.jsonSchema],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ const Ajv = require("ajv");
|
|||||||
const ajv = new Ajv({
|
const ajv = new Ajv({
|
||||||
allowUnionTypes: true,
|
allowUnionTypes: true,
|
||||||
strict: "log",
|
strict: "log",
|
||||||
|
strictTuples: false,
|
||||||
verbose: true,
|
verbose: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ AcquireRequest.Response = class Response {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static jsonSchema = {
|
static jsonSchema = {
|
||||||
|
type: "object",
|
||||||
required: ["status"],
|
required: ["status"],
|
||||||
properties: {
|
properties: {
|
||||||
"status": {
|
"status": {
|
||||||
@@ -165,6 +166,7 @@ DownloadRequest.Response = class Response {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static jsonSchema = {
|
static jsonSchema = {
|
||||||
|
type: "object",
|
||||||
required: ["playerData"],
|
required: ["playerData"],
|
||||||
properties: {
|
properties: {
|
||||||
"playerData": { type: ["object", "null"] },
|
"playerData": { type: ["object", "null"] },
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ class ProgressEvent {
|
|||||||
technologies: {
|
technologies: {
|
||||||
type: "array",
|
type: "array",
|
||||||
items: {
|
items: {
|
||||||
|
type: "object",
|
||||||
required: ["name", "level", "progress"],
|
required: ["name", "level", "progress"],
|
||||||
properties: {
|
properties: {
|
||||||
name: { type: "string" },
|
name: { type: "string" },
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ class PlaceEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static jsonSchema = {
|
static jsonSchema = {
|
||||||
|
type: "object",
|
||||||
required: ["items"],
|
required: ["items"],
|
||||||
properties: {
|
properties: {
|
||||||
"items": {
|
"items": {
|
||||||
@@ -74,6 +75,7 @@ class RemoveRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static jsonSchema = {
|
static jsonSchema = {
|
||||||
|
type: "object",
|
||||||
required: ["items"],
|
required: ["items"],
|
||||||
properties: {
|
properties: {
|
||||||
"items": {
|
"items": {
|
||||||
@@ -113,6 +115,7 @@ class UpdateStorageEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static jsonSchema = {
|
static jsonSchema = {
|
||||||
|
type: "object",
|
||||||
required: ["items"],
|
required: ["items"],
|
||||||
properties: {
|
properties: {
|
||||||
"items": {
|
"items": {
|
||||||
@@ -142,6 +145,7 @@ class SetStorageSubscriptionRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static jsonSchema = {
|
static jsonSchema = {
|
||||||
|
type: "object",
|
||||||
required: ["storage"],
|
required: ["storage"],
|
||||||
properties: {
|
properties: {
|
||||||
"storage": { type: "boolean" },
|
"storage": { type: "boolean" },
|
||||||
|
|||||||
Reference in new issue
Block a user