All files / src/core-entities custom-variable.entity.ts

100% Statements 11/11
100% Branches 0/0
100% Functions 0/0
100% Lines 9/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 5345x 45x 45x                   45x             45x             45x               45x               45x               45x    
import { Entity, Column } from 'typeorm';
import { ApiProperty } from '@nestjs/swagger';
import { BaseEntity } from './base.entity';
 
/**
 * CustomVariable is a key-value pair available in context templates.
 * Access via it.variables.KEY in Eta templates.
 *
 * Use for frequently changing values like API endpoints, author names, etc.
 * Variables can be enabled/disabled and ordered by usage frequency.
 */
@Entity('custom_variables')
export class CustomVariable extends BaseEntity {
  @ApiProperty({
    description:
      'Unique key for this variable (used in templates as it.variables.KEY)',
    example: 'author_name',
  })
  @Column({ type: 'text', unique: true })
  key: string;
 
  @ApiProperty({
    description: 'Value of this variable',
    example: 'John Developer',
  })
  @Column({ type: 'text' })
  value: string;
 
  @ApiProperty({
    description: 'Whether this variable is enabled',
    example: true,
    default: true,
  })
  @Column({ type: 'boolean', default: true })
  enabled: boolean;
 
  @ApiProperty({
    description: 'Whether this variable is frequently used (for sorting)',
    example: false,
    default: false,
  })
  @Column({ type: 'boolean', default: false })
  is_freq_used: boolean;
 
  @ApiProperty({
    description: 'Display order (lower numbers appear first)',
    example: 0,
    default: 0,
  })
  @Column({ type: 'int', default: 0 })
  order_number: number;
}