mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-17 15:33:12 +09:00
Push multiple updates in each update event
Refactor HostUpdatesEvent, InstanceDetailsUpdatesEvent, ModUpdatesEvent, ModPackUpdatesEvent and UserUpdatesEvent to have multiple updates of the entities they support in each event. This is intended to make the events capable of syncing the entire list that they represent.
This commit is contained in:
1 parent
f12a9926eb
commit
20330bc2c3
18 files changed
+215
-190
No files matched your search
@@ -52,23 +52,23 @@ export class HostListRequest {
|
||||
static Response = jsonArray(HostDetails);
|
||||
}
|
||||
|
||||
export class HostUpdateEvent {
|
||||
declare ["constructor"]: typeof HostUpdateEvent;
|
||||
export class HostUpdatesEvent {
|
||||
declare ["constructor"]: typeof HostUpdatesEvent;
|
||||
static type = "event" as const;
|
||||
static src = "controller" as const;
|
||||
static dst = "control" as const;
|
||||
static permission = "core.host.subscribe" as const;
|
||||
|
||||
constructor(
|
||||
public update: HostDetails,
|
||||
public updates: HostDetails[],
|
||||
) { }
|
||||
|
||||
static jsonSchema = Type.Object({
|
||||
"update": HostDetails.jsonSchema,
|
||||
"updates": Type.Array(HostDetails.jsonSchema),
|
||||
});
|
||||
|
||||
static fromJSON(json: Static<typeof this.jsonSchema>) {
|
||||
return new this(HostDetails.fromJSON(json.update));
|
||||
return new this(json.updates.map(update => HostDetails.fromJSON(update)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -81,25 +81,23 @@ export class InstanceDetailsListRequest {
|
||||
static Response = jsonArray(InstanceDetails);
|
||||
};
|
||||
|
||||
export class InstanceDetailsUpdateEvent {
|
||||
declare ["constructor"]: typeof InstanceDetailsUpdateEvent;
|
||||
export class InstanceDetailsUpdatesEvent {
|
||||
declare ["constructor"]: typeof InstanceDetailsUpdatesEvent;
|
||||
static type = "event" as const;
|
||||
static src = "controller" as const;
|
||||
static dst = "control" as const;
|
||||
static permission = "core.instance.subscribe" as const;
|
||||
|
||||
constructor(
|
||||
public details: InstanceDetails,
|
||||
public updates: InstanceDetails[],
|
||||
) { }
|
||||
|
||||
static jsonSchema = InstanceDetails.jsonSchema;
|
||||
|
||||
toJSON() {
|
||||
return this.details;
|
||||
}
|
||||
static jsonSchema = Type.Object({
|
||||
"updates": Type.Array(InstanceDetails.jsonSchema),
|
||||
});
|
||||
|
||||
static fromJSON(json: Static<typeof this.jsonSchema>) {
|
||||
return new this(InstanceDetails.fromJSON(json));
|
||||
return new this(json.updates.map(update => InstanceDetails.fromJSON(update)));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -245,42 +245,42 @@ export class ModDeleteRequest {
|
||||
}
|
||||
}
|
||||
|
||||
export class ModPackUpdateEvent {
|
||||
declare ["constructor"]: typeof ModPackUpdateEvent;
|
||||
export class ModPackUpdatesEvent {
|
||||
declare ["constructor"]: typeof ModPackUpdatesEvent;
|
||||
static type = "event" as const;
|
||||
static src = "controller" as const;
|
||||
static dst = "control" as const;
|
||||
static permission = "core.mod_pack.subscribe" as const;
|
||||
|
||||
constructor(
|
||||
public modPack: ModPack,
|
||||
public updates: ModPack[],
|
||||
) { }
|
||||
|
||||
static jsonSchema = Type.Object({
|
||||
"modPack": ModPack.jsonSchema,
|
||||
"updates": Type.Array(ModPack.jsonSchema),
|
||||
});
|
||||
|
||||
static fromJSON(json: Static<typeof this.jsonSchema>) {
|
||||
return new this(ModPack.fromJSON(json.modPack));
|
||||
return new this(json.updates.map(update => ModPack.fromJSON(update)));
|
||||
}
|
||||
}
|
||||
|
||||
export class ModUpdateEvent {
|
||||
declare ["constructor"]: typeof ModUpdateEvent;
|
||||
export class ModUpdatesEvent {
|
||||
declare ["constructor"]: typeof ModUpdatesEvent;
|
||||
static type = "event" as const;
|
||||
static src = "controller" as const;
|
||||
static dst = "control" as const;
|
||||
static permission = "core.mod.subscribe" as const;
|
||||
|
||||
constructor(
|
||||
public mod: ModInfo,
|
||||
public updates: ModInfo[],
|
||||
) { }
|
||||
|
||||
static jsonSchema = Type.Object({
|
||||
"mod": ModInfo.jsonSchema,
|
||||
"updates": Type.Array(ModInfo.jsonSchema),
|
||||
});
|
||||
|
||||
static fromJSON(json: Static<typeof this.jsonSchema>) {
|
||||
return new this(ModInfo.fromJSON(json.mod));
|
||||
return new this(json.updates.map(update => ModInfo.fromJSON(update)));
|
||||
}
|
||||
}
|
||||
@@ -301,22 +301,22 @@ export class UserDeleteRequest {
|
||||
}
|
||||
}
|
||||
|
||||
export class UserUpdateEvent {
|
||||
declare ["constructor"]: typeof UserUpdateEvent;
|
||||
export class UserUpdatesEvent {
|
||||
declare ["constructor"]: typeof UserUpdatesEvent;
|
||||
static type = "event" as const;
|
||||
static src = "controller" as const;
|
||||
static dst = "control" as const;
|
||||
static permission = "core.user.subscribe" as const;
|
||||
|
||||
constructor(
|
||||
public user: User,
|
||||
public updates: User[],
|
||||
) { }
|
||||
|
||||
static jsonSchema = Type.Object({
|
||||
"user": User.jsonSchema,
|
||||
"updates": Type.Array(User.jsonSchema),
|
||||
});
|
||||
|
||||
static fromJSON(json: Static<typeof this.jsonSchema>) {
|
||||
return new this(User.fromJSON(json.user));
|
||||
return new this(json.updates.map(update => User.fromJSON(update)));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user