Skip to content

Conversation

phellipeandrade
Copy link
Owner

@phellipeandrade phellipeandrade commented Sep 14, 2025

Implements a functional plugin system that allows extending RBAC functionality.

This includes:

  • Core plugin system for install/uninstall/enable/disable plugins.
  • Auto-plugin loader for community plugins installed via NPM.
  • Plugin CLI to manage plugins
  • Example plugins for caching, notifications and validation.
  • Documentation and examples for creating community plugins.

Note

Adds a full plugin architecture (hooks, loader, validator), CLI, example plugins, extensive tests, and docs; updates build/test configs accordingly.

  • Plugins
    • Functional Plugin System: New hook-based plugin framework (src/plugins/functional-plugin-system.ts, functional-types.ts).
    • Auto Plugin Loader/Validator: Community plugin discovery/validation/auto-install (auto-plugin-loader.ts, plugin-loader.ts, plugin-validator.ts).
    • CLI: rbac-plugin command (src/plugins/bin/rbac-plugin, src/plugins/cli.ts); exposed via package bin.
    • Example/Built-in Plugins: Cache, Notification, Validation, Middleware, Audit under src/plugins/** with usage examples.
  • Docs
    • README and new plugin docs (src/plugins/README.md, COMMUNITY_PLUGINS.md) detailing hooks, plugins, and community guidelines.
    • CHANGELOG updated with new features.
  • Tests
    • Comprehensive test suite for plugin system, loader, validator, manager, and integration (test/plugins/**), plus DB adapter mocks.
  • Build/Config
    • Jest config revamped to use ts-jest preset; add jest.setup.ts to silence logs.
    • New TS configs (tsconfig.test.json, tsconfig.community.json); adjust root tsconfig.json.
    • Package updates: add CLI binary and related configuration.

Written by Cursor Bugbot for commit a10679b. This will update automatically on new commits. Configure here.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex Review: Here are some suggestions.

Reply with @codex fix comments to fix any unresolved comments.

About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@phellipeandrade phellipeandrade force-pushed the feat/plugins branch 2 times, most recently from af9f121 to 8ae4ad6 Compare September 14, 2025 03:34
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@phellipeandrade phellipeandrade changed the title Adds functional plugin system for RBAC Adds plugin system for RBAC Sep 14, 2025
@phellipeandrade phellipeandrade changed the title Adds plugin system for RBAC Adds plugin system Sep 14, 2025
@phellipeandrade phellipeandrade changed the title Adds plugin system Adds plugin system Sep 14, 2025
cursor[bot]

This comment was marked as outdated.

phellipeandrade and others added 17 commits September 27, 2025 15:04
Implements a functional plugin system that allows extending RBAC functionality.

This includes:
- Core plugin system for install/uninstall/enable/disable plugins.
- Auto-plugin loader for community plugins installed via NPM.
- Plugin CLI to manage plugins
- Example plugins for caching, notifications and validation.
- Documentation and examples for creating community plugins.
- Added new hook utility functions: createHook, createConditionalHook, createAsyncHook, and createErrorHandler.
- Updated createHookUtils to accept an optional PluginSystem parameter.
- Improved error handling in the PluginManager by ensuring plugin names are logged correctly during installation errors.
- Updated test cases to reflect changes in plugin behavior and error handling.
- Introduced a new helper method `pluginToString` in `PluginValidator` to improve security checks by converting plugins to a string representation that includes function bodies.
- Updated the `cache-plugin` to always include a `cacheKey` in the metadata for better tracking of cached data.
- Modified tests to reflect changes in plugin names and validate actual dependencies from `package.json`.
…port

- Added event emission for plugin installation, uninstallation, and error handling to improve tracking and debugging.
- Introduced a new `configure` method in the PluginSystem interface to allow dynamic configuration of plugins.
- Updated error logging to provide clearer messages and context during plugin installation failures.
- Modified tests to ensure proper handling of plugin configuration and event emissions.
- Updated error messages in the plugin installation process to provide clearer context.
- Enhanced validation checks for plugins to ensure proper metadata and method implementations.
- Introduced hooks for role updates and additions in the RBAC system to allow for better extensibility.
- Modified tests to reflect changes in error handling and plugin configuration.
- Updated the result handling in the plugin system to check for both undefined and null values before updating current data.
- Modified the success hook in tests to return the input data directly, ensuring consistency in test behavior.
- Enhanced error handling in the plugin manager tests to properly catch and acknowledge expected errors during plugin installation.
cursor[bot]

This comment was marked as outdated.

- Refined Jest configuration to specify TypeScript transformation settings and added a preset for ts-jest.
- Updated tsconfig.test.json to include the jest.setup.ts file in the compilation.
- Modified tests to ensure all adapter exports can be instantiated without throwing errors.
cursor[bot]

This comment was marked as outdated.

- Added functionality to silence console logs during tests to reduce noise.
- Implemented automatic cleanup intervals in both cache and notification plugins, ensuring proper resource management.
- Updated the uninstall process to clear intervals if they exist, preventing potential memory leaks.
cursor[bot]

This comment was marked as outdated.

- Introduced a new test suite for the RBAC package, validating the default export and tenant role creation.
- Implemented tests to ensure correct role retrieval and permission checks for users.
- Added logging configuration tests to verify logger behavior based on options provided during RBAC instance creation.
cursor[bot]

This comment was marked as outdated.

- Introduced comprehensive test suites for the auto-plugin loader, validating automatic plugin installation, validation checks, and error handling in strict mode.
- Added tests for the cache plugin, ensuring proper caching behavior, expiration of entries, and eviction strategies.
- Implemented CLI tests to verify plugin listing, validation, and installation commands, enhancing overall test coverage for plugin management.
const config = pluginConfigs[plugin.metadata.name] || { enabled: true, priority: 50, settings: {} };
await rbacWithPlugins.plugins.install(plugin, config);

console.log(`Plugin da comunidade ${plugin.metadata.name}@${plugin.metadata.version} instalado com sucesso`);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Portuguese Code in English-Only Project

The changelog claims "Complete internationalization: All code, comments, and documentation translated to English" but this file contains Portuguese comments and console messages (e.g., "Instalar plugins da comunidade", "Plugin inválido", etc.). This contradicts the stated internationalization feature.

Fix in Cursor Fix in Web

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.

1 participant