1+ import type { Ability , AbilityCategory , AbilityCategoryArgs , AbilitiesQueryArgs , AbilityInput , AbilityOutput } from './types' ;
2+ /**
3+ * Get all available abilities with optional filtering.
4+ *
5+ * @param args Optional query arguments to filter. Defaults to empty object.
6+ * @return Promise resolving to array of abilities.
7+ */
8+ export declare function getAbilities ( args ?: AbilitiesQueryArgs ) : Promise < Ability [ ] > ;
9+ /**
10+ * Get a specific ability by name.
11+ *
12+ * @param name The ability name.
13+ * @return Promise resolving to the ability or null if not found.
14+ */
15+ export declare function getAbility ( name : string ) : Promise < Ability | null > ;
16+ /**
17+ * Get all available ability categories.
18+ *
19+ * @return Promise resolving to array of categories.
20+ */
21+ export declare function getAbilityCategories ( ) : Promise < AbilityCategory [ ] > ;
22+ /**
23+ * Get a specific ability category by slug.
24+ *
25+ * @param slug The category slug.
26+ * @return Promise resolving to the category or null if not found.
27+ */
28+ export declare function getAbilityCategory ( slug : string ) : Promise < AbilityCategory | null > ;
29+ /**
30+ * Register a client-side ability.
31+ *
32+ * Client abilities are executed locally in the browser and must include
33+ * a callback function. The ability will be validated by the store action,
34+ * and an error will be thrown if validation fails.
35+ *
36+ * Categories will be automatically fetched from the REST API if they
37+ * haven't been loaded yet, so you don't need to call getAbilityCategories()
38+ * before registering abilities.
39+ *
40+ * @param ability The ability definition including callback.
41+ * @return Promise that resolves when registration is complete.
42+ * @throws {Error } If the ability fails validation.
43+ *
44+ * @example
45+ * ```js
46+ * await registerAbility({
47+ * name: 'my-plugin/navigate',
48+ * label: 'Navigate to URL',
49+ * description: 'Navigates to a URL within WordPress admin',
50+ * category: 'navigation',
51+ * input_schema: {
52+ * type: 'object',
53+ * properties: {
54+ * url: { type: 'string' }
55+ * },
56+ * required: ['url']
57+ * },
58+ * callback: async ({ url }) => {
59+ * window.location.href = url;
60+ * return { success: true };
61+ * }
62+ * });
63+ * ```
64+ */
65+ export declare function registerAbility ( ability : Ability ) : Promise < void > ;
66+ /**
67+ * Unregister an ability from the store.
68+ *
69+ * Remove a client-side ability from the store.
70+ * Note: This will return an error for server-side abilities.
71+ *
72+ * @param name The ability name to unregister.
73+ */
74+ export declare function unregisterAbility ( name : string ) : void ;
75+ /**
76+ * Register a client-side ability category.
77+ *
78+ * Categories registered on the client are stored alongside server-side categories
79+ * in the same store and can be used when registering client side abilities.
80+ * This is useful when registering client-side abilities that introduce new
81+ * categories not defined by the server.
82+ *
83+ * Categories will be automatically fetched from the REST API if they haven't been
84+ * loaded yet to check for duplicates against server-side categories.
85+ *
86+ * @param slug Category slug (lowercase alphanumeric with dashes only).
87+ * @param args Category arguments (label, description, optional meta).
88+ * @return Promise that resolves when registration is complete.
89+ * @throws {Error } If the category fails validation.
90+ *
91+ * @example
92+ * ```js
93+ * // Register a new category for block editor abilities
94+ * await registerAbilityCategory('block-editor', {
95+ * label: 'Block Editor',
96+ * description: 'Abilities for interacting with the WordPress block editor'
97+ * });
98+ *
99+ * // Then register abilities using this category
100+ * await registerAbility({
101+ * name: 'my-plugin/insert-block',
102+ * label: 'Insert Block',
103+ * description: 'Inserts a block into the editor',
104+ * category: 'block-editor',
105+ * callback: async ({ blockType }) => {
106+ * // Implementation
107+ * return { success: true };
108+ * }
109+ * });
110+ * ```
111+ */
112+ export declare function registerAbilityCategory ( slug : string , args : AbilityCategoryArgs ) : Promise < void > ;
113+ /**
114+ * Unregister an ability category.
115+ *
116+ * Removes a category from the store.
117+ *
118+ * @param slug The category slug to unregister.
119+ *
120+ * @example
121+ * ```js
122+ * unregisterAbilityCategory('block-editor');
123+ * ```
124+ */
125+ export declare function unregisterAbilityCategory ( slug : string ) : void ;
126+ /**
127+ * Execute an ability.
128+ *
129+ * Determines whether to execute locally (client abilities) or remotely (server abilities)
130+ * based on whether the ability has a callback function.
131+ *
132+ * @param name The ability name.
133+ * @param input Optional input parameters for the ability.
134+ * @return Promise resolving to the ability execution result.
135+ * @throws Error if the ability is not found or execution fails.
136+ */
137+ export declare function executeAbility ( name : string , input ?: AbilityInput ) : Promise < AbilityOutput > ;
138+ //# sourceMappingURL=api.d.ts.map
0 commit comments