Knex.js based query builder to interpret design patterns in MermaidJS.
Installations
npm install @quarterfall/parseidon
Developer Guide
Typescript
Yes
Module System
CommonJS
Node Version
18.12.1
NPM Version
8.19.2
Score
62.4
Supply Chain
94.7
Quality
70
Maintenance
100
Vulnerability
95.6
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (99.74%)
JavaScript (0.26%)
Developer
quarterfall
Download Statistics
Total Downloads
1,358
Last Day
1
Last Week
2
Last Month
6
Last Year
210
GitHub Statistics
1 Stars
70 Commits
1 Forks
1 Watching
3 Branches
2 Contributors
Bundle Size
330.01 kB
Minified
89.42 kB
Minified + Gzipped
Package Meta Information
Latest Version
1.0.4
Package Id
@quarterfall/parseidon@1.0.4
Unpacked Size
1.28 MB
Size
273.90 kB
File Count
187
NPM Version
8.19.2
Node Version
18.12.1
Total Downloads
Cumulative downloads
Total Downloads
1,358
Last day
0%
1
Compared to previous day
Last week
0%
2
Compared to previous week
Last month
-66.7%
6
Compared to previous month
Last year
-46.3%
210
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
5
parseidon
Knex.js based query builder to interpret design patterns in MermaidJS.
demo
You can try out the ParseidonJS node module at the link below!
Database Structure
The database includes 4 tables, as shown in the diagram before. This database is queried to check for design patterns and relations in the class diagram.
1 classDiagram 2direction LR 3Relations "1" --> "2" Classes 4Classes "1" --> "0..*" Members 5Classes "1" --> "0..*" Methods 6class Relations { 7int id 8String first_class 9String relation 10String second_class 11} 12class Classes { 13String id 14int[] members 15int[] methods 16String type 17} 18class Members { 19int id 20String type 21String name 22String accessibility 23String classifier 24} 25class Methods { 26int id 27String returnType 28String name 29String parameters 30String accessibility 31String classifier 32}
Design Patterns
For the moment, ParseidonJS supports these design patterns software design patterns:
Singleton
Steps
- Singleton class has private static instance of own class
- Singleton class has a private constructor
- Singleton class has public static method returning the singleton class instance
- There is no instance of the singleton class in any other class
1 classDiagram 2 Animal <|-- Duck 3 Animal <|-- Fish 4 Animal <|-- Zebra 5 Singleton --> Singleton 6 Animal : +int age 7 Animal : +String gender 8 Animal: +isMammal() 9 Animal: +mate() 10 class Duck{ 11 +String beakColor 12 +swim() 13 +quack() 14 } 15 class Fish{ 16 -int sizeInFeet 17 -canEat() 18 } 19 class Zebra{ 20 +bool is_wild 21 +run() 22 } 23 class Singleton{ 24 -Singleton singleton$ 25 -Singleton() 26 +getInstance()$ Singleton 27 }
classDiagram
Animal <|-- Duck
Animal <|-- Fish
Animal <|-- Zebra
Singleton --> Singleton
Animal : +int age
Animal : +String gender
Animal: +isMammal()
Animal: +mate()
class Duck{
+String beakColor
+swim()
+quack()
}
class Fish{
-int sizeInFeet
-canEat()
}
class Zebra{
+bool is_wild
+run()
}
class Singleton{
-Singleton singleton$
-Singleton()
+getInstance()$ Singleton
}
Factory Method
Steps
- Have a "product" interface implemented by at least 1 "product'
- Have an abstract "creator" class with abstract method that returns "product" interface and at least 1 other method
- Have at least one class inheriting from "creator" class
1 classDiagram 2direction RL 3 class Dialog { 4 <<abstract>> 5 +render() 6 +createButton()* Button 7 } 8 class Button { 9 <<interface>> 10 +render() 11 +onClick() 12 } 13 class WindowsDialog { 14 +createButton(): Button 15 } 16WindowsDialog --|> Dialog 17WindowsButton ..|> Button 18Dialog --> Button
classDiagram
direction RL
class Dialog {
<<abstract>>
+render()
+createButton()* Button
}
class Button {
<<interface>>
+render()
+onClick()
}
class WindowsDialog {
+createButton(): Button
}
WindowsDialog --|> Dialog
WindowsButton ..|> Button
Dialog --> Button
Strategy
Steps
- Strategy interface with 1 method ( Strategy method )
- Context class with private Strategy interface member
- One class implementing the Strategy interface
1 classDiagram 2Context o-- Strategy 3Context --> Strategy 4ConcreteStrategy ..|> Strategy 5class Strategy { 6<<interface>> 7+execute(data) 8} 9class ConcreteStrategy { 10+execute(data) 11} 12class Context { 13-Strategy strategy 14+setStrategy(strategy) 15+doSomething() 16}
classDiagram
Context o-- Strategy
Context --> Strategy
ConcreteStrategy ..|> Strategy
class Strategy{
<<interface>>
+execute(data)
}
class ConcreteStrategy{
+execute(data)
}
class Context{
-Strategy strategy
+setStrategy(strategy)
+doSomething()
}
Adapter
Steps
- Adapter class that associates with the service and implements the client interface
- Service class, the client can't use it directly. Adapter class has an instance of it
1 classDiagram 2SquarePegAdapter ..|> RoundPeg 3SquarePegAdapter --> SquarePeg 4 5class SquarePegAdapter{ 6-SquarePeg peg 7+SquarePegAdapter(SquarePeg peg) 8+getRadius() int 9} 10class SquarePeg{ 11-int width 12+SquarePeg(int width) 13+getWidth() int 14} 15class RoundPeg{ 16<<interface>> 17+getRadius() int 18}
classDiagram
SquarePegAdapter ..|> RoundPeg
SquarePegAdapter --> SquarePeg
class SquarePegAdapter{
-SquarePeg peg
+SquarePegAdapter(SquarePeg peg)
+getRadius() int
}
class SquarePeg{
-int width
+SquarePeg(int width)
+getWidth() int
}
class RoundPeg{
<<interface>>
+getRadius() int
}
Composite
Steps
- Component interface with at least one method
- Two classes implementing the Component interface (Leaf and Container)
- One class(Container) with an array of interface type, methods to add and remove members of the array
1 classDiagram 2Dot ..|> Graphic 3CompoundGraphic ..|> Graphic 4class Graphic { 5<<interface>> 6+move(int x,int y) 7+draw() 8} 9class Dot { 10+Dot(int x, int y) 11+move(int x, int y) 12+draw() 13} 14class CompoundGraphic { 15-Graphic[] children 16+add(Graphic child) 17+remove(Graphic child) 18+move(int x, int y) 19+draw() 20}
classDiagram
Dot ..|> Graphic
CompoundGraphic ..|> Graphic
class Graphic {
<<interface>>
+move(int x,int y)
+draw()
}
class Dot {
+Dot(int x, int y)
+move(int x, int y)
+draw()
}
class CompoundGraphic {
-Graphic[] children
+add(Graphic child)
+remove(Graphic child)
+move(int x, int y)
+draw()
}
Proxy
Steps
- Interface implemented by at least two classes (Proxy and Service)
- Proxy class has instance of service class
- Proxy class constructor has parameter of type service class
- Proxy class has association to Service
1 classDiagram 2 class ThirdPartyYTLib{ 3 +listVideos() 4 +getVideoInfo(id) 5 +downloadVideo(id) 6 } 7 class CachedYTClass{ 8 -ThirdPartyYTClass service 9 +CachedYTClass(ThirdPartyYTClass s) 10 +listVideos() 11 +getVideoInfo(id) 12 +downloadVideo(id) 13 } 14 class ThirdPartyYTClass{ 15 +listVideos() 16 +getVideoInfo(id) 17 +downloadVideo(id) 18 } 19 CachedYTClass ..|> ThirdPartyYTLib 20 ThirdPartyYTClass ..|> ThirdPartyYTLib 21 CachedYTClass o--> ThirdPartyYTLib
classDiagram
class ThirdPartyYTLib{
+listVideos()
+getVideoInfo(id)
+downloadVideo(id)
}
class CachedYTClass{
-ThirdPartyYTClass service
+CachedYTClass(ThirdPartyYTClass s)
+listVideos()
+getVideoInfo(id)
+downloadVideo(id)
}
class ThirdPartyYTClass{
+listVideos()
+getVideoInfo(id)
+downloadVideo(id)
}
CachedYTClass ..|> ThirdPartyYTLib
ThirdPartyYTClass ..|> ThirdPartyYTLib
CachedYTClass o--> ThirdPartyYTLib
Observer
Steps
- Interface (Subscriber) implemented by at least one class (concrete subscribers)
- Interface has aggregation with a class (Publisher)
- Publisher class has array of interface (Subscriber) type
- Publisher class has two methods with parameter of interface (Subscriber) type
1 classDiagram 2 class EventManager{ 3 -EventListeners listeners[] 4 +subscribe(EventListeners l) 5 +unsubscribe(EventListeners l) 6 +notify(EventType event, String data) 7 } 8 class EventListeners{ 9 <<interface>> 10 +update(String filename) 11 } 12 class EmailAlertsListener{ 13 +update(String filename) 14 } 15 class LoggingListener{ 16 +update(String filename) 17 } 18 EventManager o--> EventListeners 19 EmailAlertsListener ..|> EventListeners 20 LoggingListener ..|> EventListeners
classDiagram
class EventManager{
-EventListeners listeners[]
+subscribe(EventListeners l)
+unsubscribe(EventListeners l)
+notify(EventType event, String data)
}
class EventListeners{
+update(String filename)
}
class EmailAlertsListener{
+update(String filename)
}
class LoggingListener{
+update(String filename)
}
EventManager o--> EventListeners
EmailAlertsListener ..|> EventListeners
LoggingListener ..|> EventListeners
1 classDiagram 2 class EventManager{ 3 -EventListeners listeners[] 4 +subscribe(EventListeners l) 5 +unsubscribe(EventListeners l) 6 +notify(EventType event, String data) 7 } 8 class EventListeners{ 9 +update(String filename) 10 } 11 class EmailAlertsListener{ 12 +update(String filename) 13 } 14 class LoggingListener{ 15 +update(String filename) 16 } 17 EventManager o--> EventListeners 18 EmailAlertsListener ..|> EventListeners 19 LoggingListener ..|> EventListeners
No vulnerabilities found.
No security vulnerabilities found.