@wordpress/abilities 0.14.0 → 0.14.2-next.v.202606191442.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
|
@@ -11,7 +11,7 @@ import type { AbilitiesState } from './types';
|
|
|
11
11
|
* @param args Optional query arguments to filter. Defaults to empty object.
|
|
12
12
|
* @return Array of abilities.
|
|
13
13
|
*/
|
|
14
|
-
export declare const getAbilities: ((state: AbilitiesState, { category }?: AbilitiesQueryArgs) => Ability[]) & import("
|
|
14
|
+
export declare const getAbilities: ((state: AbilitiesState, { category }?: AbilitiesQueryArgs) => Ability[]) & import("@wordpress/data").EnhancedSelector;
|
|
15
15
|
/**
|
|
16
16
|
* Returns a specific ability by name.
|
|
17
17
|
*
|
|
@@ -26,7 +26,7 @@ export declare function getAbility(state: AbilitiesState, name: string): Ability
|
|
|
26
26
|
* @param state Store state.
|
|
27
27
|
* @return Array of categories.
|
|
28
28
|
*/
|
|
29
|
-
export declare const getAbilityCategories: ((state: AbilitiesState) => AbilityCategory[]) & import("
|
|
29
|
+
export declare const getAbilityCategories: ((state: AbilitiesState) => AbilityCategory[]) & import("@wordpress/data").EnhancedSelector;
|
|
30
30
|
/**
|
|
31
31
|
* Returns a specific ability category by slug.
|
|
32
32
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectors.d.ts","sourceRoot":"","sources":["../../src/store/selectors.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,WAEhB,cAAc,iBACP,kBAAkB,KAC9B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"selectors.d.ts","sourceRoot":"","sources":["../../src/store/selectors.ts"],"names":[],"mappings":"AAKA;;GAEG;AACH,OAAO,KAAK,EAAE,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC7E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,WAEhB,cAAc,iBACP,kBAAkB,KAC9B,OAAO,EAAE,8CAaZ,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,UAAU,CACzB,KAAK,EAAE,cAAc,EACrB,IAAI,EAAE,MAAM,GACV,OAAO,GAAG,SAAS,CAErB;AAED;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,WACvB,cAAc,KAAI,eAAe,EAAE,8CAI5C,CAAC;AAEF;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,cAAc,EACrB,IAAI,EAAE,MAAM,GACV,eAAe,GAAG,SAAS,CAE7B"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/abilities",
|
|
3
|
-
"version": "0.14.0",
|
|
3
|
+
"version": "0.14.2-next.v.202606191442.0+17fe7db8a",
|
|
4
4
|
"description": "JavaScript client for WordPress Abilities API.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
},
|
|
46
46
|
"types": "build-types",
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@wordpress/data": "^10.48.0",
|
|
49
|
-
"@wordpress/i18n": "^6.21.0",
|
|
48
|
+
"@wordpress/data": "^10.48.2-next.v.202606191442.0+17fe7db8a",
|
|
49
|
+
"@wordpress/i18n": "^6.21.2-next.v.202606191442.0+17fe7db8a",
|
|
50
50
|
"ajv": "^8.17.1",
|
|
51
51
|
"ajv-draft-04": "^1.0.0",
|
|
52
52
|
"ajv-formats": "^3.0.1"
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "1b6a19222df5a88f161880b5789efb3171d8f425"
|
|
58
58
|
}
|
|
@@ -529,4 +529,71 @@ describe( 'validateValueFromSchema', () => {
|
|
|
529
529
|
);
|
|
530
530
|
} );
|
|
531
531
|
} );
|
|
532
|
+
|
|
533
|
+
describe( 'WordPress-specific schema keywords', () => {
|
|
534
|
+
// All of these keywords are valid on WordPress REST API schemas
|
|
535
|
+
// (sanitize_callback / validate_callback / arg_options from
|
|
536
|
+
// register_meta and route args, context / readonly from REST
|
|
537
|
+
// response shaping, example / examples from OpenAPI-style docs,
|
|
538
|
+
// and boolean `required` from per-arg flags) but are not part of
|
|
539
|
+
// JSON Schema draft-04. AJV rejects them at compile time (either
|
|
540
|
+
// strict mode or meta-schema), so the catch block surfaces a
|
|
541
|
+
// generic "Invalid schema" error rather than ignoring them.
|
|
542
|
+
it.each( [
|
|
543
|
+
[ 'sanitize_callback', 'sanitize_text_field' ],
|
|
544
|
+
[ 'validate_callback', 'rest_validate_request_arg' ],
|
|
545
|
+
[ 'arg_options', { sanitize_callback: 'sanitize_key' } ],
|
|
546
|
+
[ 'example', 'an example value' ],
|
|
547
|
+
[ 'examples', [ 'first', 'second' ] ],
|
|
548
|
+
[ 'context', [ 'view', 'edit', 'embed' ] ],
|
|
549
|
+
[ 'readonly', true ],
|
|
550
|
+
[ 'required', true ],
|
|
551
|
+
] )(
|
|
552
|
+
'should fail compilation when a property uses `%s`',
|
|
553
|
+
( keyword, value ) => {
|
|
554
|
+
const schema = {
|
|
555
|
+
type: 'object',
|
|
556
|
+
properties: {
|
|
557
|
+
name: {
|
|
558
|
+
type: 'string',
|
|
559
|
+
[ keyword ]: value,
|
|
560
|
+
},
|
|
561
|
+
},
|
|
562
|
+
};
|
|
563
|
+
const consoleErrorSpy = jest
|
|
564
|
+
.spyOn( console, 'error' )
|
|
565
|
+
.mockImplementation();
|
|
566
|
+
|
|
567
|
+
expect(
|
|
568
|
+
validateValueFromSchema( { name: 'hello' }, schema )
|
|
569
|
+
).toBe( 'Invalid schema provided for validation.' );
|
|
570
|
+
expect( consoleErrorSpy ).toHaveBeenCalledWith(
|
|
571
|
+
'Schema compilation error:',
|
|
572
|
+
expect.any( Error )
|
|
573
|
+
);
|
|
574
|
+
|
|
575
|
+
consoleErrorSpy.mockRestore();
|
|
576
|
+
}
|
|
577
|
+
);
|
|
578
|
+
|
|
579
|
+
it( 'should fail compilation when a WP-specific keyword sits at the top level of the schema', () => {
|
|
580
|
+
const schema = {
|
|
581
|
+
type: 'string',
|
|
582
|
+
sanitize_callback: 'sanitize_text_field',
|
|
583
|
+
};
|
|
584
|
+
const consoleErrorSpy = jest
|
|
585
|
+
.spyOn( console, 'error' )
|
|
586
|
+
.mockImplementation();
|
|
587
|
+
|
|
588
|
+
expect( validateValueFromSchema( 'hello', schema ) ).toBe(
|
|
589
|
+
'Invalid schema provided for validation.'
|
|
590
|
+
);
|
|
591
|
+
expect( consoleErrorSpy ).toHaveBeenCalledWith(
|
|
592
|
+
'Schema compilation error:',
|
|
593
|
+
expect.any( Error )
|
|
594
|
+
);
|
|
595
|
+
|
|
596
|
+
consoleErrorSpy.mockRestore();
|
|
597
|
+
} );
|
|
598
|
+
} );
|
|
532
599
|
} );
|