@dineug/erd-editor 3.3.1 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/README.md +197 -17
  2. package/dist/components/erd/canvas/altDragDuplicate.d.ts +3 -0
  3. package/dist/components/erd/canvas/duplicate-ghost/DuplicateGhost.d.ts +4 -0
  4. package/dist/components/erd/canvas/duplicate-ghost/DuplicateGhost.styles.d.ts +2 -0
  5. package/dist/components/erd/canvas/shared-drag-select/SharedDragSelect.d.ts +4 -0
  6. package/dist/components/erd/canvas/table/column/Column.d.ts +7 -0
  7. package/dist/components/erd/canvas/table/column/column-data-type/ColumnDataType.d.ts +3 -3
  8. package/dist/components/erd/canvas/table/column/column-not-null/ColumnNotNull.d.ts +1 -1
  9. package/dist/components/erd/canvas/table/column/column-option/ColumnOption.d.ts +1 -1
  10. package/dist/components/erd/canvas/table/useSharedFocusTable.d.ts +6 -0
  11. package/dist/components/erd/canvas/useSharedSelectEntity.d.ts +4 -0
  12. package/dist/components/erd/erd-context-menu/menus/drawRelationshipMenus.d.ts +3 -2
  13. package/dist/components/erd/erd-context-menu/menus/exportMenus.d.ts +6 -6
  14. package/dist/components/erd/erd-context-menu/menus/importMenus.d.ts +6 -6
  15. package/dist/components/erd/erd-context-menu/menus/relationshipMenus.d.ts +1 -1
  16. package/dist/components/erd/table-properties/table-properties-indexes/indexes-checkbox-column/IndexesCheckboxColumn.d.ts +1 -1
  17. package/dist/components/erd-editor/ErdEditor.d.ts +4 -0
  18. package/dist/components/erd-editor/ErdEditor.stories.d.ts +1 -1
  19. package/dist/components/global-styles/GlobalStyles.d.ts +14 -0
  20. package/dist/components/primitives/button/Button.stories.d.ts +4 -4
  21. package/dist/components/primitives/code-block/CodeBlock.stories.d.ts +4 -4
  22. package/dist/components/primitives/code-block/CodeBlock.styles.d.ts +6 -1
  23. package/dist/components/primitives/color-picker/ColorPicker.d.ts +1 -1
  24. package/dist/components/primitives/color-picker/ColorPicker.stories.d.ts +1 -1
  25. package/dist/components/primitives/context-menu/ContextMenu.stories.d.ts +1 -1
  26. package/dist/components/primitives/context-menu/context-menu-item/ContextMenuItem.d.ts +1 -1
  27. package/dist/components/primitives/context-menu/menu/Menu.d.ts +2 -2
  28. package/dist/components/primitives/edit-input/EditInput.d.ts +2 -2
  29. package/dist/components/primitives/edit-input/EditInput.stories.d.ts +6 -6
  30. package/dist/components/primitives/highlighted-text/HighlightedText.stories.d.ts +1 -1
  31. package/dist/components/primitives/icon/Icon.d.ts +2 -3
  32. package/dist/components/primitives/icon/Icon.stories.d.ts +3 -1
  33. package/dist/components/primitives/icon/icons.d.ts +59 -15
  34. package/dist/components/primitives/kbd/Kbd.stories.d.ts +3 -3
  35. package/dist/components/primitives/sash/Sash.stories.d.ts +5 -5
  36. package/dist/components/primitives/separator/Separator.stories.d.ts +3 -3
  37. package/dist/components/primitives/slider/Slider.stories.d.ts +4 -4
  38. package/dist/components/primitives/switch/Switch.stories.d.ts +3 -3
  39. package/dist/components/primitives/text-input/TextInput.d.ts +1 -1
  40. package/dist/components/primitives/text-input/TextInput.stories.d.ts +7 -7
  41. package/dist/components/primitives/toast/Toast.stories.d.ts +4 -4
  42. package/dist/constants/language.d.ts +7 -1
  43. package/dist/constants/layout.d.ts +20 -0
  44. package/dist/constants/schema.d.ts +11 -2
  45. package/dist/constants/sql/dataType/Databricks.d.ts +5 -0
  46. package/dist/constants/sql/dataType/MSSQL.d.ts +1 -1
  47. package/dist/constants/sql/dataType/MySQL.d.ts +1 -1
  48. package/dist/constants/sql/dataType/Oracle.d.ts +1 -1
  49. package/dist/constants/sql/dataType/Snowflake.d.ts +5 -0
  50. package/dist/constants/sql/database.d.ts +2 -0
  51. package/dist/engine/history.d.ts +5 -3
  52. package/dist/engine/hooks.d.ts +3 -3
  53. package/dist/engine/modules/editor/actions.d.ts +18 -1
  54. package/dist/engine/modules/editor/atom.actions.d.ts +78 -0
  55. package/dist/engine/modules/editor/generator.actions.d.ts +18 -0
  56. package/dist/engine/modules/editor/state.d.ts +23 -0
  57. package/dist/engine/modules/editor/utils/duplicate.d.ts +13 -0
  58. package/dist/engine/modules/memo/actions.d.ts +3 -0
  59. package/dist/engine/modules/memo/atom.actions.d.ts +12 -0
  60. package/dist/engine/modules/table/actions.d.ts +1 -0
  61. package/dist/engine/modules/table/atom.actions.d.ts +4 -0
  62. package/dist/engine.js +40 -51
  63. package/dist/erd-editor.js +30677 -26598
  64. package/dist/schemaGCService-DAGNq0wk.js +17092 -0
  65. package/dist/services/shikiService.d.ts +1 -1
  66. package/dist/styles/colorPicker.style.d.ts +10 -1
  67. package/dist/styles/fonts.styles.d.ts +2 -1
  68. package/dist/styles/reset.styles.d.ts +5 -1
  69. package/dist/styles/scrollbar.styles.d.ts +6 -1
  70. package/dist/styles/typography.styles.d.ts +2 -1
  71. package/dist/themes/radix-ui-theme.d.ts +1 -1
  72. package/dist/themes/tokens.d.ts +2 -2
  73. package/dist/utils/calcTable.d.ts +7 -0
  74. package/dist/utils/draw-relationship/chamfer.d.ts +2 -0
  75. package/dist/utils/draw-relationship/index.d.ts +73 -14
  76. package/dist/utils/draw-relationship/nudge.d.ts +3 -0
  77. package/dist/utils/draw-relationship/pathFinding.d.ts +9 -1
  78. package/dist/utils/draw-relationship/route.d.ts +32 -0
  79. package/dist/utils/draw-relationship/stub.d.ts +47 -0
  80. package/dist/utils/emitter.d.ts +16 -0
  81. package/dist/utils/file/importFile.d.ts +4 -1
  82. package/dist/utils/focus.d.ts +4 -2
  83. package/dist/utils/generator-code/aml.d.ts +4 -0
  84. package/dist/utils/generator-code/dbml.d.ts +4 -0
  85. package/dist/utils/generator-code/drizzle.d.ts +4 -0
  86. package/dist/utils/generator-code/go.d.ts +4 -0
  87. package/dist/utils/generator-code/sequelize.d.ts +4 -0
  88. package/dist/utils/generator-code/sqlalchemy.d.ts +4 -0
  89. package/dist/utils/generator-code/typeorm.d.ts +4 -0
  90. package/dist/utils/keyboard-shortcut/index.d.ts +1 -1
  91. package/dist/utils/promise.d.ts +1 -0
  92. package/dist/utils/schema-aml-parser/convert.d.ts +4 -0
  93. package/dist/utils/schema-aml-parser/dataType.d.ts +13 -0
  94. package/dist/utils/schema-aml-parser/index.d.ts +3 -0
  95. package/dist/utils/schema-aml-parser/parser.d.ts +2 -0
  96. package/dist/utils/schema-aml-parser/tokenizer.d.ts +25 -0
  97. package/dist/utils/schema-aml-parser/types.d.ts +79 -0
  98. package/dist/utils/schema-dbml-parser/convert.d.ts +4 -0
  99. package/dist/utils/schema-dbml-parser/dataType.d.ts +7 -0
  100. package/dist/utils/schema-dbml-parser/index.d.ts +3 -0
  101. package/dist/utils/schema-dbml-parser/parser.d.ts +2 -0
  102. package/dist/utils/schema-dbml-parser/tokenizer.d.ts +16 -0
  103. package/dist/utils/schema-dbml-parser/types.d.ts +62 -0
  104. package/dist/utils/schema-graphql-parser/convert.d.ts +4 -0
  105. package/dist/utils/schema-graphql-parser/dataType.d.ts +7 -0
  106. package/dist/utils/schema-graphql-parser/index.d.ts +3 -0
  107. package/dist/utils/schema-graphql-parser/parser.d.ts +2 -0
  108. package/dist/utils/schema-graphql-parser/types.d.ts +58 -0
  109. package/dist/utils/schema-sql/Databricks.d.ts +5 -0
  110. package/dist/utils/schema-sql/Snowflake.d.ts +5 -0
  111. package/dist/utils/sharedColor.d.ts +2 -0
  112. package/dist/utils/table-clipboard/copy.d.ts +7 -0
  113. package/dist/utils/table-clipboard/index.d.ts +2 -0
  114. package/dist/utils/table-clipboard/paste.d.ts +3 -0
  115. package/dist/utils/table-clipboard/payload.d.ts +83 -0
  116. package/dist/utils/table-clipboard/placement.d.ts +30 -0
  117. package/dist/utils/validation.d.ts +1 -0
  118. package/package.json +29 -25
  119. package/dist/schemaGCService-Br6jn6B2.js +0 -15866
