Skip to content

Commit ebcfb04

Browse files
akoclaude
andcommitted
feat(odata): add SHOW/DESCRIBE CONTRACT commands to browse cached $metadata
Parse the Metadata XML field stored on consumed OData services to let users browse available entities, properties, actions, and generate MDL from contracts without network access. New commands: - SHOW CONTRACT ENTITIES FROM Module.Service - SHOW CONTRACT ACTIONS FROM Module.Service - DESCRIBE CONTRACT ENTITY Module.Service.Entity [FORMAT mdl] - DESCRIBE CONTRACT ACTION Module.Service.Action [FORMAT mdl] Implementation: - Add Metadata, MetadataHash, and Catalog fields to ConsumedODataService model - Add EDMX/CSDL XML parser (sdk/mpr/edmx.go) supporting OData3 and OData4 - Add CONTRACT token to lexer, grammar rules before ambiguous alternatives - Add executor handlers with FORMAT mdl generating CREATE EXTERNAL ENTITY - Update help topics, quick reference, docs-site, CLAUDE.md, skills, examples Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent cb0bbac commit ebcfb04

File tree

23 files changed

+7366
-5827
lines changed

23 files changed

+7366
-5827
lines changed

.claude/skills/mendix/odata-data-sharing.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,8 +511,14 @@ DESCRIBE ODATA CLIENT ShopViewsClient.ShopViewsApiClient;
511511

512512
-- See external entities and view entities
513513
SHOW ENTITIES IN ShopViewsClient;
514-
DESCRIBE ENTITY ShopViewsClient.ProductWithActivePricesEE;
515-
DESCRIBE ENTITY ShopViews.ProductWithActivePriceVE;
514+
SHOW EXTERNAL ENTITIES;
515+
SHOW EXTERNAL ACTIONS;
516+
517+
-- Browse available assets from cached $metadata contract
518+
SHOW CONTRACT ENTITIES FROM ShopViewsClient.ShopViewsApiClient;
519+
SHOW CONTRACT ACTIONS FROM ShopViewsClient.ShopViewsApiClient;
520+
DESCRIBE CONTRACT ENTITY ShopViewsClient.ShopViewsApiClient.Product;
521+
DESCRIBE CONTRACT ENTITY ShopViewsClient.ShopViewsApiClient.Product FORMAT mdl;
516522

517523
-- Check security setup
518524
SHOW ACCESS ON ODATA SERVICE ShopViews.ShopViewsApi;

