@elementor/editor-canvas 4.4.0-1132 → 4.4.0-1133

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/dist/index.js CHANGED
@@ -88,10 +88,14 @@ var listWidgetTypes = async () => {
88
88
  };
89
89
  var fetchWidgetSchema = async (widgetType) => {
90
90
  const { data } = await (0, import_http_client.httpService)().post(MCP_PROXY_URL, {
91
- tool: "get-widget-schema",
92
- input: { widget_type: widgetType }
91
+ tool: "get-widget-schemas",
92
+ input: { widget_type: [widgetType] }
93
93
  });
94
- return data.data ?? {};
94
+ const schema = data.data?.schemas?.[widgetType];
95
+ if (!schema) {
96
+ throw new Error(data.data?.errors?.[widgetType]?.message ?? `No schema found for ${widgetType}.`);
97
+ }
98
+ return schema;
95
99
  };
96
100
  var initWidgetsSchemaResource = (reg) => {
97
101
  const { resource } = reg;
package/dist/index.mjs CHANGED
@@ -19,10 +19,14 @@ var listWidgetTypes = async () => {
19
19
  };
20
20
  var fetchWidgetSchema = async (widgetType) => {
21
21
  const { data } = await httpService().post(MCP_PROXY_URL, {
22
- tool: "get-widget-schema",
23
- input: { widget_type: widgetType }
22
+ tool: "get-widget-schemas",
23
+ input: { widget_type: [widgetType] }
24
24
  });
25
- return data.data ?? {};
25
+ const schema = data.data?.schemas?.[widgetType];
26
+ if (!schema) {
27
+ throw new Error(data.data?.errors?.[widgetType]?.message ?? `No schema found for ${widgetType}.`);
28
+ }
29
+ return schema;
26
30
  };
27
31
  var initWidgetsSchemaResource = (reg) => {
28
32
  const { resource } = reg;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@elementor/editor-canvas",
3
3
  "description": "Elementor Editor Canvas",
4
- "version": "4.4.0-1132",
4
+ "version": "4.4.0-1133",
5
5
  "private": false,
6
6
  "author": "Elementor Team",
7
7
  "homepage": "https://elementor.com/",
@@ -37,26 +37,26 @@
37
37
  "react-dom": "^18.3.1"
38
38
  },
39
39
  "dependencies": {
40
- "@elementor/editor": "4.4.0-1132",
41
- "@elementor/editor-controls": "4.4.0-1132",
42
- "@elementor/editor-documents": "4.4.0-1132",
43
- "@elementor/editor-elements": "4.4.0-1132",
44
- "@elementor/editor-interactions": "4.4.0-1132",
45
- "@elementor/editor-mcp": "4.4.0-1132",
46
- "@elementor/editor-notifications": "4.4.0-1132",
47
- "@elementor/editor-props": "4.4.0-1132",
48
- "@elementor/editor-responsive": "4.4.0-1132",
49
- "@elementor/editor-styles": "4.4.0-1132",
50
- "@elementor/editor-styles-repository": "4.4.0-1132",
51
- "@elementor/editor-ui": "4.4.0-1132",
52
- "@elementor/editor-v1-adapters": "4.4.0-1132",
53
- "@elementor/events": "4.4.0-1132",
54
- "@elementor/http-client": "4.4.0-1132",
55
- "@elementor/schema": "4.4.0-1132",
56
- "@elementor/twing": "4.4.0-1132",
40
+ "@elementor/editor": "4.4.0-1133",
41
+ "@elementor/editor-controls": "4.4.0-1133",
42
+ "@elementor/editor-documents": "4.4.0-1133",
43
+ "@elementor/editor-elements": "4.4.0-1133",
44
+ "@elementor/editor-interactions": "4.4.0-1133",
45
+ "@elementor/editor-mcp": "4.4.0-1133",
46
+ "@elementor/editor-notifications": "4.4.0-1133",
47
+ "@elementor/editor-props": "4.4.0-1133",
48
+ "@elementor/editor-responsive": "4.4.0-1133",
49
+ "@elementor/editor-styles": "4.4.0-1133",
50
+ "@elementor/editor-styles-repository": "4.4.0-1133",
51
+ "@elementor/editor-ui": "4.4.0-1133",
52
+ "@elementor/editor-v1-adapters": "4.4.0-1133",
53
+ "@elementor/events": "4.4.0-1133",
54
+ "@elementor/http-client": "4.4.0-1133",
55
+ "@elementor/schema": "4.4.0-1133",
56
+ "@elementor/twing": "4.4.0-1133",
57
57
  "@elementor/ui": "1.41.1",
58
- "@elementor/utils": "4.4.0-1132",
59
- "@elementor/wp-media": "4.4.0-1132",
58
+ "@elementor/utils": "4.4.0-1133",
59
+ "@elementor/wp-media": "4.4.0-1133",
60
60
  "@floating-ui/react": "^0.27.5",
61
61
  "@wordpress/i18n": "^5.13.0",
62
62
  "dompurify": "^3.2.6"
@@ -69,10 +69,15 @@ describe( 'widgets-schema-resource', () => {
69
69
  ] );
70
70
  } );
