@petrarca/sonnet-graph 0.6.0 → 0.8.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/README.md +89 -118
- package/dist/index.d.ts +354 -33
- package/dist/index.js +1534 -636
- package/dist/index.js.map +1 -1
- package/package.json +6 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import * as zustand from 'zustand';
|
|
2
|
-
import { UseBoundStore, StoreApi } from 'zustand';
|
|
3
1
|
import * as React from 'react';
|
|
4
2
|
import React__default, { ReactNode } from 'react';
|
|
3
|
+
import * as zustand from 'zustand';
|
|
4
|
+
import { UseBoundStore, StoreApi } from 'zustand';
|
|
5
5
|
import { GraphEdge, GraphNode } from 'reagraph';
|
|
6
6
|
import cytoscape from 'cytoscape';
|
|
7
7
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
@@ -272,6 +272,107 @@ declare function normalizeGraph(nodes: VisualGraphNode[], edges: VisualGraphEdge
|
|
|
272
272
|
*/
|
|
273
273
|
declare const EMPTY_NORMALIZED: VisualGraphNormalized;
|
|
274
274
|
|
|
275
|
+
/**
|
|
276
|
+
* Extracts graph elements from tabular Cypher query rows.
|
|
277
|
+
*
|
|
278
|
+
* cypher-graphdb (the underlying graph-database library) serializes a
|
|
279
|
+
* node/relationship RETURN-column value wrapped as `{ node: RawGraphNode }` /
|
|
280
|
+
* `{ edge: RawGraphEdge }` (its `serialize_model(with_type=True)` default,
|
|
281
|
+
* shared by every consumer of a cypher-graphdb-backed Cypher endpoint) --
|
|
282
|
+
* scalar columns (a property projection, an aggregate) are unwrapped plain
|
|
283
|
+
* values. A host whose backend returns query results as plain tabular rows
|
|
284
|
+
* (rather than a pre-shaped `{ nodes, edges }` response) uses this to decide
|
|
285
|
+
* whether a result is graph-shaped at all and to collect its elements, deduped
|
|
286
|
+
* by `id_` (the same node/edge commonly repeats across rows).
|
|
287
|
+
*/
|
|
288
|
+
interface ExtractedGraphRows {
|
|
289
|
+
nodes: RawGraphNode[];
|
|
290
|
+
edges: RawGraphEdge[];
|
|
291
|
+
/** True if any row cell was a wrapped node/edge -- the result has something to draw. */
|
|
292
|
+
isGraph: boolean;
|
|
293
|
+
}
|
|
294
|
+
/** Scan tabular rows (each an array of RETURN-column cell values) for wrapped node/edge cells. */
|
|
295
|
+
declare function extractGraphFromRows(rows: unknown[][]): ExtractedGraphRows;
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* QueryEditor -- a pure, reusable query editor (no store or app dependencies).
|
|
299
|
+
*
|
|
300
|
+
* A props-based editor for graph query languages (Cypher, Datalog, ...): an
|
|
301
|
+
* auto-sizing textarea, Ctrl/Cmd+Enter to execute, an inline error alert with
|
|
302
|
+
* copy-to-clipboard, and an optional custom action-button slot. Every host
|
|
303
|
+
* (an app's own query bar, a graph workbench) drives it purely through props,
|
|
304
|
+
* so it carries none of the caller's state.
|
|
305
|
+
*
|
|
306
|
+
* Promoted into sonnet-graph from the cypher-graphdb explorer, decoupled from
|
|
307
|
+
* that app's clipboard hook (uses sonnet-core's copyTextToClipboard).
|
|
308
|
+
*/
|
|
309
|
+
|
|
310
|
+
interface QueryEditorProps {
|
|
311
|
+
/** Current query text value. */
|
|
312
|
+
value: string;
|
|
313
|
+
/** Called when the user executes (Ctrl/Cmd+Enter or the Run button). */
|
|
314
|
+
onExecute: (query: string) => void;
|
|
315
|
+
/** Called when the query text changes. */
|
|
316
|
+
onChange?: (query: string) => void;
|
|
317
|
+
/** Whether execution is in progress. */
|
|
318
|
+
isLoading?: boolean;
|
|
319
|
+
/** Error message to display (null = none). */
|
|
320
|
+
error?: string | null;
|
|
321
|
+
/** Placeholder for the empty editor. */
|
|
322
|
+
placeholder?: string;
|
|
323
|
+
/** Minimum rows (default 1). */
|
|
324
|
+
minRows?: number;
|
|
325
|
+
/** Maximum rows before the textarea scrolls (default 12). */
|
|
326
|
+
maxRows?: number;
|
|
327
|
+
/** Extra class on the wrapper. */
|
|
328
|
+
className?: string;
|
|
329
|
+
/** Custom action buttons (replaces the default Run button). */
|
|
330
|
+
renderActions?: (props: {
|
|
331
|
+
onExecute: () => void;
|
|
332
|
+
isLoading: boolean;
|
|
333
|
+
}) => React__default.ReactNode;
|
|
334
|
+
}
|
|
335
|
+
declare function QueryEditor({ value, onExecute, onChange, isLoading, error, placeholder, minRows, maxRows, className, renderActions, }: QueryEditorProps): React__default.ReactElement;
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* createQueryHistoryStore -- a persisted list of recently-run query strings.
|
|
339
|
+
*
|
|
340
|
+
* A reusable Zustand store factory for a graph query editor's history: add()
|
|
341
|
+
* prepends (de-duping repeats), the list is capped, and it persists to
|
|
342
|
+
* localStorage under a caller-chosen key so history survives reloads. Language-
|
|
343
|
+
* and backend-agnostic (it stores plain query text), so any editor -- Cypher,
|
|
344
|
+
* Datalog -- can use it. The consuming app creates one instance and shares it
|
|
345
|
+
* between the query bar (which add()s on run) and the History dropdown.
|
|
346
|
+
*/
|
|
347
|
+
|
|
348
|
+
interface QueryHistoryState {
|
|
349
|
+
queries: string[];
|
|
350
|
+
add: (query: string) => void;
|
|
351
|
+
clear: () => void;
|
|
352
|
+
}
|
|
353
|
+
type QueryHistoryStore = UseBoundStore<StoreApi<QueryHistoryState>>;
|
|
354
|
+
/**
|
|
355
|
+
* Build a persisted query-history store.
|
|
356
|
+
*
|
|
357
|
+
* @param persistKey localStorage key (unique per editor, e.g. "graph-query-history").
|
|
358
|
+
* @param limit max entries to retain (default 50).
|
|
359
|
+
*/
|
|
360
|
+
declare function createQueryHistoryStore(persistKey: string, limit?: number): QueryHistoryStore;
|
|
361
|
+
|
|
362
|
+
/**
|
|
363
|
+
* QueryHistory -- a dropdown of recently-run queries.
|
|
364
|
+
*
|
|
365
|
+
* Reads a QueryHistoryStore (created by createQueryHistoryStore) and lets the
|
|
366
|
+
* user pick a past query (onSelect) or clear the list. Presentational + store-
|
|
367
|
+
* bound only; the consuming app decides what onSelect does (typically: load the
|
|
368
|
+
* query into the editor). Designed to sit in a QueryEditor's renderActions slot.
|
|
369
|
+
*/
|
|
370
|
+
|
|
371
|
+
declare function QueryHistory({ store, onSelect, }: {
|
|
372
|
+
store: QueryHistoryStore;
|
|
373
|
+
onSelect: (query: string) => void;
|
|
374
|
+
}): React__default.ReactElement;
|
|
375
|
+
|
|
275
376
|
/**
|
|
276
377
|
* Extract display label from a node or edge using resolved display config.
|
|
277
378
|
*
|
|
@@ -419,7 +520,7 @@ declare function createGraphDataStore(): zustand.UseBoundStore<zustand.StoreApi<
|
|
|
419
520
|
/**
|
|
420
521
|
* GraphFilterStore - Node/edge label filtering and data-change tracking.
|
|
421
522
|
*
|
|
422
|
-
* Graph-generic filtering store. Separated from
|
|
523
|
+
* Graph-generic filtering store. Separated from query-language-specific
|
|
423
524
|
* query editing (QueryEditorStore stays in the consumer).
|
|
424
525
|
*/
|
|
425
526
|
interface GraphFilterStore {
|
|
@@ -679,19 +780,34 @@ type StoreFactory<T> = () => UseBoundStore<StoreApi<T>>;
|
|
|
679
780
|
* Bundle of graph-related workspace-scoped store instances.
|
|
680
781
|
* Each workspace gets its own isolated set of these stores.
|
|
681
782
|
*
|
|
682
|
-
* Note: QueryEditorStore stays in the consumer
|
|
683
|
-
*
|
|
783
|
+
* Note: QueryEditorStore stays in the consumer since it is
|
|
784
|
+
* query-language-specific, not part of generic graph visualization.
|
|
684
785
|
*/
|
|
685
786
|
interface WorkspaceStores {
|
|
686
787
|
graphFilter: UseBoundStore<StoreApi<GraphFilterStore>>;
|
|
687
788
|
graphData: UseBoundStore<StoreApi<GraphDataStore>>;
|
|
688
789
|
graphExploration: UseBoundStore<StoreApi<GraphExplorationStore>>;
|
|
689
790
|
selection: UseBoundStore<StoreApi<SelectionStore>>;
|
|
791
|
+
/**
|
|
792
|
+
* Focus is workspace-scoped, not global.
|
|
793
|
+
*
|
|
794
|
+
* It is a two-part protocol, and both parts belong to one graph surface:
|
|
795
|
+
* `focusAction` is the request, and `overrideElementIds` is what makes a
|
|
796
|
+
* filtered-out element visible so the request can be carried out --
|
|
797
|
+
* useLiveGraphData merges those ids back past every filter. Sharing the store
|
|
798
|
+
* across surfaces would let a focus in one punch a hole in another's data.
|
|
799
|
+
*
|
|
800
|
+
* GraphExploration already writes focus through an injected store; before
|
|
801
|
+
* this, the readers used the module singleton instead, so a host that created
|
|
802
|
+
* an isolated focus store (the model editor, the playground) had its requests
|
|
803
|
+
* land where nothing was listening.
|
|
804
|
+
*/
|
|
805
|
+
graphFocus: UseBoundStore<StoreApi<GraphFocusStore>>;
|
|
690
806
|
}
|
|
691
807
|
|
|
692
808
|
/**
|
|
693
809
|
* Context for providing graph stores to visualization components.
|
|
694
|
-
* Must be set by the host application
|
|
810
|
+
* Must be set by the host application.
|
|
695
811
|
*/
|
|
696
812
|
declare const GraphStoresContext: React.Context<WorkspaceStores | null>;
|
|
697
813
|
/** Get GraphFilter store from context. */
|
|
@@ -702,6 +818,14 @@ declare function useWorkspaceGraphData(): UseBoundStore<StoreApi<GraphDataStore>
|
|
|
702
818
|
declare function useWorkspaceGraphExploration(): UseBoundStore<StoreApi<GraphExplorationStore>>;
|
|
703
819
|
/** Get Selection store from context. */
|
|
704
820
|
declare function useWorkspaceSelection(): UseBoundStore<StoreApi<SelectionStore>>;
|
|
821
|
+
/**
|
|
822
|
+
* Get GraphFocus store from context.
|
|
823
|
+
*
|
|
824
|
+
* Read this rather than importing the module singleton: focus is scoped to a
|
|
825
|
+
* graph surface, so a host with more than one (an explorer plus a model editor)
|
|
826
|
+
* keeps them independent.
|
|
827
|
+
*/
|
|
828
|
+
declare function useWorkspaceGraphFocus(): UseBoundStore<StoreApi<GraphFocusStore>>;
|
|
705
829
|
|
|
706
830
|
declare function useStableRef<T extends (...args: never[]) => unknown>(fn: T): T;
|
|
707
831
|
declare function useStableRef<T extends (...args: never[]) => unknown>(fn: T | undefined): T | undefined;
|
|
@@ -906,7 +1030,7 @@ declare function GraphA11yList({ visible, rowHeight, maxHeight, className, }: Gr
|
|
|
906
1030
|
* A graph model is a list of type schemas, each a JSON Schema carrying an
|
|
907
1031
|
* `x-graph` extension that declares whether it is a node or edge type, its
|
|
908
1032
|
* graph label, and (for node types) the valid outbound relations. This mirrors
|
|
909
|
-
* the shape consumed by
|
|
1033
|
+
* the shape consumed by the schema-to-graph backend, so a model authored here is a
|
|
910
1034
|
* valid model there.
|
|
911
1035
|
*
|
|
912
1036
|
* The model is the source of truth. It is rendered as a graph of node-types and
|
|
@@ -998,7 +1122,7 @@ declare function typeLabel(schema: GraphTypeSchema): string;
|
|
|
998
1122
|
* and `GraphVisualizer`. The model JSON is the source of truth; there is no
|
|
999
1123
|
* reverse conversion.
|
|
1000
1124
|
*
|
|
1001
|
-
*
|
|
1125
|
+
* Converts JSON Schemas to a graph model with two deliberate
|
|
1002
1126
|
* differences:
|
|
1003
1127
|
* - Node/edge ids are derived deterministically from type/relation names so
|
|
1004
1128
|
* the same model always yields the same ids (required for visualizer merge,
|
|
@@ -1503,17 +1627,16 @@ declare function NodeTypeNameSheet({ open, onOpenChange, initial, existing, noun
|
|
|
1503
1627
|
*
|
|
1504
1628
|
* The write analog of the read-side injected dependencies
|
|
1505
1629
|
* (`GraphExplorationDeps` / `GraphDataHook`). The library's editing components
|
|
1506
|
-
* call only this port; they never see HTTP, auth,
|
|
1507
|
-
* consumer implements the port against its own backend
|
|
1508
|
-
* existing `graphService`; a new consumer wraps its own graph REST API).
|
|
1630
|
+
* call only this port; they never see HTTP, auth, a query language, or a cache.
|
|
1631
|
+
* Each consumer implements the port against its own backend.
|
|
1509
1632
|
*
|
|
1510
|
-
* Node/edge ids are numeric, matching `RawGraphNode.id_` / `RawGraphEdge.id_
|
|
1511
|
-
*
|
|
1512
|
-
*
|
|
1633
|
+
* Node/edge ids are numeric, matching `RawGraphNode.id_` / `RawGraphEdge.id_`.
|
|
1634
|
+
* (If a future consumer keys nodes by string, this would widen to
|
|
1635
|
+
* `number | string`.)
|
|
1513
1636
|
*
|
|
1514
1637
|
* The port is EVENT-FREE: it `await`s and returns the mutation result; it does
|
|
1515
1638
|
* not own a cache and emits no events. The consumer wraps the port to patch its
|
|
1516
|
-
* own cache
|
|
1639
|
+
* own cache.
|
|
1517
1640
|
*
|
|
1518
1641
|
* Relations stay ATOMIC: `createNodeWithRelations` / `updateNodeWithRelations`
|
|
1519
1642
|
* are single port methods, not decomposed into node + edge calls in the
|
|
@@ -1585,8 +1708,8 @@ interface UpdateNodeWithRelationsResult {
|
|
|
1585
1708
|
};
|
|
1586
1709
|
}
|
|
1587
1710
|
/**
|
|
1588
|
-
* The injected write interface. Shapes
|
|
1589
|
-
*
|
|
1711
|
+
* The injected write interface. Shapes are deliberately close to a typical
|
|
1712
|
+
* graph REST service, so a consumer's adapter can be a thin wrapper.
|
|
1590
1713
|
*/
|
|
1591
1714
|
interface GraphMutationPort {
|
|
1592
1715
|
createNode(input: CreateNodeInput): Promise<RawGraphNode>;
|
|
@@ -1606,8 +1729,7 @@ interface GraphMutationPort {
|
|
|
1606
1729
|
getPairEdges(a: number, b: number): Promise<RawGraphEdge[]>;
|
|
1607
1730
|
/**
|
|
1608
1731
|
* Fetch nodes by id -- used by the delete-node dialog to resolve the display
|
|
1609
|
-
* names of dependent (neighbour) nodes.
|
|
1610
|
-
* graphService.getNodes.
|
|
1732
|
+
* names of dependent (neighbour) nodes.
|
|
1611
1733
|
*/
|
|
1612
1734
|
getNodes(ids: number[]): Promise<RawGraphNode[]>;
|
|
1613
1735
|
}
|
|
@@ -1646,7 +1768,7 @@ interface RelationDef {
|
|
|
1646
1768
|
/**
|
|
1647
1769
|
* Whether this relation is surfaced as an editable form field. Only relations
|
|
1648
1770
|
* with `form_field === true` become `__rel_*` fields in the node form
|
|
1649
|
-
*
|
|
1771
|
+
* Defaults to not-a-field.
|
|
1650
1772
|
*/
|
|
1651
1773
|
form_field?: boolean;
|
|
1652
1774
|
/**
|
|
@@ -1658,8 +1780,8 @@ interface RelationDef {
|
|
|
1658
1780
|
title?: string;
|
|
1659
1781
|
/**
|
|
1660
1782
|
* Optional widget hint for the relation field (the `x-ui-widget` value).
|
|
1661
|
-
* Defaults to "entity-select".
|
|
1662
|
-
*
|
|
1783
|
+
* Defaults to "entity-select". A consumer can override it with a custom
|
|
1784
|
+
* widget name; the widget itself is supplied app-level via the registry.
|
|
1663
1785
|
*/
|
|
1664
1786
|
widget?: string;
|
|
1665
1787
|
}
|
|
@@ -1773,11 +1895,10 @@ declare function validateGraphCapabilities(input: unknown): GraphCapabilitiesVal
|
|
|
1773
1895
|
* convert between that flat form shape and the structured
|
|
1774
1896
|
* `{ properties, relations }` the mutation port expects.
|
|
1775
1897
|
*
|
|
1776
|
-
*
|
|
1777
|
-
*
|
|
1778
|
-
*
|
|
1779
|
-
*
|
|
1780
|
-
* hardcoded backend call.
|
|
1898
|
+
* Kept here so every consumer of the shared editor gets the same relation
|
|
1899
|
+
* handling. The functions are pure -- no I/O. Reads of a node's existing
|
|
1900
|
+
* relations go through the injected `GraphMutationPort` (getInboundEdges /
|
|
1901
|
+
* getOutboundEdges), not a hardcoded backend call.
|
|
1781
1902
|
*/
|
|
1782
1903
|
|
|
1783
1904
|
/** A per-field UI schema map, as JsonSchemaFormRenderer's `uiSchema` prop. */
|
|
@@ -1814,17 +1935,17 @@ declare function extractRelationFields(formData: Record<string, unknown>): {
|
|
|
1814
1935
|
/** Whether any form key is a relation field (decides the atomic save path). */
|
|
1815
1936
|
declare function hasRelationFields(formData: Record<string, unknown>): boolean;
|
|
1816
1937
|
/** Title-case a relation type for a default field title ("USES_TECHNOLOGY" ->
|
|
1817
|
-
* "Uses Technology").
|
|
1938
|
+
* "Uses Technology"). */
|
|
1818
1939
|
declare function relationTitle(relationType: string): string;
|
|
1819
1940
|
/** A relation is editable (becomes a form field) when form_field === true,
|
|
1820
|
-
*
|
|
1941
|
+
* for display. */
|
|
1821
1942
|
declare function editableRelations(relations: RelationDef[]): RelationDef[];
|
|
1822
1943
|
/** Whether a node/edge schema declares any properties (gates "Edit edge" the
|
|
1823
|
-
* same way the
|
|
1944
|
+
* same way the has-properties check does). */
|
|
1824
1945
|
declare function hasProperties(schema: JsonSchema | null | undefined): boolean;
|
|
1825
1946
|
/**
|
|
1826
1947
|
* Enrich a node schema with a `__rel_*` field per editable relation, returning
|
|
1827
|
-
* a new `{ schema, uiSchema }`.
|
|
1948
|
+
* a new `{ schema, uiSchema }`. Enrichment:
|
|
1828
1949
|
* - field type is `array of integer` (multi) for ONE_TO_MANY / unset
|
|
1829
1950
|
* cardinality, or `integer` (single) for ONE_TO_ONE;
|
|
1830
1951
|
* - the field title is the relation's title or a Title-Cased label;
|
|
@@ -1845,7 +1966,7 @@ declare function enrichSchemaWithRelations(baseSchema: JsonSchema, relations: Re
|
|
|
1845
1966
|
* Reads the current selection from the workspace selection store (the same
|
|
1846
1967
|
* store the viewer owns), gates each action behind the resolved
|
|
1847
1968
|
* `GraphCapabilities`, and owns the edit dialogs (node form, edge form, delete
|
|
1848
|
-
* confirm).
|
|
1969
|
+
* confirm). Library-native:
|
|
1849
1970
|
* it drives everything through the injected `GraphMutationPort` +
|
|
1850
1971
|
* `GraphSchemaProvider` and is slot-injectable via `ActionPanel actions={...}`.
|
|
1851
1972
|
*
|
|
@@ -1941,4 +2062,204 @@ interface DeleteNodeDialogProps {
|
|
|
1941
2062
|
}
|
|
1942
2063
|
declare function DeleteNodeDialog({ open, onOpenChange, node, port, onDeleted, }: DeleteNodeDialogProps): React__default.ReactElement;
|
|
1943
2064
|
|
|
1944
|
-
|
|
2065
|
+
/**
|
|
2066
|
+
* GraphFinder -- locate nodes and edges within the currently loaded graph.
|
|
2067
|
+
*
|
|
2068
|
+
* Three modes:
|
|
2069
|
+
* - Full-Text: natural-language, typo-tolerant search (Orama index over all
|
|
2070
|
+
* loaded elements).
|
|
2071
|
+
* - Expression: MistQL pipe expressions over the flattened graph
|
|
2072
|
+
* (e.g. ``Person | filter name == "John"``). Collections available:
|
|
2073
|
+
* nodes/edges/graph (all), vnodes/vedges/vgraph (visible only), and each
|
|
2074
|
+
* label (Person, ACTED_IN, ...).
|
|
2075
|
+
* - Both: expression filters first, then full-text searches that subset.
|
|
2076
|
+
*
|
|
2077
|
+
* Results are click-to-focus, double-click-to-focus-and-select on the canvas.
|
|
2078
|
+
* Renderer-agnostic: uses only the workspace stores and live graph data.
|
|
2079
|
+
*/
|
|
2080
|
+
|
|
2081
|
+
declare function GraphFinder(): React__default.ReactElement;
|
|
2082
|
+
|
|
2083
|
+
/**
|
|
2084
|
+
* Graph finder types.
|
|
2085
|
+
*
|
|
2086
|
+
* Type definitions for the client-side graph finder: the Orama full-text
|
|
2087
|
+
* index over the loaded nodes/edges, its documents, results, and options.
|
|
2088
|
+
*/
|
|
2089
|
+
/**
|
|
2090
|
+
* Orama document structure for indexing nodes and edges.
|
|
2091
|
+
*
|
|
2092
|
+
* Contains fallback fields (always present) that make any node/edge
|
|
2093
|
+
* searchable without a data-model schema.
|
|
2094
|
+
*/
|
|
2095
|
+
interface OramaDocument {
|
|
2096
|
+
/** Unique ID (node or edge ID) */
|
|
2097
|
+
id_: string;
|
|
2098
|
+
/** Type: 'node' or 'edge' */
|
|
2099
|
+
type: "node" | "edge";
|
|
2100
|
+
/** Label (e.g. 'Person', 'ACTED_IN') */
|
|
2101
|
+
label_: string;
|
|
2102
|
+
/** Display name for UI */
|
|
2103
|
+
displayName: string;
|
|
2104
|
+
/** Concatenated text from all properties for full-text search */
|
|
2105
|
+
searchableText: string;
|
|
2106
|
+
/** JSON-stringified properties (fallback field) */
|
|
2107
|
+
properties_json: string;
|
|
2108
|
+
/** Whether this item is currently visible in the graph */
|
|
2109
|
+
isVisible: boolean;
|
|
2110
|
+
/** Start node ID (edges only) */
|
|
2111
|
+
start_id_?: string;
|
|
2112
|
+
/** End node ID (edges only) */
|
|
2113
|
+
end_id_?: string;
|
|
2114
|
+
}
|
|
2115
|
+
/** A finder full-text result with relevance score. */
|
|
2116
|
+
interface OramaSearchResult {
|
|
2117
|
+
/** The matched document */
|
|
2118
|
+
document: OramaDocument;
|
|
2119
|
+
/** Relevance score (higher = more relevant) */
|
|
2120
|
+
score: number;
|
|
2121
|
+
/** Matched terms (for highlighting) */
|
|
2122
|
+
positions?: Record<string, unknown>;
|
|
2123
|
+
}
|
|
2124
|
+
/** Finder index statistics for status display. */
|
|
2125
|
+
interface ServiceStats {
|
|
2126
|
+
totalIndexed: number;
|
|
2127
|
+
nodesIndexed: number;
|
|
2128
|
+
edgesIndexed: number;
|
|
2129
|
+
/** Timestamp of last index build */
|
|
2130
|
+
lastIndexBuild: number | null;
|
|
2131
|
+
/** Whether the index is ready to search */
|
|
2132
|
+
isReady: boolean;
|
|
2133
|
+
}
|
|
2134
|
+
/** Configuration for the finder's Orama search service. */
|
|
2135
|
+
interface OramaSearchServiceConfig {
|
|
2136
|
+
/** Enable debug logging (default: false) */
|
|
2137
|
+
debug?: boolean;
|
|
2138
|
+
/** Maximum nodes to index -- safety limit (default: 100000) */
|
|
2139
|
+
maxNodes?: number;
|
|
2140
|
+
/** Lazy initialization -- only build when needed (default: true) */
|
|
2141
|
+
lazyInit?: boolean;
|
|
2142
|
+
}
|
|
2143
|
+
/** Options for a full-text finder query. */
|
|
2144
|
+
interface SearchOptions {
|
|
2145
|
+
/** Search term (natural language query) */
|
|
2146
|
+
term: string;
|
|
2147
|
+
/** Filter by node/edge labels (optional) */
|
|
2148
|
+
labels?: string[];
|
|
2149
|
+
/** Only search visible items (default: false) */
|
|
2150
|
+
visibleOnly?: boolean;
|
|
2151
|
+
/** Maximum number of results (default: 50) */
|
|
2152
|
+
limit?: number;
|
|
2153
|
+
/** Include edge results (default: true) */
|
|
2154
|
+
includeEdges?: boolean;
|
|
2155
|
+
/** Include node results (default: true) */
|
|
2156
|
+
includeNodes?: boolean;
|
|
2157
|
+
/** Custom field boosting (optional) */
|
|
2158
|
+
boost?: Record<string, number>;
|
|
2159
|
+
}
|
|
2160
|
+
/**
|
|
2161
|
+
* Visibility tracking subset used when building documents.
|
|
2162
|
+
* A subset of the normalized graph shape.
|
|
2163
|
+
*/
|
|
2164
|
+
interface NormalizedData {
|
|
2165
|
+
hiddenNodeIds: Set<string>;
|
|
2166
|
+
hiddenEdgeIds: Set<string>;
|
|
2167
|
+
}
|
|
2168
|
+
|
|
2169
|
+
/**
|
|
2170
|
+
* useGraphSearch -- full-text finder over the currently loaded graph.
|
|
2171
|
+
*
|
|
2172
|
+
* Wraps an OramaSearchService whose index is built on demand: not when the
|
|
2173
|
+
* finder opens, only when the user actually runs a full-text search. The
|
|
2174
|
+
* index covers ALL nodes/edges from the last query (``baseNormalized``, the
|
|
2175
|
+
* same source expression mode uses), independent of label filters or focus.
|
|
2176
|
+
* When the underlying data changes the index is marked dirty and rebuilt on
|
|
2177
|
+
* the next search.
|
|
2178
|
+
*/
|
|
2179
|
+
|
|
2180
|
+
interface UseGraphSearchReturn {
|
|
2181
|
+
/** Run a full-text search; builds/rebuilds the index on demand. */
|
|
2182
|
+
search: (query: string, options?: Omit<SearchOptions, "term">) => Promise<OramaSearchResult[]>;
|
|
2183
|
+
/** Whether the index is initialized and current. */
|
|
2184
|
+
isReady: boolean;
|
|
2185
|
+
/** Whether the index is being (re)built. */
|
|
2186
|
+
isIndexing: boolean;
|
|
2187
|
+
/** Current index statistics (null before first build). */
|
|
2188
|
+
stats: ServiceStats | null;
|
|
2189
|
+
/** Any initialization/indexing error. */
|
|
2190
|
+
error: Error | null;
|
|
2191
|
+
}
|
|
2192
|
+
declare function useGraphSearch(): UseGraphSearchReturn;
|
|
2193
|
+
|
|
2194
|
+
/**
|
|
2195
|
+
* Orama full-text index for the graph finder.
|
|
2196
|
+
*
|
|
2197
|
+
* Maintains a client-side Orama index over the nodes/edges currently loaded
|
|
2198
|
+
* from a query. Uses a full rebuild when the index becomes dirty (simple and
|
|
2199
|
+
* fast for typical graphs) and lazily initializes only when first searched.
|
|
2200
|
+
*/
|
|
2201
|
+
|
|
2202
|
+
declare class OramaSearchService {
|
|
2203
|
+
private db;
|
|
2204
|
+
private config;
|
|
2205
|
+
private isDirty;
|
|
2206
|
+
private isInitialized;
|
|
2207
|
+
private lastIndexBuild;
|
|
2208
|
+
private stats;
|
|
2209
|
+
constructor(config?: OramaSearchServiceConfig);
|
|
2210
|
+
/** Create the empty index with the finder schema (idempotent). */
|
|
2211
|
+
initialize(): Promise<void>;
|
|
2212
|
+
/** Drop all documents (recreates the index; Orama has no bulk delete). */
|
|
2213
|
+
clear(): Promise<void>;
|
|
2214
|
+
/** Mark the index stale so the next search rebuilds it. */
|
|
2215
|
+
markDirty(): void;
|
|
2216
|
+
/** Whether the index needs a (re)build before searching. */
|
|
2217
|
+
needsRebuild(): boolean;
|
|
2218
|
+
/** Rebuild the whole index from the given nodes and edges. */
|
|
2219
|
+
rebuildIndex(nodes: VisualGraphNode[], edges: VisualGraphEdge[], normalized?: NormalizedData): Promise<void>;
|
|
2220
|
+
/** Run a full-text query against the index. */
|
|
2221
|
+
search(options: SearchOptions): Promise<OramaSearchResult[]>;
|
|
2222
|
+
/** Current index statistics. */
|
|
2223
|
+
getStats(): ServiceStats;
|
|
2224
|
+
/** Whether the index is ready to serve searches. */
|
|
2225
|
+
isReady(): boolean;
|
|
2226
|
+
}
|
|
2227
|
+
|
|
2228
|
+
/**
|
|
2229
|
+
* Flatten a normalized graph into a query-friendly shape for the finder's
|
|
2230
|
+
* expression mode (MistQL). Node/edge properties are spread to the top level,
|
|
2231
|
+
* and collections are grouped by label, so queries like
|
|
2232
|
+
* ``Person | filter name == "John"`` or ``graph | filter name == "ABC"`` work.
|
|
2233
|
+
*/
|
|
2234
|
+
|
|
2235
|
+
/** A node with its properties spread to the top level. */
|
|
2236
|
+
interface FlattenedNode {
|
|
2237
|
+
id_: number;
|
|
2238
|
+
label_: string;
|
|
2239
|
+
displayName: string;
|
|
2240
|
+
color: string;
|
|
2241
|
+
[key: string]: unknown;
|
|
2242
|
+
}
|
|
2243
|
+
/** An edge with its properties spread to the top level. */
|
|
2244
|
+
interface FlattenedEdge {
|
|
2245
|
+
id_: number;
|
|
2246
|
+
label_: string;
|
|
2247
|
+
start_id_: number;
|
|
2248
|
+
end_id_: number;
|
|
2249
|
+
[key: string]: unknown;
|
|
2250
|
+
}
|
|
2251
|
+
/** Flattened graph with raw, combined, and label-grouped collections. */
|
|
2252
|
+
interface FlattenedGraphData {
|
|
2253
|
+
nodes: FlattenedNode[];
|
|
2254
|
+
edges: FlattenedEdge[];
|
|
2255
|
+
/** All nodes and edges as a single array. */
|
|
2256
|
+
graph: Array<FlattenedNode | FlattenedEdge>;
|
|
2257
|
+
_labels: string[];
|
|
2258
|
+
_edgeLabels: string[];
|
|
2259
|
+
/** Dynamic label groups, e.g. Person / ACTED_IN. */
|
|
2260
|
+
[key: string]: unknown;
|
|
2261
|
+
}
|
|
2262
|
+
/** Flatten normalized graph data. Pure function -- no React hooks. */
|
|
2263
|
+
declare function flattenGraphData(normalized: NormalizedGraph): FlattenedGraphData;
|
|
2264
|
+
|
|
2265
|
+
export { ActionPanel, type ActionPanelState, type ActionPanelStore, type CapabilitiesValidation, type Cardinality, type ColorPalette, type CreateEdgeInput, type CreateNodeInput, type CreateNodeWithRelationsInput, type CreateNodeWithRelationsResult, DeleteNodeDialog, type DeleteNodeDialogProps, EMPTY_NORMALIZED, EdgeFormSheet, type EdgeFormSheetProps, EdgeInfoCard, type EdgeTypeMode, type EdgeTypeView, type EdgeVisual, type EditMode$1 as EditMode, type EditableMode, type ExpandOptions, type ExpandResult, type ExtractedGraphRows, type FlattenedEdge, type FlattenedGraphData, type FlattenedNode, GraphA11yList, type GraphA11yListProps, type GraphCapabilities, type GraphCapabilitiesValidation, type GraphDataHook, type GraphDataStore, type GraphDisplayConfig, type EditMode as GraphEditMode, GraphEditToolbar, type GraphEditToolbarProps, type GraphExplorationDeps, type GraphExplorationStore, type GraphFilterStore, GraphFinder, type GraphFocusAction, type GraphFocusStore, type GraphModel, type GraphModelCapabilities, type GraphModelDisplay, GraphModelEditor, type GraphModelEditorProps, type GraphModelProperty, type GraphMutationPort, type GraphProperties, type GraphProperty, type GraphRelation, type GraphRenderer, GraphRendererProvider, type GraphSchemaProvider, type GraphStatistics, type WorkspaceStores as GraphStoreBundle, GraphStoresContext, type GraphTypeSchema, GraphVisualizer, type GraphVisualizerProps, type LabelDisplayMap, type LiveGraphDataResult, ModelActionPanel, type ModelActionPanelProps, type ModelGraph, NodeFormSheet, type NodeFormSheetProps, NodeInfoCard, NodeTypeNameSheet, type NodeTypeNameSheetProps, type NodeTypeView, type NodeVisual, type NormalizedData, type NormalizedGraph, type OramaDocument, type OramaSearchResult, OramaSearchService, type OramaSearchServiceConfig, Overview, PropertyFormSheet, type PropertyFormSheetProps, type PropertyInput, type PropertyView, QueryEditor, type QueryEditorProps, QueryHistory, type QueryHistoryState, type QueryHistoryStore, type RawGraphEdge, type RawGraphNode, type RelationCardinality, type RelationDef, type RelationDetailView, RelationFormSheet, type RelationFormSheetProps, type RelationInput, type RelationMap, type RelationView, type ResolvedCapabilities, type ResolvedGraphCapabilities, type SearchOptions, type SelectionStore, type ServiceStats, type StoreFactory, TypeDetailPanel, type TypeDetailPanelProps, type UpdateEdgeInput, type UpdateNodeInput, type UpdateNodeWithRelationsInput, type UpdateNodeWithRelationsResult, type UseGraphSearchReturn, type VisualGraphEdge, type VisualGraphNode, type VisualGraphNormalized, type WorkspaceStores, type XGraph, addEdgeType, addNodeType, addRelation, buildColorPalette, buildColorPaletteFromNodes, capabilitiesSchema, cardinalityLabel, createActionPanelStore, createGraphDataStore, createGraphExplorationStore, createGraphFilterStore, createGraphFocusStore, createQueryHistoryStore, createSelectionStore, deleteEdgeType, deleteEdgeTypeProperty, deleteNodeProperty, deleteNodeType, deleteRelation, deleteRelationProperty, edgeTypeView, editableRelations, enrichEdge, enrichEdges, enrichNode, enrichNodes, enrichSchemaWithRelations, extractDisplayLabel, extractGraphFromRows, extractRelationFields, findEdgeType, findType, flattenGraphData, graphCapabilitiesSchema, groupEdgesByRelation, hasProperties, hasRelationFields, initializeFormData, isEdgeType, isNodeType, isRawGraphNode, isRelationField, isVisualEdge, isVisualNode, modelToGraph, nodeTypeView, normalizeGraph, reconcileFilter, relationFieldName, relationTitle, relationTypeFromField, relationView, renameEdgeType, renameNodeType, resolveCapabilities, resolveGraphCapabilities, resolveRelationEdge, setEdgeTypeProperty, setNodeProperty, setRelationProperty, toCytoscapeEdge, toCytoscapeNode, toReagraphEdge, toReagraphNode, typeLabel, updateRelation, useActionPanelStore, useCytoscapeData, useGraphFocus, useGraphRenderer, useGraphSearch, useLiveGraphData, useReagraphData, useStableRef, useWorkspaceGraphData, useWorkspaceGraphExploration, useWorkspaceGraphFilter, useWorkspaceGraphFocus, useWorkspaceSelection, validateCapabilities, validateGraphCapabilities };
|