-
Notifications
You must be signed in to change notification settings - Fork 22
Adds plugin system #48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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".
af9f121
to
8ae4ad6
Compare
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.
4068933
to
6bd0de7
Compare
- 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.
- 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.
- 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.
- 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`); |
There was a problem hiding this comment.
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.
Implements a functional plugin system that allows extending RBAC functionality.
This includes:
Note
Adds a full plugin architecture (hooks, loader, validator), CLI, example plugins, extensive tests, and docs; updates build/test configs accordingly.
src/plugins/functional-plugin-system.ts
,functional-types.ts
).auto-plugin-loader.ts
,plugin-loader.ts
,plugin-validator.ts
).rbac-plugin
command (src/plugins/bin/rbac-plugin
,src/plugins/cli.ts
); exposed via packagebin
.src/plugins/**
with usage examples.src/plugins/README.md
,COMMUNITY_PLUGINS.md
) detailing hooks, plugins, and community guidelines.test/plugins/**
), plus DB adapter mocks.ts-jest
preset; addjest.setup.ts
to silence logs.tsconfig.test.json
,tsconfig.community.json
); adjust roottsconfig.json
.Written by Cursor Bugbot for commit a10679b. This will update automatically on new commits. Configure here.