@@ -1,6 +1,6 @@
1
1
  export type ShikiService = {
2
2
  codeToHtml(code: string, { lang, theme, }: {
3
- lang: 'sql' | 'typescript' | 'graphql' | 'csharp' | 'java' | 'kotlin' | 'scala';
3
+ lang: 'sql' | 'typescript' | 'graphql' | 'csharp' | 'java' | 'kotlin' | 'scala' | 'go' | 'python';
4
4
  theme?: 'dark' | 'light';
5
5
  }): Promise<string>;
6
6
  };
@@ -1 +1,10 @@
1
- export declare function createColorPickerStyle(): HTMLStyleElement;
1
+ /**
2
+ * Vendored from https://github.com/easylogic/colorpicker.
3
+ *
4
+ * Global, not scoped. The picker's markup is built by the upstream library at runtime, outside
5
+ * anything r-html renders, so there is no element here to hang a generated component class on —
6
+ * every selector below matches by the literal class names that library writes
7
+ * (`.easylogic-colorpicker`, `.colorsets-contextmenu`), and scoping them would rename them out
8
+ * from under it. Last in `setGlobalStyleOrder`, which is where it sat when it was a tree `<style>`.
9
+ */
10
+ export declare const colorPickerStyle: import('@dineug/r-html').CSSTemplateLiterals;
@@ -1,3 +1,4 @@
1
1
  export declare const TextFontFamily: "-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', 'Open Sans', system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji'";
