version mise à jour par claude , à tester
This commit is contained in:
@@ -0,0 +1,156 @@
|
||||
/**
|
||||
* Entity Schema Resources
|
||||
* Provides schema information for WMS entity types
|
||||
*/
|
||||
|
||||
function listResources() {
|
||||
return [
|
||||
{
|
||||
uri: 'wms://entity-schemas',
|
||||
name: 'Entity Schemas',
|
||||
description: 'Schema information and common fields for WMS entities',
|
||||
mimeType: 'text/markdown',
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
async function readResource(uri) {
|
||||
let content;
|
||||
|
||||
switch (uri) {
|
||||
case 'wms://entity-schemas':
|
||||
content = getEntitySchemas();
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Error(`Unknown entity schema resource: ${uri}`);
|
||||
}
|
||||
|
||||
return {
|
||||
contents: [{
|
||||
uri,
|
||||
mimeType: 'text/markdown',
|
||||
text: content,
|
||||
}],
|
||||
};
|
||||
}
|
||||
|
||||
function getEntitySchemas() {
|
||||
return `# WMS Entity Schemas
|
||||
|
||||
## Overview
|
||||
|
||||
Entity schemas define the structure and available fields for each entity type.
|
||||
Use the \`get_entity_schema\` tool to retrieve the actual schema from the API by querying one entity.
|
||||
|
||||
## Common Field Patterns
|
||||
|
||||
Most WMS entities follow these patterns:
|
||||
|
||||
### Standard Fields
|
||||
- \`Id\` - Unique identifier (GUID or integer)
|
||||
- \`Code\` - Business code/reference
|
||||
- \`Name\` - Display name
|
||||
- \`Description\` - Detailed description
|
||||
- \`Created\` - Creation timestamp
|
||||
- \`Modified\` - Last modification timestamp
|
||||
- \`Status\` - Entity status
|
||||
|
||||
### Relationship Fields
|
||||
- \`{Entity}Id\` - Foreign key to related entity (e.g., ProductId, AccountId)
|
||||
- \`{Entity}Code\` - Related entity code
|
||||
- \`{Entity}Name\` - Related entity name
|
||||
|
||||
## Entity-Specific Schemas
|
||||
|
||||
### Products
|
||||
Common fields:
|
||||
- Id, Code, Name, Description
|
||||
- Category, Family, SubFamily
|
||||
- Weight, Volume, Height, Width, Length
|
||||
- UnitOfMeasure, BaseUnit
|
||||
- Barcode, AlternativeCodes
|
||||
- Active, Blocked
|
||||
|
||||
### Containers
|
||||
Common fields:
|
||||
- Id, Code, Name, Type
|
||||
- Status, Location, Zone
|
||||
- Weight, Tare, MaxWeight
|
||||
- ProductId, Quantity
|
||||
- Created, Modified
|
||||
|
||||
### Tasks
|
||||
Common fields:
|
||||
- Id, Code, Type, Status
|
||||
- Priority, Sequence
|
||||
- SourceLocation, TargetLocation
|
||||
- ProductId, Quantity
|
||||
- AssignedUser, AssignedDevice
|
||||
- StartedAt, CompletedAt
|
||||
|
||||
### Stocks
|
||||
Common fields:
|
||||
- ProductId, ProductCode, ProductName
|
||||
- LocationId, LocationCode
|
||||
- Quantity, AvailableQuantity, ReservedQuantity
|
||||
- UnitOfMeasure
|
||||
- LotNumber, SerialNumber
|
||||
- ExpirationDate
|
||||
|
||||
### InboundOrders / OutboundOrders
|
||||
Common fields:
|
||||
- Id, Code, ExternalCode
|
||||
- Type, Status, Priority
|
||||
- AccountId, AccountCode, AccountName
|
||||
- SupplierId, SupplierCode (inbound only)
|
||||
- ExpectedDate, PlannedDate, ActualDate
|
||||
- TotalLines, TotalQuantity
|
||||
- Created, Modified
|
||||
|
||||
## Retrieving Schemas
|
||||
|
||||
Use the \`get_entity_schema\` tool to dynamically retrieve the schema:
|
||||
|
||||
\`\`\`
|
||||
# Get Products schema
|
||||
get_entity_schema(entity_type="Products")
|
||||
|
||||
# Get Tasks schema
|
||||
get_entity_schema(entity_type="Tasks")
|
||||
\`\`\`
|
||||
|
||||
This will query one entity from the API and return all available fields with sample values.
|
||||
|
||||
## LINQ Field Selection
|
||||
|
||||
You can select specific fields using LINQ expressions:
|
||||
|
||||
\`\`\`
|
||||
# Select specific fields
|
||||
query_wms_entities(
|
||||
entity_type="Products",
|
||||
select_expression="z => new { z.Id, z.Code, z.Name, z.Category }"
|
||||
)
|
||||
|
||||
# Nested object creation
|
||||
query_wms_entities(
|
||||
entity_type="Tasks",
|
||||
select_expression="z => new {
|
||||
Task = z.Code,
|
||||
Product = z.ProductName,
|
||||
Status = z.Status
|
||||
}"
|
||||
)
|
||||
\`\`\`
|
||||
|
||||
---
|
||||
|
||||
**Note:** Field availability may vary depending on WMS configuration and version.
|
||||
`;
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
listResources,
|
||||
readResource,
|
||||
};
|
||||
Reference in New Issue
Block a user