export declare const gsbSchemaMarkdown = "\n# GSB Schema Management Guide\n\n## Table of Contents\n1. [Overview](#overview)\n2. [Schema Creation Best Practices](#schema-creation-best-practices)\n3. [Core Schema Types](#core-schema-types)\n4. [Entity Definition Management](#entity-definition-management)\n5. [Property Management](#property-management)\n6. [Schema Operations](#schema-operations)\n7. [Best Practices](#best-practices)\n\n## Overview\n\nGSB (Generic Service Backend) provides a comprehensive framework for defining and managing data schemas through entity definitions. This guide covers how to work with GSB schema components to create, read, update, and delete data tables and their properties.\n\n## Schema Creation Best Practices\n\n### Creating Initial Schema\n\nWhen creating an initial schema with multiple related entity definitions:\n\n1. **Create entity definitions without reference types first**:\n   - Build all your base entity definitions with standard properties (string, number, etc.)\n   - Save these entities before adding reference properties\n\n2. **Add reference properties in a second pass**:\n   - After all entity definitions exist, add reference properties\n   - GSB automatically manages the bidirectional relationship\n\n### Reference Property Management\n\nWhen adding reference properties between entities:\n\n1. **Add reference to only one entity**: \n   - Only add the reference property to one of the related entity definitions\n   - Specify the correct `refEntDef_id` and `refEntPropName`\n   - GSB automatically adds the corresponding reference property to the other definition\n\n2. **Foreign key handling**:\n   - For single relationships (OneToOne, ManyToOne), GSB automatically adds an `_id` property\n   - For example, adding `customer` ref property to an Order entity will automatically create `customer_id` field\n\n3. **Bidirectional management**:\n   - When you delete a reference property, GSB automatically removes:\n     - The corresponding reference property in the related entity\n     - Any automatically created foreign key fields\n\n### Example\n\n```typescript\n// Example: Customer has Orders, Order has Customer\n\n// 1. First create basic entity definitions\nawait entityDefService.createDataTable(\n  'Customer',                    \n  'Customer Information',        \n  'Stores customer data'         \n);\n\nawait entityDefService.createDataTable(\n  'Order',                    \n  'Order Information',        \n  'Stores order data'         \n);\n\n// 2. Then add the reference property to just one entity\nawait entityDefService.addColumn(\n  'customer-entity-id', // Customer entity\n  {\n    name: 'orders',\n    title: 'Orders',\n    description: 'Customer orders',\n    definition_id: '924acba8-58c5-4881-940d-472ec01eba5f', // Reference type\n    refEntDef_id: 'order-entity-id', // Order entity\n    refEntPropName: 'customer', // Name of property in Order entity\n    refType: RefType.OneToMany\n  }\n);\n\n// GSB automatically:\n// 1. Adds 'customer' property to Order entity\n// 2. Adds 'customer_id' to Order entity for the database relationship\n```\n\n## Core Schema Types\n\n### Entity Definition (GsbEntityDef)\n\nThe `GsbEntityDef` interface represents a data table in the GSB system:\n\n```typescript\nexport interface GsbEntityDef {\n  id?: string;                        // Unique identifier\n  name?: string;                      // Entity name (must be unique)\n  title?: string;                     // Display title\n  description?: string;               // Description\n  dbTableName?: string;               // Database table name\n  publicAccess?: boolean;             // Whether entity is publicly accessible\n  activityLogLevel?: ActivityLogLevel; // Level of activity logging\n  properties?: GsbProperty[];         // Array of properties (columns)\n  isActive?: boolean;                 // Whether entity is active\n  isDeleted?: boolean;                // Whether entity is deleted\n  createDate?: Date;                  // Creation date (system-managed)\n  lastUpdateDate?: Date;              // Last update date (system-managed)\n  createdBy_id?: string;              // Creator ID (system-managed)\n  lastUpdatedBy_id?: string;          // Last updater ID (system-managed)\n  permissions?: GsbPermission[];      // Entity permissions\n  workflowTriggers?: GsbWorkflowTrigger[]; // Associated workflow triggers\n}\n```\n\n### Property (GsbProperty)\n\nThe `GsbProperty` interface represents a column in a data table:\n\n```typescript\nexport interface GsbProperty {\n  id?: string;                     // Unique identifier\n  name?: string;                   // Property name (must be unique within entity)\n  title?: string;                  // Display title\n  description?: string;            // Description\n  definition_id?: string;          // Reference to property definition (data type)\n  orderNumber?: number;            // Display order\n  isRequired?: boolean;            // Whether property is required\n  isSearchable?: boolean;          // Whether property is searchable\n  isUnique?: boolean;              // Whether property must have unique values\n  isPrimaryKey?: boolean;          // Whether property is a primary key\n  isIndexed?: boolean;             // Whether property is indexed\n  maxLength?: number;              // Maximum length (for strings)\n  defaultValue?: string;           // Default value\n  \n  // Reference properties\n  refEntDef_id?: string;           // Referenced entity definition ID\n  refEntPropName?: string;         // Property name in referenced entity\n  refType?: RefType;               // Reference type (OneToOne, OneToMany, etc.)\n  \n  // UI control properties\n  formModes?: number;              // Form modes where property is visible\n  listScreens?: ScreenType;        // List screens where property is visible\n  \n  // Additional properties\n  enum_id?: string;                // Enum ID (for enum properties)\n  isMultiLingual?: boolean;        // Whether property supports multiple languages\n  isEncrypted?: boolean;           // Whether property value is encrypted\n  regex?: string;                  // Validation regex pattern\n  \n  // System properties\n  isDefault?: boolean;             // Whether it's a default property\n  type?: string;                   // Property type name\n}\n```\n\n### Property Definition (GsbPropertyDef)\n\nThe `GsbPropertyDef` interface represents a data type definition:\n\n```typescript\nexport interface GsbPropertyDef {\n  id: string;                      // Unique identifier\n  dataType: DataType;              // Data type enum value\n  title: string;                   // Display title\n  name: string;                    // Type name\n  description?: string;            // Description\n  maxLength?: number;              // Maximum length\n  scale?: number;                  // Scale (for decimal numbers)\n  regex?: string;                  // Default validation regex\n  usage?: number;                  // Usage counter\n  createDate?: Date;               // Creation date\n  lastUpdateDate?: Date;           // Last update date\n  defaultControlComponent?: {      // Default UI component\n    title: string;\n    id: string;\n  };\n}\n```\n\n## Entity Definition Management\n\n### Creating an Entity Definition\n\nTo create a new data table, use the `EntityDefService`:\n\n```typescript\nimport { EntityDefService } from '@gsb-core/core';\n\nconst entityDefService = EntityDefService.getInstance();\n\n// Create a basic data table\nconst tableId = await entityDefService.createDataTable(\n  'Customer',                    // Table name\n  'Customer Information',        // Display title\n  'Stores customer data'         // Description\n);\n\n// Create a more complex entity definition\nconst entityDef: GsbEntityDef = {\n  name: 'Product',\n  title: 'Product Catalog',\n  description: 'Product information and inventory data',\n  properties: [\n    // Default properties will be added automatically\n    // Add custom properties\n    {\n      name: 'price',\n      title: 'Price',\n      description: 'Product price',\n      definition_id: '35efcf9c-fff0-44d4-8972-73a9a32b93fa', // Number type\n      isRequired: true,\n      isSearchable: false,\n      orderNumber: 10\n    },\n    {\n      name: 'category',\n      title: 'Category',\n      description: 'Product category',\n      definition_id: 'c6c34bf3-f51b-4e69-a689-b09847be74b9', // String type\n      isSearchable: true,\n      orderNumber: 11\n    }\n  ]\n};\n\nconst entityId = await entityDefService.createEntityDef(entityDef);\n```\n\n### Default Properties\n\n1. `id` - Primary key (UUID), Required\n2. `title` - Display title, better to define automated form builders use this field\n3. `createdBy` - User who created the record (If a property with this name is defined GSB will atuomatically set its value)\n4. `lastUpdatedBy` - User who last updated the record (If a property with this name is defined GSB will atuomatically set its value)\n5. `createDate` - Creation timestamp (If a property with this name is defined GSB will atuomatically set its value)\n6. `lastUpdateDate` - Last update timestamp (If a property with this name is defined GSB will atuomatically set its value)\n\n### Retrieving Entity Definitions\n\n```typescript\n// Get by ID\nconst entityDef = await entityDefService.getEntityDefById('entity-id');\n\n// Get by name\nconst customerTable = await entityDefService.getDataTableByName('Customer');\n\n// Get all tables with pagination\nconst { entityDefs, totalCount } = await entityDefService.getEntityDefs(1, 10);\n\n// Search for tables\nconst { entityDefs, totalCount } = await entityDefService.searchEntityDefs('customer', 1, 10);\n\n// Get all tables\nconst allTables = await entityDefService.getAllDataTables();\n```\n\n### Updating Entity Definitions\n\n```typescript\n// Update an entity definition\nconst entityDef = await entityDefService.getEntityDefById('entity-id');\nif (entityDef) {\n  entityDef.title = 'Updated Title';\n  entityDef.description = 'Updated description';\n  \n  const success = await entityDefService.updateEntityDef(entityDef);\n}\n```\n\n### Deleting Entity Definitions\n\n```typescript\n// Soft delete (sets isDeleted flag)\nconst success = await entityDefService.deleteEntityDef('entity-id');\n\n// Permanent delete (removes table and data)\nconst success = await entityDefService.permanentlyDeleteDataTable('entity-id');\n```\n\n## Property Management\n\n### Adding Properties\n\n```typescript\n// Add a simple string property\nawait entityDefService.addColumn(\n  'entity-id',\n  {\n    name: 'address',\n    title: 'Address',\n    description: 'Customer address',\n    definition_id: 'c6c34bf3-f51b-4e69-a689-b09847be74b9', // String type\n    isSearchable: true\n  }\n);\n\n// Add a reference property\nawait entityDefService.addColumn(\n  'entity-id',\n  {\n    name: 'category',\n    title: 'Category',\n    description: 'Product category',\n    definition_id: '924acba8-58c5-4881-940d-472ec01eba5f', // Reference type\n    refEntDef_id: 'category-entity-id',\n    refEntPropName: 'products',\n    refType: RefType.OneToMany\n  }\n);\n```\n\n### Common Property Types\n\nGSB provides several pre-defined property types:\n\n| Type | Definition ID | Description |\n|------|--------------|-------------|\n| ID | 5c0aa76f-9c32-4e7e-a4bc-b56e93877883 | Unique identifier |\n| String | c6c34bf3-f51b-4e69-a689-b09847be74b9 | Text string |\n| Number | 35efcf9c-fff0-44d4-8972-73a9a32b93fa | Numeric value |\n| Boolean | 7868afdf-2709-45be-87e3-87de8d35f30f | True/false value |\n| DateTime | 12e647e0-ebd2-4ec2-a4e3-82c1dfe07da2 | Date and time |\n| Reference | 924acba8-58c5-4881-940d-472ec01eba5f | Entity reference |\n| Enum | 7bf08f4f-7de0-469e-bbfb-f4c43762f4d7 | Enumerated value |\n| RichText | e07f578e-2705-49c1-b97f-3ca5963c67c0 | Rich text content |\n| Email | df7ce94b-d59c-4b67-8519-aa4c98ab477c | Email address |\n| Password | 7291fbc2-a7cf-4713-a876-0cff085cc035 | Password field |\n\n### Removing Properties\n\n```typescript\n// Remove a property by name\nawait entityDefService.removeColumn('entity-id', 'propertyName');\n\n// Remove a property by ID\nawait entityDefService.removeColumn('entity-id', 'property-id');\n```\n\n## Schema Operations\n\n### Checking Name Uniqueness\n\nBefore creating a new entity or property, check if the name is already used:\n\n```typescript\n// Check entity name uniqueness\nconst { entityDefs } = await entityDefService.checkNameUniqueness('Customer');\nconst isNameUnique = entityDefs.length === 0;\n\n// Check reference property name uniqueness\nconst { isValid, validationMessage } = await entityDefService.checkRefPropNameUniqueness(\n  'products',\n  'category-entity-id'\n);\n```\n\n### Working with References\n\nGSB supports different types of entity relationships:\n\n```typescript\nenum RefType {\n  OneToOne = 1,\n  OneToMany = 2,\n  ManyToOne = 3,\n  ManyToMany = 4\n}\n```\n\nWhen creating a reference property:\n\n1. Set `definition_id` to the Reference type ID\n2. Set `refEntDef_id` to the referenced entity's ID\n3. Set `refEntPropName` to create a back-reference property in the referenced entity\n4. Set `refType` to define the relationship type\n\nExample:\n\n```typescript\n// Create a one-to-many relationship from Category to Product\nawait entityDefService.addColumn(\n  'product-entity-id',\n  {\n    name: 'category',\n    title: 'Category',\n    definition_id: '924acba8-58c5-4881-940d-472ec01eba5f', // Reference type\n    refEntDef_id: 'category-entity-id',\n    refEntPropName: 'products', // Creates a 'products' property in Category entity\n    refType: RefType.ManyToOne\n  }\n);\n```\n\n## Best Practices\n\n### Entity Definition Naming\n\n1. **Use PascalCase for entity names**: `Customer`, `ProductCategory`, `OrderItem`\n2. **Use singular nouns**: `Product` instead of `Products`\n3. **Be descriptive but concise**: `CustomerAddress` instead of `CustAddr` or `CustomerAddressInformation`\n4. **Avoid special characters**: Use only letters, numbers, and underscores\n5. **Start with a letter**: Entity names must start with a letter\n\n### Property Naming\n\n1. **Use camelCase for property names**: `firstName`, `orderDate`, `productCategory`\n2. **Be descriptive**: `customerAddress` instead of `custAddr`\n3. **Use consistent naming patterns**: `createDate`/`updateDate` instead of mixing `createDate`/`modifiedOn`\n4. **Prefix boolean properties with 'is' or 'has'**: `isActive`, `hasAttachments`\n\n### Schema Design\n\n1. **Normalize appropriately**: Break down complex entities into related tables\n2. **Use references instead of duplicating data**: Link to a Customer entity instead of duplicating customer fields\n3. **Add appropriate indexes**: Mark frequently searched fields as `isIndexed: true`\n4. **Set searchable fields**: Mark fields that should be included in search as `isSearchable: true`\n5. **Define required fields**: Mark mandatory fields as `isRequired: true`\n6. **Set appropriate field lengths**: Define `maxLength` for string fields\n\n### Performance Considerations\n\n1. **Cache entity definitions**: GSB automatically caches entity definitions\n2. **Limit the number of properties**: Too many columns can impact performance\n3. **Use appropriate data types**: Use the most specific type for each property\n4. **Index wisely**: Only index fields used in filters and sorts\n5. **Use reference relationships appropriately**: Choose the right relationship type\n\n### Security Best Practices\n\n1. **Set appropriate permissions**: Define who can view and modify each entity\n2. **Mark sensitive fields as encrypted**: Use `isEncrypted: true` for sensitive data\n3. **Use publicAccess flag carefully**: Only set `publicAccess: true` when necessary\n4. **Implement field-level security**: Control which users can see specific fields\n5. **Audit important changes**: Set appropriate `activityLogLevel` \n";
