mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-12 23:04:52 +09:00
Adds a permissions array to PluginDeclaration, a type-level Permissions registry that plugins extend with module augmentation, and registerPluginPermissions() called from all entrypoints. checkPermission and the web UI hasPermission helpers now take PermissionName so typos are compile errors. Core definitions move into a corePermissions array that the interface derives its keys from. Closes #987 Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com> Co-authored-by: Cooldude2606 <25043174+Cooldude2606@users.noreply.github.com>
70 lines
1.8 KiB
TypeScript
70 lines
1.8 KiB
TypeScript
import * as lib from "@clusterio/lib";
|
|
import * as messages from "./messages.js";
|
|
|
|
declare module "@clusterio/lib" {
|
|
export interface ControllerConfigFields {
|
|
"subspace_storage.division_method": "simple" | "dole" | "neural_dole";
|
|
"subspace_storage.log_item_transfers": boolean;
|
|
}
|
|
export interface InstanceConfigFields {
|
|
"subspace_storage.log_item_transfers": boolean;
|
|
}
|
|
export interface Permissions {
|
|
"subspace_storage.storage.view": never;
|
|
}
|
|
}
|
|
|
|
export const plugin: lib.PluginDeclaration = {
|
|
name: "subspace_storage",
|
|
title: "Subspace Storage",
|
|
description: "Provides shared storage across instances for the Subspace Storage mod",
|
|
instanceEntrypoint: "dist/node/instance.js",
|
|
instanceConfigFields: {
|
|
"subspace_storage.log_item_transfers": {
|
|
title: "Log Item Transfers",
|
|
description: "Spam host console with item transfers done.",
|
|
type: "boolean",
|
|
initialValue: false,
|
|
},
|
|
},
|
|
|
|
controllerEntrypoint: "dist/node/controller.js",
|
|
controllerConfigFields: {
|
|
"subspace_storage.division_method": {
|
|
title: "Division Method",
|
|
description: "Method for dividing resource requests between instances.",
|
|
type: "string",
|
|
enum: ["simple", "dole", "neural_dole"],
|
|
initialValue: "simple",
|
|
},
|
|
"subspace_storage.log_item_transfers": {
|
|
title: "Log Item Transfers",
|
|
description: "Spam controller console with item transfers done.",
|
|
type: "boolean",
|
|
initialValue: false,
|
|
},
|
|
},
|
|
|
|
features: [
|
|
"ScriptCommands",
|
|
],
|
|
|
|
messages: [
|
|
messages.PlaceEvent,
|
|
messages.RemoveRequest,
|
|
messages.GetStorageRequest,
|
|
messages.UpdateStorageEvent,
|
|
messages.SetStorageSubscriptionRequest,
|
|
],
|
|
permissions: [
|
|
{
|
|
name: "subspace_storage.storage.view",
|
|
title: "View Subspace Storage",
|
|
description: "View the items and fluids stored in the shared subspace.",
|
|
grantByDefault: true,
|
|
},
|
|
],
|
|
webEntrypoint: "./web",
|
|
routes: ["/storage"],
|
|
};
|