mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-09-21 17:04:00 +00:00
Clusterio #988 added a permissions array to PluginDeclaration and a type level Permissions registry, and made checkPermission and the web UI hasPermission helpers take PermissionName. Move the definePermission calls of exp_groups and exp_scenario into the declaration and add the names to the registry so the web pages type check. The browser tsconfigs include index.ts so the augmentation is visible to the web bundle, matching the in-repo plugins. The exp_scenario table keeps its tuple form and derives the name union from it, so a new row is still one line. Seed role permissions are typed as PermissionName, so a typo in seed.ts is now a compile error rather than a warning at seed time. The tests register the declared permissions through registerPluginPermissions instead of importing permissions.ts for its side effect. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
46 lines
1.3 KiB
TypeScript
46 lines
1.3 KiB
TypeScript
import * as lib from "@clusterio/lib";
|
|
import * as messages from "./messages";
|
|
import { permissions as scenarioPermissions, type ScenarioPermissionName } from "./permissions";
|
|
|
|
declare module "@clusterio/lib" {
|
|
// Everything checked in game through exp_roles, plus the permissions checked on the controller
|
|
export interface Permissions extends Record<ScenarioPermissionName, never> {
|
|
"exp_scenario.config.view": never;
|
|
"exp_scenario.config.edit": never;
|
|
"exp_scenario.seed": never;
|
|
}
|
|
}
|
|
|
|
export const plugin: lib.PluginDeclaration = {
|
|
name: "exp_scenario",
|
|
title: "exp_scenario",
|
|
description: "Example Description. Plugin. Change me in index.ts",
|
|
controllerEntrypoint: "./dist/node/controller",
|
|
instanceEntrypoint: "./dist/node/instance",
|
|
|
|
messages: [
|
|
messages.SeedRequest,
|
|
],
|
|
|
|
permissions: [
|
|
...scenarioPermissions,
|
|
{
|
|
name: "exp_scenario.config.view",
|
|
title: "View ExpScenario Config",
|
|
description: "View the config for all submodules of ExpScenario",
|
|
},
|
|
{
|
|
name: "exp_scenario.config.edit",
|
|
title: "Edit ExpScenario Config",
|
|
description: "Edit the config for all submodules of ExpScenario",
|
|
},
|
|
{
|
|
name: "exp_scenario.seed",
|
|
title: "Seed ExpScenario roles and groups",
|
|
description: "Create the roles and permission groups the scenario shipped with",
|
|
},
|
|
],
|
|
|
|
webEntrypoint: "./web",
|
|
};
|