/**
 * Documentation for the getEntityDef operation
 */

/**
 * Returns documentation for the getEntityDef operation
 * @return {string} markdown documentation
 */
export function getEntityDefDocs(): string {
  return `
# GetEntityDef Operation

## General Description

The \`getEntityDef\` operation retrieves an entity definition by its ID or name.

## Detailed Description

This operation allows you to fetch the complete definition of an entity type, including all its properties, relationships, and metadata. Entity definitions represent the schema or blueprint for entities in the system, defining their structure, validation rules, and relationships to other entities.

## Input Parameters

| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| entityDef | object | Yes | The entity definition identifier. Object containing either the \`id\` (string) or \`name\` (string) of the entity definition to retrieve. One of these must be provided. |
| token | string | No | Authentication token for your request. If not provided, the system will use the default API key from environment variables. |
| tenantCode | string | No | Tenant code to specify which tenant's data to access. If not provided, the system will extract it from the token or use the default tenant code from environment variables. |

## Response

### Success Response

\`\`\`json
{
    "success": true,
    "data": {
        "id": "string",
        "name": "string",
        "title": "string",
        "description": "string",
        "dbTableName": "string",
        "publicAccess": boolean,
        "activityLogLevel": number,
        "properties": [
            {
                "id": "string",
                "name": "string",
                "title": "string",
                "description": "string",
                "definition_id": "string",
                "orderNumber": number,
                "isRequired": boolean,
                "isSearchable": boolean,
                "isUnique": boolean,
                "isPrimaryKey": boolean,
                "isIndexed": boolean,
                "maxLength": number,
                "defaultValue": "string",
                "regex": "string",
                "refEntDef_id": "string",
                "refEntPropName": "string",
                "refType": number
            }
        ],
        "isActive": boolean,
        "isDeleted": boolean,
        "createDate": "string",
        "lastUpdateDate": "string",
        "createdBy_id": "string",
        "lastUpdatedBy_id": "string",
        "permissions": [
            // Permission objects
        ],
        "workflowTriggers": [
            // Workflow trigger objects
        ]
    }
}
\`\`\`

### Error Response

\`\`\`json
{
    "success": false,
    "error": "Error message describing what went wrong"
}
\`\`\`

## Example Usage

### Get Entity Definition by ID

\`\`\`typescript
const result = await getEntityDef({
  entityDef: { id: "entity-def-id-123" }
});

if (result.success) {
  const entityDef = result.entityDef;
  console.log("Entity Definition:", entityDef.name);
  console.log("Properties:", entityDef.properties.length);
} else {
  console.error("Error:", result.error);
}
\`\`\`

### Get Entity Definition by Name

\`\`\`typescript
const result = await getEntityDef({
  entityDef: { name: "Customer" },  
});

if (result.success) {
  const entityDef = result.entityDef;
  console.log("Entity Definition ID:", entityDef.id);
  console.log("Title:", entityDef.title);
  console.log("Description:", entityDef.description);
  
  // Access properties
  entityDef.properties.forEach(prop => {
    console.log(\`Property: \${prop.name}, Title: \${prop.title}, Type: \${prop.definition_id}\`);
  });
} else {
  console.error("Error:", result.error);
}
\`\`\`

## Additional Information

- The getEntityDef operation is used to retrieve the complete definition of an entity type.
- You can retrieve an entity definition by either its ID or its name.
- The response includes all properties defined for the entity, including their data types, validation rules, and relationships.
- Entity definitions are the foundation for working with entities in the system:
  - They define the structure and validation rules for entities
  - They establish relationships between different entity types
  - They control permissions and access control for entities
- For retrieving multiple entity definitions, use the queryEntityDefs operation.
- For creating new entity definitions, use the createEntityDef operation.
- For updating existing entity definitions, use the updateEntityDef operation.
- Access permissions are enforced based on the provided token.
`;
}

/**
 * Returns a brief summary of the getEntityDef operation.
 * @return {string} A short description of the function.
 */
export function getEntityDefSummary(): string {
  return `
**Purpose**: Retrieves complete entity definition (schema) by ID or name.

**When to use**:
- Need schema information
- Exploring entity structure
- Creating/validating entities
- Building dynamic interfaces

**Inputs**:
- entityDef: Object with either id or name {id/name: string}
- token (optional)
- tenantCode (optional)

**Returns**: {success: boolean, entityDef: object} Full entity definition with all properties, relationships, and metadata.
`;
}

export default getEntityDefDocs; 