2
2
  export declare const CodeFontFamily: "'Menlo', 'Consolas', 'Bitstream Vera Sans Mono', monospace, 'Apple Color Emoji', 'Segoe UI Emoji'";
3
- export declare function createFontsStyle(): HTMLStyleElement;
3
+ /** Global, not scoped: `:host` is the shadow host, which no component class matches. */
4
+ export declare const fontsStyle: import('@dineug/r-html').CSSTemplateLiterals;
@@ -1 +1,5 @@
1
- export declare function createResetStyle(): HTMLStyleElement;
1
+ /**
2
+ * Global, not scoped: every selector here is a type selector, the universal selector or `:host`,
3
+ * none of which survives having a component class prepended to it.
4
+ */
5
+ export declare const resetStyle: import('@dineug/r-html').CSSTemplateLiterals;
@@ -1 +1,6 @@
1
- export declare function createScrollbarStyle(): HTMLStyleElement;
1
+ /**
2
+ * Global, not scoped. The `::-webkit-scrollbar*` pseudo elements have no element of their own to
3
+ * hang a component class on, and `.scrollbar` is a hook class seven components opt into by
4
+ * literal name (`class=${['scrollbar', ...]}`) — scoping it would rename it out from under them.
5
+ */
6
+ export declare const scrollbarStyle: import('@dineug/r-html').CSSTemplateLiterals;
@@ -11,4 +11,5 @@ export declare const typography: {
11
11
  readonly normal: import('@dineug/r-html').CSSTemplateLiterals;
12
12
  readonly paragraph: import('@dineug/r-html').CSSTemplateLiterals;
13
13
  };
14
- export declare function createTypographyStyle(): HTMLStyleElement;
14
+ /** Global, not scoped: `:host` is the shadow host, which no component class matches. */
15
+ export declare const typographyStyle: import('@dineug/r-html').CSSTemplateLiterals;
@@ -1783,7 +1783,7 @@ export declare const AccentColor: {
1783
1783
  readonly sky: "sky";
1784
1784
  };
1785
1785
  export type AccentColor = ValuesType<typeof AccentColor>;
