Skip to content

Declare permissions on the plugin declaration - #475

Merged
Cooldude2606 merged 1 commit into
explosivegaming:mainfrom
bbassie:feature/plugin-permissions
Sep 12, 2026
Merged

Declare permissions on the plugin declaration#475
Cooldude2606 merged 1 commit into
explosivegaming:mainfrom
bbassie:feature/plugin-permissions

Conversation

@bbassie

@bbassie bbassie commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Clusterio merged clusterio/clusterio#988, which adds a permissions array to PluginDeclaration and a Permissions type registry. checkPermission and the web UI hasPermission helpers now take PermissionName, so a TypeScript plugin has to add its names to the registry or its web pages stop compiling.

exp_groups and exp_scenario now declare their permissions on the plugin declaration instead of calling lib.definePermission() at import time. exp_scenario keeps its tuple table in permissions.ts and derives the name union from it, so adding a permission is still one line. The three controller side permissions stay in index.ts next to the declaration.

The augmentation for exp_groups lives in messages.ts rather than index.ts. The browser project has to see it, and it cannot include index.ts because that file re-exports the ControllerPlugin type from controller.ts. exp_scenario includes index.ts and permissions.ts in its browser project, matching what clusterio did for its own plugins.

Seed role permissions are typed as lib.PermissionName, so a typo in seed.ts fails the build instead of logging a warning at seed time. The tests register the declared permissions with lib.registerPluginPermissions() instead of importing permissions.ts for its side effect.

CI stays red on this PR by itself. main already fails against clusterio master because clusterio moved to ES modules in clusterio/clusterio#984, and #476 stacked on this one fixes that. With both applied, all eight packages build, the isolated reference checks pass and the tap suites pass with 523 and 575 assertions.

Changelog

### Changes
- Permissions are declared on the plugin declaration and checked at compile time. #475

🤖 Generated with Claude Code

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>
@bbassie bbassie mentioned this pull request Sep 11, 2026
@Cooldude2606
Cooldude2606 merged commit 797d750 into explosivegaming:main Sep 12, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants