Skip to content

Commit

Permalink
document request and response format
Browse files Browse the repository at this point in the history
  • Loading branch information
nk-coding committed Oct 21, 2024
1 parent 04e5e43 commit 44fefb5
Showing 1 changed file with 96 additions and 2 deletions.
98 changes: 96 additions & 2 deletions docs/docs.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,97 @@
# Gropius Layot DEV UI
# Gropius Layout DEV UI

More coming soon
## Request Format

```ts
type RequestBody = Graph;

interface Graph {
components: ComponentVersion[];
relations: Relation[];
}

interface ComponentVersion extends Node {
name: string;
style: ShapeStyle;
interfaces: Interface[];
}

interface Interface extends Node {
name: string;
style: ShapeStyle;
};

interface Relation extends Node {
name: string;
start: string;
end: string;
style: RelationStyle;
}

interface Node {
id: string;
}

interface StrokeStyle {
stroke?: {
color?: string;
dash?: number[];
};
}

interface FillStyle {
fill?: {
color: string;
};
}

interface ShapeStyle extends StrokeStyle, FillStyle {
shape: Shape;
radius?: number;
}

interface RelationStyle extends StrokeStyle {
marker: Marker;
}

type Shape = "RECT" | "CIRCLE" | "ELLIPSE" | "RHOMBUS" | "HEXAGON";

type Marker =
| "ARROW"
| "DIAMOND"
| "FILLED_DIAMOND"
| "TRIANGLE"
| "FILLED_TRIANGLE"
| "CIRCLE"
| "FILLED_CIRCLE";
```

::: info
Note: this may be extended in the future to contain the size of components / interfaces.
Further, the actual response body contains some additional fields which can be safely ignored.
:::



## Expected Response Format

```ts
type ResponseBody = GraphLayout;

interface GraphLayout {
[id: string]: ElementLayout | RelationLayout;
}

interface ElementLayout {
pos: Point;
}

interface RelationLayout {
points: Point[];
}

interface Point {
x: number;
y: number;
}
```

0 comments on commit 44fefb5

Please sign in to comment.