We are close to wrapping up the Abilities API 1.0 Milestone, covering all server-side aspects. Now, it's time to start working on implementing a client-side registry for the Abilities API to streamline usage with JavaScript.
We can use for inspiration the existing implementation in the WP Feature API plugin:
https://github.com/Automattic/wp-feature-api/tree/trunk/packages/client
Planned Tasks
I propose we start with developing a JavaScript package on top of the server-side registry, so it's easy to:
- list all available abilities
- find a specific ability by name
- execute a selected ability on the server
Internally, this would use the existing REST API endpoints added in #6.
See the prototyped version:
https://github.com/Automattic/wp-feature-api/blob/trunk/packages/client/src/api.ts
Future
- Implement a way to register abilities that work only on the client.
- It's also worth considering a solution that allows extending the ability registered on the server with an alternative implementation optimized for client usage. A good example is operations on data entities (such as posts or pages) through the
@wordpress/core-data package, which provides an abstraction layer on top of REST API operations, offering optimistic updates, data caching, and tight integration with the editor's UI.