|
| 1 | +--- |
| 2 | +title: Taxonomies |
| 3 | +sidebar_label: Taxonomies |
| 4 | +--- |
| 5 | + |
| 6 | +# Taxonomies |
| 7 | + |
| 8 | +Taxonomies in epilot provide a powerful labeling and classification system for organizing entities, relations, and files. They enable consistent categorization and improve searchability across the platform. |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + |
| 13 | +## Overview |
| 14 | + |
| 15 | +Taxonomies are hierarchical classification systems that allow you to create and manage labels for different types of data in epilot. The system supports three main taxonomy types, each with specific prefixes: |
| 16 | + |
| 17 | +- **Entity Labels** - Classification for entities (`_schema_` prefix for standalone labels or any slug not starting with `_relation_` or `_system_`) |
| 18 | +- **Relation Labels** - Classification for entity relationships (`_relation_` prefix) |
| 19 | +- **System Collections** - Organization for document groups (`_system_` prefix) |
| 20 | + |
| 21 | +## Entity Labels |
| 22 | + |
| 23 | +Entity labels provide a way to categorize and classify entities within your schemas. They help organize entities by their business purpose, status, or any other relevant classification. |
| 24 | + |
| 25 | +### Structure |
| 26 | +```typescript |
| 27 | +type EntityStandardFamilySlug = `_schema_${string}` |
| 28 | +type EntityStandardFamilyLabelSlug = `_schema_${string}:${string}` |
| 29 | +``` |
| 30 | +
|
| 31 | +### Use Cases |
| 32 | +- Categorizing customers by type (e.g., residential, commercial) |
| 33 | +- Marking entity status (e.g., active, archived, pending) |
| 34 | +- Grouping entities by business processes |
| 35 | +- Flagging entities for specific workflows |
| 36 | +
|
| 37 | +### System Labels |
| 38 | +Entity schemas include predefined system labels that are locked and cannot be modified: |
| 39 | +- `__hidden` - Marks entities as hidden from standard views |
| 40 | +- `copy` - Indicates an entity is a copy |
| 41 | +- `merged` - Marks entities that have been merged |
| 42 | +- `composite` - Identifies composite entities |
| 43 | +- `automation` - Related to automated processes |
| 44 | +- `bulk-generated` - Entities created through bulk operations |
| 45 | +
|
| 46 | +The reason for this is simple, our system produces some of these labels depending on certain actions, like bulk operations, or system actions, like duplicating entities. Enabling users to modify these labels wouldn't serve much of purpose since those labels would keep coming back. For this reason, the system locks these labels. |
| 47 | +
|
| 48 | +## Purposes |
| 49 | +
|
| 50 | +Purposes are a special type of taxonomy that define the business purpose or intent of a given entity, but not exclusively. Purposes are also used to control visibility of attributes and groups of fields within an entity. They provide semantic meaning to entity data. |
| 51 | +
|
| 52 | +### Key Characteristics |
| 53 | +- Purposes exist as a standalone taxonomy family with slug `purpose` |
| 54 | +- They can be applied to any entity, attribute or group of fields to clarify its business context |
| 55 | +- They can be used to control visibility of attributes and groups of fields within an entity |
| 56 | +
|
| 57 | +## Relation Labels |
| 58 | +
|
| 59 | +Relation labels classify the connections between entities, providing additional context about the nature of relationships. |
| 60 | +
|
| 61 | +### Structure |
| 62 | +```typescript |
| 63 | +type RelationSystemFamilySlug = `_relation_${string}` |
| 64 | +type RelationSystemFamilyLabelSlug = `_relation_${string}:${string}` |
| 65 | +``` |
| 66 | +
|
| 67 | +### Predefined Relation Labels |
| 68 | +
|
| 69 | +The system includes predefined relation labels for common entity types: |
| 70 | +
|
| 71 | +#### Address Relations |
| 72 | +- `_relation_address:billing` - Billing address |
| 73 | +- `_relation_address:delivery` - Delivery address |
| 74 | +
|
| 75 | +#### Account Relations |
| 76 | +- `_relation_account:customer` - Customer account |
| 77 | +- `_relation_account:installer` - Installer account |
| 78 | +- `_relation_account:planner` - Planner account |
| 79 | +- `_relation_account:onsite_contact` - On-site contact |
| 80 | +- `_relation_account:architect` - Architect account |
| 81 | +- `_relation_account:supplier` - Supplier account |
| 82 | +
|
| 83 | +#### Contact Relations |
| 84 | +- `_relation_contact:customer` - Customer contact |
| 85 | +- `_relation_contact:installer` - Installer contact |
| 86 | +- `_relation_contact:planner` - Planner contact |
| 87 | +- `_relation_contact:onsite_contact` - On-site contact |
| 88 | +- `_relation_contact:architect` - Architect contact |
| 89 | +- `_relation_contact:supplier` - Supplier contact |
| 90 | +
|
| 91 | +### Benefits |
| 92 | +- Enables filtering relationships by type |
| 93 | +- Improves data navigation and discovery |
| 94 | +- Supports business logic based on relationship types |
| 95 | +
|
| 96 | +## File Collections |
| 97 | +
|
| 98 | +File collections provide a way to organize and group documents and files within epilot, supporting both global collections and entity-specific collections. |
| 99 | +
|
| 100 | +### Structure |
| 101 | +```typescript |
| 102 | +type FileCollectionSystemFamilySlug = `_system_files_collection_schema_${string}` |
| 103 | +type FileCollectionSystemFamilyLabelSlug = `_system_files_collection_schema_${string}:${string}` |
| 104 | +``` |
| 105 | +
|
| 106 | +### Types of File Collections |
| 107 | +
|
| 108 | +#### Global Collections |
| 109 | +- System-wide file groupings accessible across all entities |
| 110 | +- Used for shared documents, templates, and resources |
| 111 | +- Examples: Company policies, standard contracts, marketing materials |
| 112 | +
|
| 113 | +#### Per-Entity Collections (also called User Collections, since they are personal to each user) |
| 114 | +- Collections specific to individual entity schemas |
| 115 | +- Organize documents related to specific entity types |
| 116 | +- Examples: Customer contracts, project documentation, compliance certificates |
| 117 | +
|
| 118 | +### Use Cases |
| 119 | +- Document categorization by type or purpose |
| 120 | +- Compliance document management |
| 121 | +- Project file organization |
| 122 | +- Template and resource libraries |
| 123 | +- Attachment classification |
| 124 | +
|
| 125 | +## Working with Taxonomies |
| 126 | +
|
| 127 | + |
| 128 | +
|
| 129 | +### Label Structure |
| 130 | +
|
| 131 | +All taxonomy labels follow a consistent structure: |
| 132 | +```typescript |
| 133 | +{ |
| 134 | + id: string, // Unique identifier |
| 135 | + slug: string, // Formatted slug with prefix |
| 136 | + name: string // Display name |
| 137 | +} |
| 138 | +``` |
| 139 | +
|
| 140 | +### System Functions |
| 141 | +
|
| 142 | +The platform provides utility functions for working with taxonomies: |
| 143 | +
|
| 144 | +- `isEntitySystemFamilyOrSlug()` - Check if a slug is an entity taxonomy |
| 145 | +- `isRelationSystemFamilyOrSlug()` - Check if a slug is a relation taxonomy |
| 146 | +- `isFileCollectionSystemFamilyOrSlug()` - Check if a slug is a file collection |
| 147 | +- `getSchemaFromSystemFamilySlug()` - Extract schema name from taxonomy slug |
| 148 | +- `getLabelSlugFromSystemLabel()` - Extract label portion from full slug |
| 149 | +
|
| 150 | +### Locked System Labels |
| 151 | +
|
| 152 | +Some labels are system-defined and locked, meaning they: |
| 153 | +- Cannot be deleted or modified |
| 154 | +- Are consistently available across all instances |
| 155 | +- Support core platform functionality |
| 156 | +- Include special handling in the application logic |
| 157 | +
|
| 158 | +
|
| 159 | +### Permissions |
| 160 | +
|
| 161 | +Taxonomy operations require specific permissions: |
| 162 | +- `label_builder:create` - Create taxonomies and classifications |
| 163 | +- `label_builder:edit` - Update existing labels |
| 164 | +- `label_builder:delete` - Delete labels |
| 165 | +
|
| 166 | +### Error Handling |
| 167 | +
|
| 168 | +Common API errors: |
| 169 | +- `TaxonomyNotFoundError` - Returns 404 |
| 170 | +- `TaxonomyAlreadyExistsError` - Returns 409 Conflict |
| 171 | +- `TaxonomyValidationError` - Returns 400 Bad Request |
| 172 | +- `TaxonomyInUseError` - Returns 400 when trying to delete taxonomy in use |
| 173 | +- `RelationTaxonomyClassificationDeletionNotAllowedError` - Returns 403 for protected items |
| 174 | +
|
| 175 | +### Bulk Operations |
| 176 | +
|
| 177 | +The API supports bulk operations for efficiency: |
| 178 | +
|
| 179 | +```typescript |
| 180 | +// Bulk classification update |
| 181 | +POST /v1/entity/taxonomies/{taxonomySlug}/classifications |
| 182 | +{ |
| 183 | + "create": [ |
| 184 | + { "id": "uuid", "name": "New Label", "slug": "new-label" } |
| 185 | + ], |
| 186 | + "update": [ |
| 187 | + { "id": "existing-id", "name": "Updated Name" } |
| 188 | + ], |
| 189 | + "delete": [ |
| 190 | + { "id": "id-to-delete" } |
| 191 | + ] |
| 192 | +} |
| 193 | +``` |
| 194 | +
|
| 195 | +### Search and Filtering |
| 196 | +
|
| 197 | +Advanced search capabilities: |
| 198 | +```typescript |
| 199 | +// Search with patterns |
| 200 | +POST /v1/entity/taxonomies/classifications/search |
| 201 | +{ |
| 202 | + "classificationIds": [ |
| 203 | + { "pattern": "customer*" }, // Wildcard search |
| 204 | + "specific-id" // Exact match |
| 205 | + ] |
| 206 | +} |
| 207 | +``` |
| 208 | +
|
| 209 | +### Integration Example |
| 210 | +
|
| 211 | +```typescript |
| 212 | +import { getEntityClient } from '@epilot/entity-client'; |
| 213 | + |
| 214 | +const client = getEntityClient(); |
| 215 | + |
| 216 | +// Create a new taxonomy |
| 217 | +const taxonomy = await client.createTaxonomy({}, { |
| 218 | + slug: 'project-status', |
| 219 | + name: 'Project Status', |
| 220 | + type: 'entity', |
| 221 | + enabled: true |
| 222 | +}); |
| 223 | + |
| 224 | +// Add classifications |
| 225 | +await client.updateClassifications({ |
| 226 | + taxonomySlug: 'project-status' |
| 227 | +}, { |
| 228 | + create: [ |
| 229 | + { id: 'uuid-1', name: 'Planning', slug: 'planning' }, |
| 230 | + { id: 'uuid-2', name: 'In Progress', slug: 'in-progress' }, |
| 231 | + { id: 'uuid-3', name: 'Completed', slug: 'completed' } |
| 232 | + ] |
| 233 | +}); |
| 234 | + |
| 235 | +// Search classifications |
| 236 | +const results = await client.searchClassifications({ |
| 237 | + taxonomySlug: 'project-status', |
| 238 | + query: 'progress', |
| 239 | + include_archived: 'false' |
| 240 | +}); |
| 241 | +``` |
| 242 | + |
| 243 | +For detailed API documentation, refer to the [Taxonomy API Reference](https://docs.epilot.io/api/entity#tag/Taxonomy). |
0 commit comments