Component diagram - donvadicastro/generator-xmi GitHub Wiki

component generation

  • input interfaces will be transformed into component constructor injected property
  • output interfaces will be transformed into component public methods
// C1
export class C1 extends C1Base {}

// C1.generated
export abstract class C1Base extends ComponentBase implements ... {
    // component own property
    attr1: number = 0;

    // constructor injected IN interface
    constructor(protected in: InContract) {
        super();
    }
    
    // component own method
    fn1(state: any): Promise < any > {
        ...
    }

    // output defined interface methods
    outFn(state: any): Promise < any > {
        ...
    }
}

// C2.generated
export abstract class C2Base extends ComponentBase implements C2Contract, InContract {
    constructor(protected out: outContract) {
        super();
    }

    inFn(state: any): Promise < any > {
        ...
    }
}

// In.interface
export interface InContract {
    inFn(state: any): Promise < any > ;
}

// Out.interface
export interface OutContract {
    outFn(state: any): Promise < any > ;
}

Components dependency generation

components dependency generation

  • TelegramBot and StorageService components depends on ConfidurationService component
  • Dependent component is injected through component constructor
  • Exposed interfaces are represented as component public methods

ConfigurationService.generated

// ConfigurationService.generated
export abstract class ConfigurationServiceBase extends ComponentBase implements ... {
    constructor() { super(); }

    getConfig(state: any): Promise < any > { ... }
}

// StorageService.generated
export abstract class StorageServiceBase extends ComponentBase implements ... {
    constructor(@Inject protected configure: ConfigureContract) {
        super();
    }

    save(state: any): Promise < any > {
        ...
    }
}

// TelegramBot.generated
export abstract class TelegramBotBase extends ComponentBase implements ... {
    constructor(@Inject protected configure: ConfigureContract) {
        super();
    }

    onMessage(state: any): Promise < any > {
        ...
    }
}

// Configure.interface
export interface ConfigureContract {
    getConfig(state: any): Promise < any > ;
}

// Persistense.interface
export interface PersistenseContract {
    save(state: any): Promise < any > ;
}

// Notification.interface
export interface NotificationContract {
    onMessage(state: any): Promise < any > ;
}

Component assembly

Another approach to link dependent component is to use component assembly link. components assembly

In this example "DomainService" explicitly requires "Logger" and "Storage" and these components explicitly provide linkage to parent component.

⚠️ **GitHub.com Fallback** ⚠️