@rokkit/graph 1.6.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.
- package/LICENSE +21 -0
- package/README.md +100 -0
- package/dist/Graph.svelte +369 -0
- package/dist/Graph.svelte.d.ts +4 -0
- package/dist/GraphState.svelte.d.ts +171 -0
- package/dist/GraphState.svelte.js +398 -0
- package/dist/icons.d.ts +13 -0
- package/dist/icons.js +38 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +8 -0
- package/dist/layout/cards.d.ts +19 -0
- package/dist/layout/cards.js +31 -0
- package/dist/layout/cluster.d.ts +11 -0
- package/dist/layout/cluster.js +39 -0
- package/dist/layout/clusters.d.ts +39 -0
- package/dist/layout/clusters.js +217 -0
- package/dist/layout/constants.d.ts +12 -0
- package/dist/layout/constants.js +15 -0
- package/dist/layout/edges.d.ts +5 -0
- package/dist/layout/edges.js +110 -0
- package/dist/layout/index.d.ts +9 -0
- package/dist/layout/index.js +7 -0
- package/dist/layout/neighborhood.d.ts +9 -0
- package/dist/layout/neighborhood.js +123 -0
- package/dist/layout/nested.d.ts +13 -0
- package/dist/layout/nested.js +156 -0
- package/dist/layout/points.d.ts +6 -0
- package/dist/layout/points.js +204 -0
- package/dist/layout/types.d.ts +115 -0
- package/dist/layout/types.js +1 -0
- package/dist/model/normalize.d.ts +7 -0
- package/dist/model/normalize.js +215 -0
- package/dist/model/path.d.ts +13 -0
- package/dist/model/path.js +23 -0
- package/dist/preset.d.ts +47 -0
- package/dist/preset.js +61 -0
- package/dist/schema/EntitiesView.svelte +83 -0
- package/dist/schema/EntitiesView.svelte.d.ts +13 -0
- package/dist/schema/EntityView.svelte +116 -0
- package/dist/schema/EntityView.svelte.d.ts +13 -0
- package/dist/schema/NoteBlocks.svelte +31 -0
- package/dist/schema/NoteBlocks.svelte.d.ts +6 -0
- package/dist/schema/column-type.d.ts +4 -0
- package/dist/schema/column-type.js +19 -0
- package/dist/schema/fromSchemaModel.d.ts +66 -0
- package/dist/schema/fromSchemaModel.js +92 -0
- package/dist/schema/index.d.ts +8 -0
- package/dist/schema/index.js +7 -0
- package/dist/schema/notes.d.ts +12 -0
- package/dist/schema/notes.js +65 -0
- package/dist/types.d.ts +160 -0
- package/dist/types.js +1 -0
- package/package.json +62 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/** A flag rendered as a badge on a node row. */
|
|
2
|
+
export type RowBadge = 'pk' | 'fk' | 'uq' | 'nn';
|
|
3
|
+
/** One row inside a node — a column, a parameter, a field. */
|
|
4
|
+
export type GraphRow = {
|
|
5
|
+
name: string;
|
|
6
|
+
type?: string;
|
|
7
|
+
badges: RowBadge[];
|
|
8
|
+
note?: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Whether an edge expresses a data reference (a foreign key) or a dependency
|
|
12
|
+
* (a view reading a table, a procedure calling a function). Layouts branch on
|
|
13
|
+
* this rather than on any schema-specific notion.
|
|
14
|
+
*/
|
|
15
|
+
export type EdgeKind = 'reference' | 'dependency';
|
|
16
|
+
export type GraphNode = {
|
|
17
|
+
/** Stable key. `${group}.${label}` when a group is present, else `label`. */
|
|
18
|
+
id: string;
|
|
19
|
+
label: string;
|
|
20
|
+
/** Open vocabulary — a schema name. Drives cluster grouping and group colour. */
|
|
21
|
+
group?: string;
|
|
22
|
+
/** Closed vocabulary — table | view | matview | function | procedure | enum. */
|
|
23
|
+
kind?: string;
|
|
24
|
+
rows: GraphRow[];
|
|
25
|
+
note?: string;
|
|
26
|
+
/** Source fields the map did not claim, passed through untouched. */
|
|
27
|
+
meta: Record<string, unknown>;
|
|
28
|
+
};
|
|
29
|
+
export type GraphEdge = {
|
|
30
|
+
id: string;
|
|
31
|
+
/** GraphNode.id */
|
|
32
|
+
source: string;
|
|
33
|
+
/** GraphNode.id */
|
|
34
|
+
target: string;
|
|
35
|
+
/** GraphRow.name — the anchor row on the source card. */
|
|
36
|
+
sourceRow?: string;
|
|
37
|
+
/** GraphRow.name — the anchor row on the target card. */
|
|
38
|
+
targetRow?: string;
|
|
39
|
+
kind: EdgeKind;
|
|
40
|
+
/**
|
|
41
|
+
* The consumer's own word for the relationship, when it has one — dbd v2's `DepEdge.kind`
|
|
42
|
+
* is `reads | writes | calls | member`.
|
|
43
|
+
*
|
|
44
|
+
* Open vocabulary, deliberately. `kind` stays the two-value discriminator that layouts
|
|
45
|
+
* branch on; widening THAT to hold four SQL verbs would teach a generic graph package
|
|
46
|
+
* what a stored procedure is. This carries the word so the renderer can label and theme
|
|
47
|
+
* it (`data-edge-relation`) without the coupling.
|
|
48
|
+
*/
|
|
49
|
+
relation?: string;
|
|
50
|
+
cardinality?: string;
|
|
51
|
+
action?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Endpoints the field map could not resolve to a node, with the raw value left in place
|
|
54
|
+
* on `source`/`target` so it is still readable.
|
|
55
|
+
*
|
|
56
|
+
* An unresolvable endpoint is a NORMAL state, not a defect. Sensei's code graph reports
|
|
57
|
+
* 59.6% of 4.08M edges with a null target: the call is real, the callee is simply not
|
|
58
|
+
* indexed. Dropping those would make the graph look far more complete than it is, so the
|
|
59
|
+
* edge is kept and marked, and it is the renderer's job to dim it.
|
|
60
|
+
*/
|
|
61
|
+
unplaced?: 'source' | 'target' | 'both';
|
|
62
|
+
};
|
|
63
|
+
export type GraphModel = {
|
|
64
|
+
nodes: GraphNode[];
|
|
65
|
+
edges: GraphEdge[];
|
|
66
|
+
byId: Map<string, GraphNode>;
|
|
67
|
+
/** Undirected adjacency, self-edges excluded. */
|
|
68
|
+
neighbors: Map<string, Set<string>>;
|
|
69
|
+
};
|
|
70
|
+
/**
|
|
71
|
+
* Props for the `Graph` canvas.
|
|
72
|
+
*
|
|
73
|
+
* Either hand it a `state` — for composition, or to drive selection from outside — or hand
|
|
74
|
+
* it `nodes`/`edges`/`fields` and let it construct one. A supplied `state` must have STABLE
|
|
75
|
+
* IDENTITY for the component's lifetime: drive the existing instance through its own methods
|
|
76
|
+
* and `update()` rather than swapping instances, because context captures it once at init.
|
|
77
|
+
*/
|
|
78
|
+
export type GraphProps = {
|
|
79
|
+
state?: import('./GraphState.svelte.js').GraphState;
|
|
80
|
+
nodes?: unknown[];
|
|
81
|
+
edges?: unknown[];
|
|
82
|
+
fields?: GraphFields;
|
|
83
|
+
layout?: string | import('./layout/types.js').LayoutFn;
|
|
84
|
+
density?: import('./layout/types.js').Density;
|
|
85
|
+
arrange?: import('./layout/types.js').Arrange;
|
|
86
|
+
/** Outer grouping axis — `group` (default) or `kind`. */
|
|
87
|
+
groupBy?: import('./layout/types.js').NodeAxis;
|
|
88
|
+
/** Subdivide each cluster by a second axis. Omit for one level. */
|
|
89
|
+
nestBy?: import('./layout/types.js').NodeAxis;
|
|
90
|
+
edgeStyle?: import('./layout/types.js').EdgeStyle;
|
|
91
|
+
/** `neighborhood` only — the node the view centres on. Defaults to the selection. */
|
|
92
|
+
focus?: string | null;
|
|
93
|
+
value?: string | null;
|
|
94
|
+
preset?: import('./preset.js').GraphPreset;
|
|
95
|
+
mode?: 'light' | 'dark';
|
|
96
|
+
/**
|
|
97
|
+
* Multiplier on the fit-to-container scale. 1 fits the whole diagram; above 1 the canvas
|
|
98
|
+
* scrolls and drags rather than clipping. Bindable — the built-in controls drive it.
|
|
99
|
+
*/
|
|
100
|
+
zoom?: number;
|
|
101
|
+
/** Built-in zoom controls, ctrl/pinch-wheel zoom and drag-to-pan. Default true. */
|
|
102
|
+
zoomable?: boolean;
|
|
103
|
+
/** Built-in names/keys/all detail toggle on the canvas. Default true. */
|
|
104
|
+
densityToggle?: boolean;
|
|
105
|
+
/**
|
|
106
|
+
* Draw an arrowhead at each edge's target instead of a plain anchor dot. Default true —
|
|
107
|
+
* an edge is directed, and two identical dots discard that.
|
|
108
|
+
*/
|
|
109
|
+
arrows?: boolean;
|
|
110
|
+
label?: string;
|
|
111
|
+
onselect?: (id: string) => void;
|
|
112
|
+
/** Icon class per node kind and row badge, merged over the built-in map. */
|
|
113
|
+
icons?: Record<string, string>;
|
|
114
|
+
class?: string;
|
|
115
|
+
};
|
|
116
|
+
/**
|
|
117
|
+
* Field map from a consumer's shape to the canonical model. Every entry is a
|
|
118
|
+
* dotted path read with `readPath`. Anything omitted falls back to the
|
|
119
|
+
* same-named key, so a source already shaped like the canonical model needs no map.
|
|
120
|
+
*/
|
|
121
|
+
export type GraphFields = {
|
|
122
|
+
id?: string;
|
|
123
|
+
label?: string;
|
|
124
|
+
group?: string;
|
|
125
|
+
kind?: string;
|
|
126
|
+
rows?: string;
|
|
127
|
+
note?: string;
|
|
128
|
+
/** Row-level paths, read against each entry of the `rows` array. */
|
|
129
|
+
rowName?: string;
|
|
130
|
+
rowType?: string;
|
|
131
|
+
rowNote?: string;
|
|
132
|
+
/** Row badge flags — each names a truthy path on the row. */
|
|
133
|
+
rowBadges?: Partial<Record<RowBadge, string>>;
|
|
134
|
+
/** Edge-level paths. */
|
|
135
|
+
source?: string;
|
|
136
|
+
target?: string;
|
|
137
|
+
/**
|
|
138
|
+
* Where each endpoint's GROUP is read from, when the endpoint value is a bare label.
|
|
139
|
+
* Declared explicitly rather than guessed: dbd's refs nest as `from: { s, t, c }`, so the
|
|
140
|
+
* group is `from.s`. Falls back to `group` (the node-level path) when unset.
|
|
141
|
+
*/
|
|
142
|
+
sourceGroup?: string;
|
|
143
|
+
targetGroup?: string;
|
|
144
|
+
sourceRow?: string;
|
|
145
|
+
targetRow?: string;
|
|
146
|
+
edgeKind?: string;
|
|
147
|
+
/**
|
|
148
|
+
* Kind for an edge whose `edgeKind` path yields nothing. Defaults to `'reference'`.
|
|
149
|
+
*
|
|
150
|
+
* For a dataset that is ENTIRELY dependencies — dbd v2's `deps`, or a call graph — the
|
|
151
|
+
* kind is a property of the list, not of each row, and there is no path to point at.
|
|
152
|
+
* Without this the consumer has to rewrite every edge object just to tag it, or accept
|
|
153
|
+
* every call being drawn as a foreign key.
|
|
154
|
+
*/
|
|
155
|
+
defaultEdgeKind?: EdgeKind;
|
|
156
|
+
/** Path to the consumer's own relationship word — see `GraphEdge.relation`. */
|
|
157
|
+
relation?: string;
|
|
158
|
+
cardinality?: string;
|
|
159
|
+
action?: string;
|
|
160
|
+
};
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rokkit/graph",
|
|
3
|
+
"version": "1.6.0",
|
|
4
|
+
"description": "Node-link diagram components — pluggable layouts, ER/schema views",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/jerrythomas/rokkit.git"
|
|
8
|
+
},
|
|
9
|
+
"author": "Jerry Thomas <me@jerrythomas.name>",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"type": "module",
|
|
12
|
+
"svelte": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public"
|
|
16
|
+
},
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
|
+
"svelte": "./dist/index.js",
|
|
21
|
+
"default": "./dist/index.js"
|
|
22
|
+
},
|
|
23
|
+
"./schema": {
|
|
24
|
+
"types": "./dist/schema/index.d.ts",
|
|
25
|
+
"svelte": "./dist/schema/index.js",
|
|
26
|
+
"default": "./dist/schema/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./package.json": "./package.json"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"README.md",
|
|
33
|
+
"LICENSE"
|
|
34
|
+
],
|
|
35
|
+
"scripts": {
|
|
36
|
+
"prepublishOnly": "cp ../../LICENSE . && bun run clean && bun run build && node ../../config/pack-repoint.mjs",
|
|
37
|
+
"postpublish": "node ../../config/pack-repoint.mjs --restore && rm -f LICENSE",
|
|
38
|
+
"clean": "rm -rf dist",
|
|
39
|
+
"build": "svelte-package -i src -o dist",
|
|
40
|
+
"check": "svelte-check --tsconfig ./tsconfig.json",
|
|
41
|
+
"check:types": "tsc --noEmit"
|
|
42
|
+
},
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"@rokkit/core": "1.6.0"
|
|
45
|
+
},
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"@rokkit/ui": "1.6.0",
|
|
48
|
+
"svelte": "^5.0.0"
|
|
49
|
+
},
|
|
50
|
+
"peerDependenciesMeta": {
|
|
51
|
+
"@rokkit/ui": {
|
|
52
|
+
"optional": true
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@rokkit/ui": "1.6.0",
|
|
57
|
+
"@sveltejs/package": "^2.5.8",
|
|
58
|
+
"@sveltejs/vite-plugin-svelte": "^6.2.4",
|
|
59
|
+
"svelte": "^5.55.7",
|
|
60
|
+
"svelte-check": "^4.7.6"
|
|
61
|
+
}
|
|
62
|
+
}
|