All files / src/entities component.ts

84.61% Statements 33/39
0% Branches 0/3
50% Functions 1/2
86.11% Lines 31/36

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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93    1x 1x     1x 1x 1x 1x   1x     1x     1x     1x     1x     1x     1x     1x     1x     1x     1x     1x     1x     1x     1x     1x     1x     1x     1x     1x     1x     1x     1x     1x                     1x  
import { ComponentTag } from './component_tag.js';
import { ComponentVersion } from './component_version.js';
import { Entity } from '../entity.js';
import { MerchiFile } from './file.js';
import { User } from './user.js';
 
export class Component extends Entity {
  protected static resourceName = 'components';
  protected static singularName = 'component';
  protected static pluralName = 'components';
 
  @Component.property({type: Date})
  public archived?: Date | null;
 
  @Component.property({type: Date})
  public created?: Date;
 
  @Component.property({type: Date})
  public updated?: Date;
 
  @Component.property()
  public id?: number;
 
  @Component.property()
  public isClassBased?: boolean;
 
  @Component.property()
  public outOfSyncWithOriginal?: boolean;
 
  @Component.property()
  public needsUpdate?: boolean;
 
  @Component.property()
  public hasImports?: number;
 
  @Component.property()
  public isClone?: boolean;
 
  @Component.property()
  public warnings?: boolean;
 
  @Component.property()
  public name?: string;
 
  @Component.property()
  public body?: string;
 
  @Component.property()
  public description?: string;
 
  @Component.property()
  public compiled?: string;
 
  @Component.property({type: 'Component'})
  public componentExport?: Component;
 
  @Component.property({arrayType: 'Component'})
  public componentExports?: Component[];
 
  @Component.property({arrayType: 'Component'})
  public componentImports?: Component[];
 
  @Component.property({type: 'Component'})
  public originalComponent?: Component;
 
  @Component.property({arrayType: 'MerchiFile'})
  public images?: MerchiFile[];
 
  @Component.property({type: MerchiFile})
  public featureImage?: MerchiFile | null;
 
  @Component.property({arrayType: 'ComponentTag'})
  public tags?: ComponentTag[];
 
  @Component.property({type: 'User'})
  public createdBy?: User | null;
 
  @Component.property({type: 'User'})
  public updatedBy?: User | null;
 
  @Component.property({arrayType: 'ComponentVersion'})
  public versions?: ComponentVersion[];
 
  public toReact = (context: any) => {
    const componentCode = 'with (this) { ' + this.compiled + ' return ' +
      this.name + ';}';
    const proxy = new Proxy(context, {});
    const callable = new Function(componentCode);
    return callable.call(proxy);
  };
 
}