UNPKG

@clusterio/plugin-subspace_storage

Version:

Clusterio plugin for sharing storage between Factorio servers

141 lines 4.67 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.SetStorageSubscriptionRequest = exports.UpdateStorageEvent = exports.GetStorageRequest = exports.RemoveRequest = exports.PlaceEvent = exports.Item = void 0; const typebox_1 = require("@sinclair/typebox"); const lib = __importStar(require("@clusterio/lib")); class Item { name; count; quality; constructor(name, count, quality = "normal") { this.name = name; this.count = count; this.quality = quality; } static jsonSchema = typebox_1.Type.Tuple([ typebox_1.Type.String(), typebox_1.Type.Number(), typebox_1.Type.String(), ]); toJSON() { return [this.name, this.count, this.quality]; } static fromJSON(json) { return new this(json[0], json[1], json[2]); } } exports.Item = Item; // XXX this should be a request to be reliable class PlaceEvent { items; static type = "event"; static src = "instance"; static dst = "controller"; static plugin = "subspace_storage"; constructor(items) { this.items = items; } static jsonSchema = typebox_1.Type.Object({ "items": typebox_1.Type.Array(Item.jsonSchema), }); static fromJSON(json) { return new this(json.items.map(item => Item.fromJSON(item))); } } exports.PlaceEvent = PlaceEvent; class RemoveRequest { items; static type = "request"; static src = "instance"; static dst = "controller"; static plugin = "subspace_storage"; constructor(items) { this.items = items; } static jsonSchema = typebox_1.Type.Object({ "items": typebox_1.Type.Array(Item.jsonSchema), }); static fromJSON(json) { return new this(json.items.map(item => Item.fromJSON(item))); } static Response = lib.jsonArray(Item); } exports.RemoveRequest = RemoveRequest; class GetStorageRequest { static type = "request"; static src = ["instance", "control"]; static dst = "controller"; static plugin = "subspace_storage"; static permission = "subspace_storage.storage.view"; static Response = lib.jsonArray(Item); } exports.GetStorageRequest = GetStorageRequest; class UpdateStorageEvent { items; static type = "event"; static src = "controller"; static dst = ["instance", "control"]; static plugin = "subspace_storage"; constructor(items) { this.items = items; } static jsonSchema = typebox_1.Type.Object({ "items": typebox_1.Type.Array(Item.jsonSchema), }); static fromJSON(json) { return new this(json.items.map(item => Item.fromJSON(item))); } } exports.UpdateStorageEvent = UpdateStorageEvent; class SetStorageSubscriptionRequest { storage; static type = "request"; static src = "control"; static dst = "controller"; static plugin = "subspace_storage"; static permission = "subspace_storage.storage.view"; constructor(storage) { this.storage = storage; } static jsonSchema = typebox_1.Type.Object({ "storage": typebox_1.Type.Boolean(), }); static fromJSON(json) { return new this(json.storage); } } exports.SetStorageSubscriptionRequest = SetStorageSubscriptionRequest; //# sourceMappingURL=messages.js.map