71
71
 
72
- it( 'reads a single widget schema via the get-widget-schema tool', async () => {
72
+ it( 'reads a single widget schema via the get-widget-schemas tool', async () => {
73
73
  // Arrange
74
74
  const post = jest.fn().mockResolvedValue( {
75
- data: { data: { type: 'object', properties: { text: { mocked: true } } } },
75
+ data: {
76
+ data: {
77
+ schemas: { 'e-heading': { type: 'object', properties: { text: { mocked: true } } } },
78
+ errors: {},
79
+ },
80
+ },
76
81
  } );
77
82
  mockedHttpService.mockReturnValue( { post } as never );
78
83
  const { readHandler } = captureHandlers();
@@ -83,8 +88,8 @@ describe( 'widgets-schema-resource', () => {
83
88
 
84
89
  // Assert
85
90
  expect( post ).toHaveBeenCalledWith( 'elementor/v1/mcp-proxy', {
86
- tool: 'get-widget-schema',
87
- input: { widget_type: 'e-heading' },
91
+ tool: 'get-widget-schemas',
92
+ input: { widget_type: [ 'e-heading' ] },
88
93
  } );
89
94
  expect( JSON.parse( result.contents[ 0 ].text ) ).toEqual( {
90
95
  type: 'object',
@@ -92,6 +97,28 @@ describe( 'widgets-schema-resource', () => {
92
97
  } );
93
98
  } );
94
99
 
100
+ it( 'throws the tool error when the widget type has no schema', async () => {
101
+ // Arrange
102
+ const post = jest.fn().mockResolvedValue( {
103
+ data: {
104
+ data: {
105
+ schemas: {},
106
+ errors: {
107
+ 'e-missing': { code: 'elementor_not_found', message: 'Unknown widget type: e-missing.' },
108
+ },
109
+ },
110
+ },
111
+ } );
112
+ mockedHttpService.mockReturnValue( { post } as never );
113
+ const { readHandler } = captureHandlers();
114
+ const uri = new URL( 'elementor://widgets/schema/e-missing' );
115
+
116
+ // Act & Assert
117
+ await expect( readHandler( uri, { widgetType: 'e-missing' } ) ).rejects.toThrow(
118
+ 'Unknown widget type: e-missing.'
119
+ );
120
+ } );
121
+
95
122
  it( 'throws when no widget type variable is provided', async () => {
96
123
  // Arrange
97
124
  const { readHandler } = captureHandlers();
@@ -29,13 +29,24 @@ const listWidgetTypes = async (): Promise< string[] > => {
29
29
  return ( data.data?.widgets ?? [] ).map( ( widget ) => widget.type );
30
30
  };
31
31
 
32
+ type WidgetSchemasResponse = {
33
+ schemas?: Record< string, Record< string, unknown > >;
34
+ errors?: Record< string, { code: string; message: string } >;
35
+ };
36
+
32
37
  const fetchWidgetSchema = async ( widgetType: string ): Promise< Record< string, unknown > > => {
33
- const { data } = await httpService().post< HttpResponse< Record< string, unknown > > >( MCP_PROXY_URL, {
34
- tool: 'get-widget-schema',
35
- input: { widget_type: widgetType },
38
+ const { data } = await httpService().post< HttpResponse< WidgetSchemasResponse > >( MCP_PROXY_URL, {
39
+ tool: 'get-widget-schemas',
40
+ input: { widget_type: [ widgetType ] },
36
41
  } );
37
42
 
38
- return data.data ?? {};
43
+ const schema = data.data?.schemas?.[ widgetType ];
44
+
45
+ if ( ! schema ) {
46
+ throw new Error( data.data?.errors?.[ widgetType ]?.message ?? `No schema found for ${ widgetType }.` );
47
+ }
48
+
49
+ return schema;
39
50
  };
40
51
 
41
52
  export const initWidgetsSchemaResource = ( reg: MCPRegistryEntry ) => {