JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 813
  • Score
    100M100P100Q100474F
  • License ISC

NGRX to Plant UML diagram

Package Exports

  • ngrx-uml

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ngrx-uml) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

ngrx-uml

Generate Plant UML diagram from ngrx/store project (version > 7.0).

Generate separete diagram for each Action.

Searches for actions created function createAction and their use.

Installation

Node Package Node.js

To download and install the ngrx-um run the following command:

npm install -g ngrx-uml

Commands

Invoke the tool on the command line through the ngrx-uml executable.

The command ngrx-uml --help lists the available commands. ngrx-uml <command> --help shows available options for the (such as diagram).

ng --help
ng diagram --help
Command Description
diagram Generate plantUML diagram
diagnostic Diagnostic tools

Diagram Command

Usage:

ngrx-uml diagram -f '**/*ts' -d ../ngrx/projects/example-app/ -i '../**/*.spec.ts' -c tsconfig.app.json

*** Glob-like file patterns must be in quotation marks ***

Option Alias Description Type Default
--version Show version number boolean
--log -l Log level. [choices: "TRACE", "DEBUG", "INFO", "WARN", "ERROR", "SILENT"] "INFO"
--help -h Show help boolean
--files -f Glob-like file pattern specifying the filepath for the source files. Relative to baseDir. IMPORTANT!! Use with quote (" or ')' string "**/*.ts"
--ignore -i Glob-like file pattern specifying files to ignore. IMPORTANT!! Use with quote (" or ')' array ["**/*.spec.ts", "**/node_modules/**"]
--imageFormat --im Image format. To turn off image generation set to off [choices: "eps", "latex", "png", "svg", "txt", "off"] "png"
--outDir -o Redirect output structure to the directory string "out"
--baseDir -d Path to project base directory string ""
--tsConfig -c tsconfig.json file name with relative path from baseDir string "tsconfig.json
--toJson --js Generate intermediate files to json boolean false
--wsd Generate plant uml file (.wsd) boolean false
--clickableLinks --cl Convert terminal links to clickable in vs code terminal boolean false

Examples

Generated from source code ngrx/store example app

Png

Png diagram

wsd

@startuml [Auth/API] Login Success

set namespaceSeparator ::

interface "[Auth/API] Login Success" << (A,#FF7700) action >> {
        variable: loginSuccess
        src: auth-api.actions
        --
        props<{user: User}>
}

interface "auth.reducer:: reducer L" << (L,orchid) listen >> {
        name: loginSuccess
        action: [Auth/API] Login Success
        src: auth.reducer
        ..
        Variable: reducer
}

"[Auth/API] Login Success" <.down. "auth.reducer:: reducer L"

interface "auth.effects:: AuthEffects D" << (D,orchid) dispatch >> {
        name: loginSuccess
        action: [Auth/API] Login Success
        src: auth.effects
        ..
        Class: AuthEffects
        Property: login$
}

"[Auth/API] Login Success" -down-> "auth.effects:: AuthEffects D"

@enduml

Plantuml file

JSON

Actions JSON

Actions with references JSON

Action's references JSON

{
    "name": "[Auth] Logout Confirmation Dismiss",
    "kind": 1002,
    "kindText": "Action",
    "variable": "logoutConfirmationDismiss",
    "filePath": "./actions/auth.actions.ts",
    "references": [
      {
        "name": "logoutConfirmationDismiss",
        "kind": 1003,
        "kindText": "ActionReference",
        "documentation": "",
        "isCall": true,
        "filePath": "./effects/auth.effects.ts",
        "fileName": "auth.effects",
        "declarationContext": [
          {
            "kindText": "ClassDeclaration",
            "name": "AuthEffects"
          },
          {
            "kindText": "PropertyDeclaration",
            "name": "logoutConfirmation$"
          }
        ]
      }
    ]
  }

Using from source files

Installation

npm install ngrx-uml

Example

Use GeneratorService

import {
    ActionConvertContextFactory, ActionReferenceConvertContextFactory,
    ActionsPlantDiagramRenderFactory, GeneratorOptions, GeneratorService, PlantUmlOutputService
} from 'ngrx-uml';

export function useGeneratorService(): void {

    const options: GeneratorOptions = {
        outDir: 'out/generator',
        imageFormat: 'png',
        ignorePattern: ['**/*.spec.ts'],
        saveActionsReferencesToJson: false,
        saveActionsToJson: false,
        saveWsd: false,
        logLevel: 'INFO'
    };

    const plantUmlService = new PlantUmlOutputService({
        outDir: options.outDir || 'out',
        ext: options.imageFormat || 'png',
        clickableLinks: options.clickableLinks || true,
        saveWsd: options.saveWsd || false
    });


    const generateService = new GeneratorService(
        plantUmlService,
        [
            new ActionConvertContextFactory,
            new ActionReferenceConvertContextFactory,
        ],
        new ActionsPlantDiagramRenderFactory().create(),
        [plantUmlService],
        options
    );

    const files = '../../test/test_data/**/*.ts';
    generateService.generate(files);

}

Use CreateActionsDiagramService

import { CreateActionsDiagramService, GeneratorOptions } from 'ngrx-uml';

export function useCreateActionsDiagramService(): void {
    const options: GeneratorOptions = {
        outDir: 'out/create-actions-diagram-service',
        imageFormat: 'svg',
        ignorePattern: ['**/*.spec.ts'],
        saveActionsReferencesToJson: true,
        saveActionsToJson: true,
        saveWsd: true,
        logLevel: 'INFO'
    };
    const files = '../../test/test_data/**/*.ts';
    const createActionsDiagramService = new CreateActionsDiagramService(options);
    createActionsDiagramService.generateDiagram(files);
}