CLAUDE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,9 @@ Full syntax tables for all MDL statements (microflows, pages, security, navigati
405405
- CREATE/DROP WORKFLOW with user tasks, decisions, parallel splits, and other activity types
406406
- CALCULATED BY microflow syntax for calculated attributes
407407
- Image collections (SHOW/DESCRIBE/CREATE/DROP)
408+
- OData contract browsing (SHOW/DESCRIBE CONTRACT ENTITIES/ACTIONS FROM cached $metadata)
409+
- SHOW EXTERNAL ACTIONS, SHOW PUBLISHED REST SERVICES
410+
- Integration catalog tables (rest_clients, rest_operations, published_rest_services, external_entities, external_actions, business_events)
408411

409412
**Not Yet Implemented:**
410413
- 47 of 52 metamodel domains (REST, etc.)

cmd/mxcli/help_topics/odata.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ SHOW COMMANDS
1313
SHOW EXTERNAL ACTIONS; -- List external actions used in microflows
1414
SHOW EXTERNAL ACTIONS IN MyModule; -- Filter by module
1515

16+
CONTRACT COMMANDS (browse cached $metadata)
17+
--------------------------------------------
18+
19+
SHOW CONTRACT ENTITIES FROM MyModule.MyClient; -- List entity types from $metadata
20+
SHOW CONTRACT ACTIONS FROM MyModule.MyClient; -- List actions/functions from $metadata
21+
22+
DESCRIBE CONTRACT ENTITY MyModule.MyClient.Product; -- Properties and nav props
23+
DESCRIBE CONTRACT ENTITY MyModule.MyClient.Product FORMAT mdl; -- Generate CREATE EXTERNAL ENTITY
24+
DESCRIBE CONTRACT ACTION MyModule.MyClient.CreateOrder; -- Parameters and return type
25+
1626
DESCRIBE COMMANDS
1727
-----------------
1828

cmd/mxcli/lsp_completions_gen.go

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs-site/src/appendixes/quick-reference.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,14 @@ CREATE CONSTANT MyModule.EnableLogging TYPE Boolean DEFAULT true;
9191
| Alter OData service | `ALTER ODATA SERVICE Module.Name SET Key = Value;` | |
9292
| Drop OData service | `DROP ODATA SERVICE Module.Name;` | |
9393
| Show external entities | `SHOW EXTERNAL ENTITIES [IN Module];` | OData-backed entities |
94+
| Show external actions | `SHOW EXTERNAL ACTIONS [IN Module];` | Actions used in microflows |
9495
| Create external entity | `CREATE [OR MODIFY] EXTERNAL ENTITY Module.Name FROM ODATA CLIENT Module.Client (...) (attrs);` | |
9596
| Grant OData access | `GRANT ACCESS ON ODATA SERVICE Module.Name TO Module.Role, ...;` | |
9697
| Revoke OData access | `REVOKE ACCESS ON ODATA SERVICE Module.Name FROM Module.Role, ...;` | |
98+
| Show contract entities | `SHOW CONTRACT ENTITIES FROM Module.Client;` | Browse cached $metadata |
99+
| Show contract actions | `SHOW CONTRACT ACTIONS FROM Module.Client;` | Browse cached $metadata |
100+
| Describe contract entity | `DESCRIBE CONTRACT ENTITY Module.Client.Entity [FORMAT mdl];` | Properties, types, keys |
101+
| Describe contract action | `DESCRIBE CONTRACT ACTION Module.Client.Action [FORMAT mdl];` | Parameters, return type |
97102

98103
**OData Client Example:**
99104
```sql

docs/01-project/MDL_QUICK_REFERENCE.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,14 @@ CREATE CONSTANT MyModule.EnableLogging TYPE Boolean DEFAULT true;
9494
| Alter OData service | `ALTER ODATA SERVICE Module.Name SET Key = Value;` | |
9595
| Drop OData service | `DROP ODATA SERVICE Module.Name;` | |
9696
| Show external entities | `SHOW EXTERNAL ENTITIES [IN Module];` | OData-backed entities |
97+
| Show external actions | `SHOW EXTERNAL ACTIONS [IN Module];` | Actions used in microflows |
9798
| Create external entity | `CREATE [OR MODIFY] EXTERNAL ENTITY Module.Name FROM ODATA CLIENT Module.Client (...) (attrs);` | |
9899
| Grant OData access | `GRANT ACCESS ON ODATA SERVICE Module.Name TO Module.Role, ...;` | |
99100
| Revoke OData access | `REVOKE ACCESS ON ODATA SERVICE Module.Name FROM Module.Role, ...;` | |
101+
| Show contract entities | `SHOW CONTRACT ENTITIES FROM Module.Client;` | Browse cached $metadata |
102+
| Show contract actions | `SHOW CONTRACT ACTIONS FROM Module.Client;` | Browse cached $metadata |
103+
| Describe contract entity | `DESCRIBE CONTRACT ENTITY Module.Client.Entity [FORMAT mdl];` | Properties, types, keys |
104+
| Describe contract action | `DESCRIBE CONTRACT ACTION Module.Client.Action [FORMAT mdl];` | Parameters, return type |
100105

101106
**OData Client Example:**
102107
```sql

mdl-examples/doctype-tests/10-odata-examples.mdl

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,40 @@ SHOW EXTERNAL ACTIONS;
365365
SHOW EXTERNAL ACTIONS IN OdTest;
366366
/
367367

368+
-- ############################################################################
369+
-- LEVEL 10: CONTRACT BROWSING (cached $metadata)
370+
-- ############################################################################
371+
372+
/**
373+
* Level 10.1: Browse entity types from a consumed OData service's cached $metadata
374+
*/
375+
SHOW CONTRACT ENTITIES FROM OdTest.SalesforceAPI;
376+
/
377+
378+
/**
379+
* Level 10.2: Browse actions/functions from the contract
380+
*/
381+
SHOW CONTRACT ACTIONS FROM OdTest.SalesforceAPI;
382+
/
383+
384+
/**
385+
* Level 10.3: Describe a specific entity type from the contract
386+
*/
387+
DESCRIBE CONTRACT ENTITY OdTest.SalesforceAPI.Account;
388+
/
389+
390+
/**
391+
* Level 10.4: Generate CREATE EXTERNAL ENTITY from the contract
392+
*/
393+
DESCRIBE CONTRACT ENTITY OdTest.SalesforceAPI.Account FORMAT mdl;
394+
/
395+
396+
/**
397+
* Level 10.5: Describe a specific action from the contract
398+
*/
399+
DESCRIBE CONTRACT ACTION OdTest.SalesforceAPI.CreateOrder;
400+
/
401+
368402
-- ############################################################################
369403
-- LEVEL 8.8: DROP (cleanup)
370404
-- ############################################################################

mdl/ast/ast_query.go

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@ const (
8080
ShowRestClients // SHOW REST CLIENTS [IN module]
8181
ShowPublishedRestServices // SHOW PUBLISHED REST SERVICES [IN module]
8282
ShowConstantValues // SHOW CONSTANT VALUES [IN module]
83+
ShowContractEntities // SHOW CONTRACT ENTITIES FROM Module.Service
84+
ShowContractActions // SHOW CONTRACT ACTIONS FROM Module.Service
8385
)
8486

8587
// String returns the human-readable name of the show object type.
@@ -187,6 +189,10 @@ func (t ShowObjectType) String() string {
187189
return "PUBLISHED REST SERVICES"
188190
case ShowConstantValues:
189191
return "CONSTANT VALUES"
192+
case ShowContractEntities:
193+
return "CONTRACT ENTITIES"
194+
case ShowContractActions:
195+
return "CONTRACT ACTIONS"
190196
default:
191197
return "UNKNOWN"
192198
}
@@ -203,7 +209,8 @@ func (s *SelectStmt) isStatement() {}
203209
type DescribeStmt struct {
204210
ObjectType DescribeObjectType
205211
Name QualifiedName
206-
WithAll bool // For DESCRIBE MODULE ... WITH ALL
212+
WithAll bool // For DESCRIBE MODULE ... WITH ALL
213+
Format string // For DESCRIBE CONTRACT ... FORMAT mdl
207214
}
208215

209216
func (s *DescribeStmt) isStatement() {}
@@ -238,6 +245,8 @@ const (
238245
DescribeImageCollection // DESCRIBE IMAGE COLLECTION Module.Name
239246
DescribeRestClient // DESCRIBE REST CLIENT Module.Name
240247
DescribePublishedRestService // DESCRIBE PUBLISHED REST SERVICE Module.Name
248+
DescribeContractEntity // DESCRIBE CONTRACT ENTITY Service.EntityName [FORMAT mdl]
249+
DescribeContractAction // DESCRIBE CONTRACT ACTION Service.ActionName [FORMAT mdl]
241250
)
242251

243252
// String returns the human-readable name of the describe object type.
@@ -295,6 +304,10 @@ func (t DescribeObjectType) String() string {
295304
return "REST CLIENT"
296305
case DescribePublishedRestService:
297306
return "PUBLISHED REST SERVICE"
307+
case DescribeContractEntity:
308+
return "CONTRACT ENTITY"
309+
case DescribeContractAction:
310+
return "CONTRACT ACTION"
298311
default:
299312
return "UNKNOWN"
300313
}

0 commit comments

Comments
 (0)