1786
- export declare const AccentColorList: ("gray" | "gold" | "bronze" | "brown" | "yellow" | "amber" | "orange" | "tomato" | "red" | "ruby" | "crimson" | "pink" | "plum" | "purple" | "violet" | "iris" | "indigo" | "blue" | "cyan" | "teal" | "jade" | "green" | "grass" | "lime" | "mint" | "sky")[];
1786
+ export declare const AccentColorList: ("ruby" | "gray" | "gold" | "bronze" | "brown" | "yellow" | "amber" | "orange" | "tomato" | "red" | "crimson" | "pink" | "plum" | "purple" | "violet" | "iris" | "indigo" | "blue" | "cyan" | "teal" | "jade" | "green" | "grass" | "lime" | "mint" | "sky")[];
1787
1787
  export type ThemeOptions = {
1788
1788
  appearance: Appearance;
1789
1789
  grayColor: GrayColor;
@@ -45,8 +45,8 @@ export type Theme = {
45
45
  minimapViewportBorderHover: string;
46
46
  toastBackground: string;
47
47
  toastBorder: string;
48
- dargSelectBackground: string;
49
- dargSelectBorder: string;
48
+ dragSelectBackground: string;
49
+ dragSelectBorder: string;
50
50
  scrollbarTrack: string;
51
51
  scrollbarThumb: string;
52
52
  scrollbarThumbHover: string;
@@ -1,6 +1,13 @@
1
1
  import { EngineContext } from '../engine/context';
2
2
  import { RootState } from '../engine/state';
3
3
  import { Table } from '../internal-types';
4
+ export declare function getWidthGeneration(): number;
5
+ /**
6
+ * Invalidates every cached table size. Called from `recalculateTableWidth`,
7
+ * which rewrites widths without dispatching an action, and from the
8
+ * relationship-sort hook for any action that is not a pure move.
9
+ */
10
+ export declare function invalidateTableWidths(): void;
4
11
  export declare function calcTableWidths(table: Table, { settings: { show, maxWidthComment }, collections }: RootState): ColumnWidth;
5
12
  export type ColumnWidth = {
6
13
  width: number;
@@ -0,0 +1,2 @@
1
+ import { Point } from '../../internal-types';
2
+ export declare function chamferPolyline(points: Point[], size: number): Point[];
@@ -1,4 +1,4 @@
1
- import { Point, RelationshipPoint, ValuesType } from '../../internal-types';
1
+ import { Point, Relationship, ValuesType } from '../../internal-types';
2
2
  export declare const DirectionName: {
3
3
  readonly left: "left";
4
4
  readonly right: "right";
@@ -78,15 +78,6 @@ export type RelationshipPath = {
78
78
  startCircle: Circle;
79
79
  };
80
80
  };
81
- export type RelationshipMarginPoint = {
82
- xArray: number[];
83
- yArray: number[];
84
- };
85
- export type RelationshipOrder = {
86
- start: RelationshipPoint;
87
- end: RelationshipPoint;
88
- distance: number;
89
- };
90
81
  export type ObjectPoint = {
91
82
  width: number;
92
83
  height: number;
@@ -102,7 +93,75 @@ export type ObjectPoint = {
102
93
  export declare const isDirection: (value: string) => boolean;
103
94
  export declare const PATH_HEIGHT = 30;
104
95
  export declare const PATH_END_HEIGHT: number;
105
- export declare const PATH_LINE_HEIGHT = 35;
106
- export declare const LINE_SIZE = 10;
107
- export declare const LINE_HEIGHT = 16;
108
- export declare const CIRCLE_HEIGHT = 26;
96
+ /**
97
+ * The cardinality decoration, measured outward from the anchor.
98
+ *
99
+ * The four are one shape and cannot be set independently: the second tick and
100
+ * the ring share a centre at `LINE_SIZE + LINE_HEIGHT`, the guide line starts
101
+ * where the longest stroke ends at `LINE_HEIGHT * 2 + 3`, and the ring has to
102
+ * clear the first tick behind it and the guide line in front of it, which puts
103
+ * its radius between those two.
104
+ *
105
+ * Scaled to 0.7 of what they were, so a decoration reaches 25px out rather than
106
+ * 35px. `RELATIONSHIP_STROKE_WIDTH` thinned the connector; leaving the notation
107
+ * at its old size would have made the crow's foot the heaviest thing on the
108
+ * canvas.
109
+ */
110
+ export declare const LINE_SIZE = 7;
111
+ export declare const LINE_HEIGHT = 11;
112
+ export declare const CIRCLE_HEIGHT: number;
113
+ export declare const CIRCLE_RADIUS = 6;
114
+ export declare const PATH_LINE_HEIGHT: number;
115
+ /**
116
+ * How far apart the corridors of two relationships leaving the same table side
117
+ * are placed. Without this every path on a side turns at the same `x` (or `y`),
118
+ * so their first segments run down one another no matter how far apart the
119
+ * anchors are spread.
120
+ */
121
+ export declare const STUB_STEP = 12;
122
+ /**
123
+ * Corridors repeat every fourth slot. Growing the stub without limit would walk
124
+ * a busy side's paths ever further from the table; wrapping keeps the longest
125
+ * stub at `PATH_END_HEIGHT + 3 * STUB_STEP` while leaving four slots — at least
126
+ * four anchor pitches apart — between any two that share a corridor.
127
+ */
128
+ export declare const STUB_CYCLE = 4;
129
+ /**
130
+ * The shortest a stub may be clamped to.
131
+ *
132
+ * It has to clear `PATH_LINE_HEIGHT`: the cardinality decorations reach that far
133
+ * out from the anchor and the guide line is drawn from there to the stub, so a
134
+ * shorter stub draws that line backwards. It is not derived from it. 36 is where
135
+ * the routing was measured, and letting it follow the decorations down to 26
136
+ * when they shrank took the medium corpus from 168px of collinear overlap to
137
+ * 484px — two tables facing each other closer than `2 * MIN_STUB` turn in
138
+ * earlier, and the routing bench found them sharing a corridor for 316px.
139
+ */
140
+ export declare const MIN_STUB = 36;
141
+ /**
142
+ * The widest gap allowed between two anchors on the same table side.
143
+ *
144
+ * Anchors used to be spread over the whole edge, so two relationships on a tall
145
+ * table splayed hundreds of pixels apart and converged again. Capping the pitch
146
+ * keeps a side's anchors together as a group; the side is only filled when it
147
+ * genuinely has that many relationships.
148
+ */
149
+ export declare const ANCHOR_MAX_PITCH = 120;
150
+ /** Keeps the outermost anchor of a side clear of the table's corners. */
151
+ export declare const ANCHOR_EDGE_INSET = 12;
152
+ /**
153
+ * How far back from a corner a connector turns, when the corner is drawn as a
154
+ * 45-degree cut rather than a right angle.
155
+ *
156
+ * Each cut is clamped to half of the shorter run it touches, so this is a ceiling
157
+ * rather than a length: a short run keeps its right angle instead of losing the
158
+ * whole of itself to two cuts. Two connectors turning the same way in
159
+ * neighbouring lanes stay `NUDGE_GAP` apart through the corner, so a bundle bends
160
+ * as a set of concentric cuts rather than converging on one.
161
+ */
162
+ export declare const ROUTE_CHAMFER = 8;
163
+ export declare function setStubSlots(relationship: Relationship, slots: readonly [number, number]): void;
164
+ /** Falls back to slot zero, which reproduces the pre-stagger geometry. */
165
+ export declare function getStubSlots(relationship: Relationship): readonly [number, number];
166
+ export declare function setRoute(relationship: Relationship, points: Point[]): void;
167
+ export declare function getRoute(relationship: Relationship): Point[] | undefined;
@@ -0,0 +1,3 @@
1
+ import { Point } from '../../internal-types';
2
+ import { Obstacles } from './route';
3
+ export declare function nudgeRoutes(routes: Map<string, Point[]>, obstacles: Obstacles, endpoints: Map<string, [string, string]>): void;
@@ -1,3 +1,11 @@
1
- import { Relationship } from '../../internal-types';
1
+ import { Point, Relationship } from '../../internal-types';
2
2
  import { RelationshipPath } from '.';
3
3
  export declare function getRelationshipPath(relationship: Relationship): RelationshipPath;
4
+ /**
5
+ * The routing polyline as one `d`, so a connector is a single element whatever
6
+ * the router and the corner cuts made of it.
7
+ *
8
+ * The segments are contiguous by construction — they come from a polyline — so
9
+ * each one contributes its far end and nothing else.
10
+ */
11
+ export declare function toPathD(segments: Array<[Point, Point]>): string;
@@ -0,0 +1,32 @@
1
+ import { RootState } from '../../engine/state';
2
+ import { Point } from '../../internal-types';
3
+ export type Obstacles = {
4
+ ids: string[];
5
+ left: Float64Array;
6
+ top: Float64Array;
7
+ right: Float64Array;
8
+ bottom: Float64Array;
9
+ };
10
+ /**
11
+ * Every table in the document, not only those carrying a relationship: a table
12
+ * with no relationships at all still blocks the view.
13
+ */
14
+ export declare function collectObstacles(state: RootState): Obstacles;
15
+ /** Liang–Barsky, with no divisions until a slab actually clips. */
16
+ export declare function segmentHitsBox(ax: number, ay: number, bx: number, by: number, left: number, top: number, right: number, bottom: number): boolean;
17
+ /**
18
+ * How many tables a polyline passes through, ignoring the two it connects.
19
+ *
20
+ * This is the hot function of the whole router: every candidate is scored with
21
+ * it, and the nudge pass calls it twice per lane it tries. The polyline's own
22
+ * bounding box is computed once and used to skip tables outright — a connector
23
+ * spans a small part of the canvas, so most tables fail it. Every segment's box
24
+ * sits inside the polyline's, so a table the polyline's box misses is a table
25
+ * every segment's cheap reject would have missed too; the count is unchanged.
26
+ */
27
+ export declare function countBlocked(points: Point[], obstacles: Obstacles, skipA: string, skipB: string): number;
28
+ /**
29
+ * The cheapest orthogonal polyline from `m` to `l`, or a two-bend fallback when
30
+ * nothing is feasible — a connector always has to be drawn.
31
+ */
32
+ export declare function routeOrthogonal(m: Point, mDirection: number, l: Point, lDirection: number, obstacles: Obstacles, skipA: string, skipB: string): Point[];
@@ -0,0 +1,47 @@
1
+ import { Point, Relationship } from '../../internal-types';
2
+ /**
3
+ * Where a connector turns away from its anchor.
4
+ *
5
+ * Shared because two callers need the same answer: `pathFinding` draws from it,
6
+ * and `relationshipSort` routes from it. Deriving it twice would let the routed
7
+ * polyline and the guide line drift apart by a slot's worth of stub.
8
+ */
9
+ /**
10
+ * Slot zero keeps the historical `PATH_END_HEIGHT`, so a relationship that never
11
+ * went through `relationshipSort` draws exactly as it did before.
12
+ */
13
+ export declare function stubFor(slot: number): number;
14
+ /**
15
+ * The axis-aligned distance between two anchors that point at each other, or
16
+ * `null` when they do not.
17
+ *
18
+ * Only this arrangement can collapse: with a stub on each side, a gap of twice
19
+ * the stub puts both turning points on the same spot and the connector vanishes,
20
+ * and a smaller gap inverts it so the path runs backwards through both tables.
21
+ * Nothing stops two tables being that close — the editor allows them to overlap.
22
+ */
23
+ export declare function facingGap(start: Relationship['start'], end: Relationship['end']): number | null;
24
+ /**
25
+ * Below roughly `2 * MIN_STUB` the two cardinality decorations already overlap
26
+ * each other, which no stub length can fix; the clamp stops short of making it
27
+ * worse by drawing the guide line backwards.
28
+ */
29
+ export declare function clampStub(stub: number, gap: number | null): number;
30
+ export type StubEnds = {
31
+ /** Turning point on the start side. */
32
+ m: Point;
33
+ /** Turning point on the end side. */
34
+ l: Point;
35
+ startStub: number;
36
+ endStub: number;
37
+ };
38
+ export declare function isHorizontal(direction: number): direction is 1 | 2;
39
+ /** +1 when the anchor's outward normal points right or down. */
40
+ export declare function outwardSign(direction: number): 1 | -1;
41
+ /** The two points a route has to join, given the anchors and their slots. */
42
+ export declare function stubEnds(relationship: Relationship): StubEnds;
43
+ /**
44
+ * Where the guide line begins — the short run between the cardinality
45
+ * decorations and the routed polyline.
46
+ */
47
+ export declare const GUIDE_START: number;
@@ -17,6 +17,7 @@ declare const InternalActionType: {
17
17
  readonly mouseTrackerStart: "mouseTrackerStart";
18
18
  readonly mouseTrackerEnd: "mouseTrackerEnd";
19
19
  readonly openDiffViewer: "openDiffViewer";
20
+ readonly duplicateDragStart: "duplicateDragStart";
20
21
  };
21
22
  type InternalActionType = ValuesType<typeof InternalActionType>;
22
23
  type InternalActionMap = {
@@ -50,6 +51,10 @@ type InternalActionMap = {
50
51
  [InternalActionType.openDiffViewer]: {
51
52
  value: string;
52
53
  };
54
+ [InternalActionType.duplicateDragStart]: {
55
+ tableIds: string[];
56
+ memoIds: string[];
57
+ } | void;
53
58
  };
54
59
  type ListenerRecord = {
55
60
  [P in keyof InternalActionMap]: (action: Action<P, InternalActionMap>) => void;
@@ -165,4 +170,15 @@ export declare const openDiffViewerAction: {
165
170
  toString(): string;
166
171
  type: string;
167
172
  };
173
+ export declare const duplicateDragStartAction: {
174
+ (payload: void | {
175
+ tableIds: string[];
176
+ memoIds: string[];
177
+ }): AnyAction<void | {
178
+ tableIds: string[];
179
+ memoIds: string[];
180
+ }>;
181
+ toString(): string;
182
+ type: string;
183
+ };
168
184
  export {};
@@ -1,6 +1,6 @@
1
1
  import { AppContext } from '../../components/appContext';
2
2
  type ImportOptions = {
3
- type: 'json' | 'sql';
3
+ type: 'json' | 'sql' | 'graphql' | 'dbml' | 'aml';
4
4
  op: 'set' | 'diff';
5
5
  accept: string;
6
6
  };
@@ -8,5 +8,8 @@ type ImportFileCallback = (options: ImportOptions) => void;
8
8
  export declare function setImportFileCallback(callback: ImportFileCallback | null): void;
9
9
  export declare function importJSON({ store, emitter }: AppContext): void;
10
10
  export declare function importSchemaSQL({ store, emitter }: AppContext): void;
11
+ export declare function importGraphQL({ store, emitter }: AppContext): void;
12
+ export declare function importDBML({ store, emitter }: AppContext): void;
13
+ export declare function importAML({ store, emitter }: AppContext): void;
11
14
  export declare function importDiffJSON({ emitter }: AppContext): void;
12
15
  export {};
@@ -1,5 +1,7 @@
1
- import { FocusTable, FocusType } from '../engine/modules/editor/state';
2
- export declare function isFocus(focusTable: FocusTable | null, focusType: FocusType, tableId: string, columnId?: string | null): boolean;
1
+ import { FocusTable, FocusType, SharedFocus } from '../engine/modules/editor/state';
2
+ export declare function isFocus(focusTable: Pick<FocusTable, 'tableId' | 'columnId' | 'focusType'> | null, focusType: FocusType, tableId: string, columnId?: string | null): boolean;
3
3
  export declare const isSelectColumn: (focusTable: FocusTable | null, tableId: string, columnId: string) => boolean;
4
4
  export declare function isEdit(focusTable: FocusTable | null, focusType: FocusType, tableId: string, columnId?: string | null): boolean;
5
5
  export declare function lastCursorFocus(input: HTMLInputElement): void;
6
+ export declare const toSharedFocus: (focusTable: FocusTable | null) => SharedFocus | null;
7
+ export declare const toSharedFocusKey: (focus: SharedFocus | null) => string;
@@ -0,0 +1,4 @@
1
+ import { RootState } from '../../engine/state';
2
+ import { FormatTableOptions } from './utils';
3
+ export declare function createCode(state: RootState): string;
4
+ export declare function formatTable(state: RootState, { buffer, table }: FormatTableOptions): void;
@@ -0,0 +1,4 @@
1
+ import { RootState } from '../../engine/state';
2
+ import { FormatTableOptions } from './utils';
3
+ export declare function createCode(state: RootState): string;
4
+ export declare function formatTable(state: RootState, { buffer, table }: FormatTableOptions): void;
@@ -0,0 +1,4 @@
1
+ import { RootState } from '../../engine/state';
2
+ import { FormatTableOptions } from './utils';
3
+ export declare function createCode(state: RootState): string;
4
+ export declare function formatTable(state: RootState, { buffer, table }: FormatTableOptions): void;
@@ -0,0 +1,4 @@
1
+ import { RootState } from '../../engine/state';
2
+ import { FormatTableOptions } from './utils';
3
+ export declare function createCode(state: RootState): string;
4
+ export declare function formatTable(state: RootState, { buffer, table }: FormatTableOptions): void;
@@ -0,0 +1,4 @@
1
+ import { RootState } from '../../engine/state';
2
+ import { FormatTableOptions } from './utils';
3
+ export declare function createCode(state: RootState): string;
4
+ export declare function formatTable(state: RootState, { buffer, table }: FormatTableOptions): void;
@@ -0,0 +1,4 @@
1
+ import { RootState } from '../../engine/state';
2
+ import { FormatTableOptions } from './utils';
3
+ export declare function createCode(state: RootState): string;
4
+ export declare function formatTable(state: RootState, { buffer, table }: FormatTableOptions): void;
@@ -0,0 +1,4 @@
1
+ import { RootState } from '../../engine/state';
2
+ import { FormatTableOptions } from './utils';
3
+ export declare function createCode(state: RootState): string;
4
+ export declare function formatTable(state: RootState, { buffer, table }: FormatTableOptions): void;
@@ -28,7 +28,7 @@ export declare const KeyBindingName: {
28
28
  readonly zoomOut: "zoomOut";
29
29
  };
30
30
  export type KeyBindingName = ValuesType<typeof KeyBindingName>;
31
- export declare const KeyBindingNameList: ("undo" | "redo" | "selectAllColumn" | "edit" | "addMemo" | "addTable" | "removeTable" | "addColumn" | "removeColumn" | "search" | "stop" | "primaryKey" | "selectAllTable" | "relationshipZeroOne" | "relationshipZeroN" | "relationshipOneOnly" | "relationshipOneN" | "tableProperties" | "zoomIn" | "zoomOut")[];
31
+ export declare const KeyBindingNameList: ("undo" | "redo" | "selectAllColumn" | "search" | "stop" | "edit" | "addMemo" | "addTable" | "removeTable" | "addColumn" | "removeColumn" | "primaryKey" | "selectAllTable" | "relationshipZeroOne" | "relationshipZeroN" | "relationshipOneOnly" | "relationshipOneN" | "tableProperties" | "zoomIn" | "zoomOut")[];
32
32
  export type KeyBindingMap = Record<KeyBindingName, ShortcutOption[]>;
33
33
  export declare const createKeyBindingMap: () => KeyBindingMap;
34
34
  export declare function shortcutToTuple(shortcut?: string): KeyBindingPress[];
@@ -1 +1,2 @@
1
+ export declare const delay: (ms: number) => Promise<void>;
1
2
  export declare function closePromise(): [Promise<void>, () => void];
@@ -0,0 +1,4 @@
1
+ import { ERDEditorSchemaV3 } from '@dineug/erd-editor-schema';
2
+ import { EngineContext } from '../../engine/context';
3
+ import { AMLModel } from './types';
4
+ export declare function convertToSchema(model: AMLModel, ctx: EngineContext, database: number): ERDEditorSchemaV3;
@@ -0,0 +1,13 @@
1
+ import { AMLModel } from './types';
2
+ /**
3
+ * `enumValues` carries the inline `status post_status(draft, published)`
4
+ * members, which never reach `model.types`. Both entry points take them as a
5
+ * trailing optional argument so `convert.ts` keeps one call site each, and
6
+ * inline members take precedence over anything the name would resolve to.
7
+ */
8
+ export declare function resolveDataType(typeName: string, database: number, model: AMLModel, enumValues?: string[]): string;
9
+ /**
10
+ * Keeps the members where the column type cannot hold them. Pass `database` to
11
+ * drop it on the dialects whose `ENUM(...)` column already spells them out.
12
+ */
13
+ export declare function enumCommentSuffix(typeName: string, model: AMLModel, database: number, enumValues?: string[]): string;
@@ -0,0 +1,3 @@
1
+ import { ERDEditorSchemaV3 } from '@dineug/erd-editor-schema';
2
+ import { EngineContext } from '../../engine/context';
3
+ export declare function schemaAMLParserToSchemaJson(aml: string, ctx: EngineContext, prepare?: (schema: ERDEditorSchemaV3) => ERDEditorSchemaV3): string;
@@ -0,0 +1,2 @@
1
+ import { AMLParseResult } from './types';
2
+ export declare function parseAMLModel(source: string): AMLParseResult;
@@ -0,0 +1,25 @@
1
+ export declare const TokenKind: {
2
+ readonly identifier: 1;
3
+ readonly quoted: 2;
4
+ readonly string: 3;
5
+ readonly expression: 4;
6
+ readonly number: 5;
7
+ readonly punctuation: 6;
8
+ readonly doc: 7;
9
+ readonly comment: 8;
10
+ readonly newline: 9;
11
+ };
12
+ /**
13
+ * AML is indentation-sensitive, so every token carries the depth of its line --
14
+ * `-1` when the line is unindented, `0` for the first nesting level. A newline
15
+ * token opens the line that follows it and already holds that line's depth, and
16
+ * the stream always starts with a synthetic one (`value: ''`, `line: 0`), so
17
+ * `parser.ts` reads the first line's depth the same way as every other line's.
18
+ */
19
+ export type Token = {
20
+ kind: number;
21
+ value: string;
22
+ line: number;
23
+ depth: number;
24
+ };
25
+ export declare function tokenize(source: string): Token[];
@@ -0,0 +1,79 @@
1
+ /**
2
+ * `tokenizer.ts` and `parser.ts` own every AML syntax concern -- indentation,
3
+ * quoting and the constraint grammar are resolved into the flat fields below,
4
+ * so `convert.ts` never sees a token. Nesting is resolved the same way: a
5
+ * nested attribute reaches `convert.ts` as one entry whose `path` is dotted.
6
+ */
7
+ export type AMLNamespace = {
8
+ database: string;
9
+ catalog: string;
10
+ schema: string;
11
+ };
12
+ /** `-` and `--` read as `1`, `>` and `<>` as `n`. */
13
+ export type AMLCardinality = '1' | 'n';
14
+ export type AMLEndpoint = {
15
+ namespace: AMLNamespace;
16
+ entityName: string;
17
+ /** Dotted from the entity root, so a nested endpoint keeps `settings.slug`. */
18
+ attributePaths: string[];
19
+ };
20
+ export type AMLRelation = {
21
+ src: AMLEndpoint;
22
+ ref: AMLEndpoint;
23
+ srcCardinality: AMLCardinality;
24
+ refCardinality: AMLCardinality;
25
+ /** `-item_kind=User>`; the discriminator has no editor slot and is dropped. */
26
+ polymorphic: boolean;
27
+ };
28
+ /**
29
+ * One `unique` / `unique=name` / `index` / `index=name` constraint. A bare
30
+ * `unique` is a column flag; every other spelling groups by `name`.
31
+ */
32
+ export type AMLAttributeIndex = {
33
+ name: string;
34
+ unique: boolean;
35
+ };
36
+ export type AMLAttribute = {
37
+ /** Dotted from the entity root; a root attribute is its own name. */
38
+ path: string;
39
+ comment: string;
40
+ /** Holds the argument list and any array suffix; never the namespace. */
41
+ typeName: string;
42
+ /** Inline `status post_status(draft, published)` members. */
43
+ enumValues: string[];
44
+ /** AML is NOT NULL by default, so `nullable` is what clears this. */
45
+ notNull: boolean;
46
+ primaryKey: boolean;
47
+ indexes: AMLAttributeIndex[];
48
+ default: string;
49
+ autoIncrement: boolean;
50
+ };
51
+ export type AMLEntity = {
52
+ namespace: AMLNamespace;
53
+ name: string;
54
+ alias: string;
55
+ comment: string;
56
+ attributes: AMLAttribute[];
57
+ };
58
+ /** A struct and a custom type carry neither field, which is what stops a lookup. */
59
+ export type AMLType = {
60
+ values: string[];
61
+ /** `type uid int` -- the aliased name. */
62
+ alias: string;
63
+ };
64
+ export type AMLModel = {
65
+ entities: AMLEntity[];
66
+ /** Inline and standalone relations in source order, both with `src` filled. */
67
+ relations: AMLRelation[];
68
+ /** Keyed by the qualified name, so `cms.post_status` and `post_status` stay apart. */
69
+ types: Record<string, AMLType>;
70
+ skipped: string[];
71
+ };
72
+ export type AMLParseResult = {
73
+ ok: true;
74
+ model: AMLModel;
75
+ } | {
76
+ ok: false;
77
+ message: string;
78
+ };
79
+ export declare const EMPTY_NAMESPACE: AMLNamespace;
@@ -0,0 +1,4 @@
1
+ import { ERDEditorSchemaV3 } from '@dineug/erd-editor-schema';
2
+ import { EngineContext } from '../../engine/context';
3
+ import { DBMLModel } from './types';
4
+ export declare function convertToSchema(model: DBMLModel, ctx: EngineContext, database: number): ERDEditorSchemaV3;
@@ -0,0 +1,7 @@
1
+ import { DBMLModel } from './types';
2
+ export declare function resolveDataType(typeName: string, typeSchemaName: string, database: number, model: DBMLModel): string;
3
+ /**
4
+ * Keeps the members where the column type cannot hold them. Pass `database` to
5
+ * drop it on the dialects whose `ENUM(...)` column already spells them out.
6
+ */
7
+ export declare function enumCommentSuffix(typeName: string, typeSchemaName: string, model: DBMLModel, database: number): string;
@@ -0,0 +1,3 @@
1
+ import { ERDEditorSchemaV3 } from '@dineug/erd-editor-schema';
2
+ import { EngineContext } from '../../engine/context';
3
+ export declare function schemaDBMLParserToSchemaJson(dbml: string, ctx: EngineContext, prepare?: (schema: ERDEditorSchemaV3) => ERDEditorSchemaV3): string;
@@ -0,0 +1,2 @@
1
+ import { DBMLParseResult } from './types';
2
+ export declare function parseDBMLModel(source: string): DBMLParseResult;
@@ -0,0 +1,16 @@
1
+ export declare const TokenKind: {
2
+ readonly identifier: 1;
3
+ readonly quoted: 2;
4
+ readonly string: 3;
5
+ readonly expression: 4;
6
+ readonly number: 5;
7
+ readonly punctuation: 6;
8
+ readonly operator: 7;
9
+ readonly newline: 8;
10
+ };
11
+ export type Token = {
12
+ kind: number;
13
+ value: string;
14
+ line: number;
15
+ };
16
+ export declare function tokenize(source: string): Token[];