@wordpress/abilities 0.14.0 → 0.14.1

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
@@ -2,7 +2,9 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
- ## 0.14.0 (2026-06-04)
5
+ ## 0.14.1 (2026-06-16)
6
+
7
+ ## 0.14.0 (2026-06-10)
6
8
 
7
9
  ## 0.13.0 (2026-05-27)
8
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/abilities",
3
- "version": "0.14.0",
3
+ "version": "0.14.1",
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.1",
49
+ "@wordpress/i18n": "^6.21.1",
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": "e7856693aeb4e2522d13608cd32c994e4a97cb9c"
57
+ "gitHead": "99df7432c5c7cb83ba41146fd1f57f3c19004305"
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
  } );