mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-09-21 17:04:00 +00:00
Declare permissions on the plugin declaration
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>
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
24d2f76a35
commit
30f1b5ea75
+119
-117
@@ -12,123 +12,6 @@ declare module "@clusterio/lib" {
|
||||
}
|
||||
}
|
||||
|
||||
// Group permissions
|
||||
|
||||
lib.definePermission({
|
||||
name: "exp_groups.group.get",
|
||||
title: "Get Groups",
|
||||
description: "Retrieve a specific Factorio permission group by ID.",
|
||||
grantByDefault: true,
|
||||
});
|
||||
lib.definePermission({
|
||||
name: "exp_groups.group.list",
|
||||
title: "List Groups",
|
||||
description: "List all Factorio permission groups.",
|
||||
grantByDefault: true,
|
||||
});
|
||||
lib.definePermission({
|
||||
name: "exp_groups.group.subscribe",
|
||||
title: "Subscribe to Group Updates",
|
||||
description: "Receive updates when Factorio permission groups change.",
|
||||
grantByDefault: true,
|
||||
});
|
||||
lib.definePermission({
|
||||
name: "exp_groups.group.create",
|
||||
title: "Create Groups",
|
||||
description: "Create new Factorio permission groups.",
|
||||
grantByDefault: false,
|
||||
});
|
||||
lib.definePermission({
|
||||
name: "exp_groups.group.update",
|
||||
title: "Update Groups",
|
||||
description: "Modify existing Factorio permission groups.",
|
||||
grantByDefault: false,
|
||||
});
|
||||
lib.definePermission({
|
||||
name: "exp_groups.group.delete",
|
||||
title: "Delete Groups",
|
||||
description: "Delete Factorio permission groups.",
|
||||
grantByDefault: false,
|
||||
});
|
||||
|
||||
// Assignment permissions
|
||||
|
||||
lib.definePermission({
|
||||
name: "exp_groups.assignment.get",
|
||||
title: "Get Assignments",
|
||||
description: "Retrieve a specific manual group assignment for a player.",
|
||||
grantByDefault: true,
|
||||
});
|
||||
lib.definePermission({
|
||||
name: "exp_groups.assignment.list",
|
||||
title: "List Assignments",
|
||||
description: "List all manual group assignments.",
|
||||
grantByDefault: true,
|
||||
});
|
||||
lib.definePermission({
|
||||
name: "exp_groups.assignment.subscribe",
|
||||
title: "Subscribe to Assignment Updates",
|
||||
description: "Receive updates when manual group assignments change.",
|
||||
grantByDefault: true,
|
||||
});
|
||||
lib.definePermission({
|
||||
name: "exp_groups.assignment.create",
|
||||
title: "Create Assignments",
|
||||
description: "Manually assign players to groups, overriding role mappings.",
|
||||
grantByDefault: false,
|
||||
});
|
||||
lib.definePermission({
|
||||
name: "exp_groups.assignment.update",
|
||||
title: "Update Assignments",
|
||||
description: "Modify existing manual group assignments.",
|
||||
grantByDefault: false,
|
||||
});
|
||||
lib.definePermission({
|
||||
name: "exp_groups.assignment.delete",
|
||||
title: "Delete Assignments",
|
||||
description: "Remove manual group assignments.",
|
||||
grantByDefault: false,
|
||||
});
|
||||
|
||||
// Role mapping permissions
|
||||
|
||||
lib.definePermission({
|
||||
name: "exp_groups.role_mapping.get",
|
||||
title: "Get Role Mappings",
|
||||
description: "Retrieve a specific role mapping rule.",
|
||||
grantByDefault: true,
|
||||
});
|
||||
lib.definePermission({
|
||||
name: "exp_groups.role_mapping.list",
|
||||
title: "List Role Mappings",
|
||||
description: "List all role mapping rules.",
|
||||
grantByDefault: true,
|
||||
});
|
||||
lib.definePermission({
|
||||
name: "exp_groups.role_mapping.subscribe",
|
||||
title: "Subscribe to Role Mapping Updates",
|
||||
description: "Receive updates when role mapping rules change.",
|
||||
grantByDefault: true,
|
||||
});
|
||||
lib.definePermission({
|
||||
name: "exp_groups.role_mapping.create",
|
||||
title: "Create Role Mappings",
|
||||
description: "Create rules that map user roles to Factorio permission groups.",
|
||||
grantByDefault: false,
|
||||
});
|
||||
lib.definePermission({
|
||||
name: "exp_groups.role_mapping.update",
|
||||
title: "Update Role Mappings",
|
||||
description: "Modify existing role mapping rules.",
|
||||
grantByDefault: false,
|
||||
});
|
||||
lib.definePermission({
|
||||
name: "exp_groups.role_mapping.delete",
|
||||
title: "Delete Role Mappings",
|
||||
description: "Delete role mapping rules.",
|
||||
grantByDefault: false,
|
||||
});
|
||||
|
||||
export const plugin: lib.PluginDeclaration = {
|
||||
name: "exp_groups",
|
||||
title: "ExpGaming - Permission Groups",
|
||||
@@ -164,6 +47,125 @@ export const plugin: lib.PluginDeclaration = {
|
||||
messages.RoleMappingListRequest,
|
||||
],
|
||||
|
||||
permissions: [
|
||||
// Group permissions
|
||||
|
||||
{
|
||||
name: "exp_groups.group.get",
|
||||
title: "Get Groups",
|
||||
description: "Retrieve a specific Factorio permission group by ID.",
|
||||
grantByDefault: true,
|
||||
},
|
||||
{
|
||||
name: "exp_groups.group.list",
|
||||
title: "List Groups",
|
||||
description: "List all Factorio permission groups.",
|
||||
grantByDefault: true,
|
||||
},
|
||||
{
|
||||
name: "exp_groups.group.subscribe",
|
||||
title: "Subscribe to Group Updates",
|
||||
description: "Receive updates when Factorio permission groups change.",
|
||||
grantByDefault: true,
|
||||
},
|
||||
{
|
||||
name: "exp_groups.group.create",
|
||||
title: "Create Groups",
|
||||
description: "Create new Factorio permission groups.",
|
||||
grantByDefault: false,
|
||||
},
|
||||
{
|
||||
name: "exp_groups.group.update",
|
||||
title: "Update Groups",
|
||||
description: "Modify existing Factorio permission groups.",
|
||||
grantByDefault: false,
|
||||
},
|
||||
{
|
||||
name: "exp_groups.group.delete",
|
||||
title: "Delete Groups",
|
||||
description: "Delete Factorio permission groups.",
|
||||
grantByDefault: false,
|
||||
},
|
||||
|
||||
// Assignment permissions
|
||||
|
||||
{
|
||||
name: "exp_groups.assignment.get",
|
||||
title: "Get Assignments",
|
||||
description: "Retrieve a specific manual group assignment for a player.",
|
||||
grantByDefault: true,
|
||||
},
|
||||
{
|
||||
name: "exp_groups.assignment.list",
|
||||
title: "List Assignments",
|
||||
description: "List all manual group assignments.",
|
||||
grantByDefault: true,
|
||||
},
|
||||
{
|
||||
name: "exp_groups.assignment.subscribe",
|
||||
title: "Subscribe to Assignment Updates",
|
||||
description: "Receive updates when manual group assignments change.",
|
||||
grantByDefault: true,
|
||||
},
|
||||
{
|
||||
name: "exp_groups.assignment.create",
|
||||
title: "Create Assignments",
|
||||
description: "Manually assign players to groups, overriding role mappings.",
|
||||
grantByDefault: false,
|
||||
},
|
||||
{
|
||||
name: "exp_groups.assignment.update",
|
||||
title: "Update Assignments",
|
||||
description: "Modify existing manual group assignments.",
|
||||
grantByDefault: false,
|
||||
},
|
||||
{
|
||||
name: "exp_groups.assignment.delete",
|
||||
title: "Delete Assignments",
|
||||
description: "Remove manual group assignments.",
|
||||
grantByDefault: false,
|
||||
},
|
||||
|
||||
// Role mapping permissions
|
||||
|
||||
{
|
||||
name: "exp_groups.role_mapping.get",
|
||||
title: "Get Role Mappings",
|
||||
description: "Retrieve a specific role mapping rule.",
|
||||
grantByDefault: true,
|
||||
},
|
||||
{
|
||||
name: "exp_groups.role_mapping.list",
|
||||
title: "List Role Mappings",
|
||||
description: "List all role mapping rules.",
|
||||
grantByDefault: true,
|
||||
},
|
||||
{
|
||||
name: "exp_groups.role_mapping.subscribe",
|
||||
title: "Subscribe to Role Mapping Updates",
|
||||
description: "Receive updates when role mapping rules change.",
|
||||
grantByDefault: true,
|
||||
},
|
||||
{
|
||||
name: "exp_groups.role_mapping.create",
|
||||
title: "Create Role Mappings",
|
||||
description: "Create rules that map user roles to Factorio permission groups.",
|
||||
grantByDefault: false,
|
||||
},
|
||||
{
|
||||
name: "exp_groups.role_mapping.update",
|
||||
title: "Update Role Mappings",
|
||||
description: "Modify existing role mapping rules.",
|
||||
grantByDefault: false,
|
||||
},
|
||||
{
|
||||
name: "exp_groups.role_mapping.delete",
|
||||
title: "Delete Role Mappings",
|
||||
description: "Delete role mapping rules.",
|
||||
grantByDefault: false,
|
||||
},
|
||||
],
|
||||
|
||||
instanceEntrypoint: "./dist/node/instance",
|
||||
instanceConfigFields: {
|
||||
"exp_groups.sync_mode": {
|
||||
|
||||
@@ -1,6 +1,30 @@
|
||||
import * as lib from "@clusterio/lib";
|
||||
import { Type, Static } from "@sinclair/typebox";
|
||||
|
||||
// Declared here rather than in index.ts because the browser project cannot include index.ts, which re-exports controller.ts
|
||||
declare module "@clusterio/lib" {
|
||||
export interface Permissions {
|
||||
"exp_groups.group.get": never;
|
||||
"exp_groups.group.list": never;
|
||||
"exp_groups.group.subscribe": never;
|
||||
"exp_groups.group.create": never;
|
||||
"exp_groups.group.update": never;
|
||||
"exp_groups.group.delete": never;
|
||||
"exp_groups.assignment.get": never;
|
||||
"exp_groups.assignment.list": never;
|
||||
"exp_groups.assignment.subscribe": never;
|
||||
"exp_groups.assignment.create": never;
|
||||
"exp_groups.assignment.update": never;
|
||||
"exp_groups.assignment.delete": never;
|
||||
"exp_groups.role_mapping.get": never;
|
||||
"exp_groups.role_mapping.list": never;
|
||||
"exp_groups.role_mapping.subscribe": never;
|
||||
"exp_groups.role_mapping.create": never;
|
||||
"exp_groups.role_mapping.update": never;
|
||||
"exp_groups.role_mapping.delete": never;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Data records
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user