Files
Synapse/app/lib/src/rust/api/dto.dart
T
dasemuandClaude Opus 5.5 e43452f5af feat(graph): graph view with network, local, synapse, cluster and namespace modes
- synapse-ffi: graph_data() returns the whole page-level graph (links, tags,
  property refs, block refs/embeds per page, unlinked mentions, decayed
  synapses) as parallel arrays with degree, backlinks, Louvain clusters and
  primary tags; cached by op seq, synapse state and hour.
- synapse-ffi: ForceLayout, a Barnes-Hut force layout stepped from Dart on a
  Rust worker thread (pin/unpin for dragging, reheat).
- app: Graph view with a mode selector (Network, Local, Synapses, Clusters,
  Namespaces, Timeline), filters (title, tag, date range, min links,
  orphans, journals, mentions), pan/zoom, node drag, hover highlighting,
  activation pulse, cluster hulls, radial namespace/tag tree, and a local
  graph panel on every page. Edges render as one vertex mesh, nodes in
  colour/size batches, culled to the viewport.
- Tests: Rust extraction/mentions/cache/clusters/layout; widget tests for
  mode switching, filters and layout restarts; a real-app integration
  smoke test with frame timings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-21 15:39:07 +02:00

544 lines
13 KiB
Dart

// This file is automatically generated, so please do not edit it.
// @generated by `flutter_rust_bridge`@ 2.13.0.
// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import
import '../frb_generated.dart';
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';
// These functions are ignored because they are not marked as `pub`: `new`
// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `assert_fields_are_eq`, `assert_fields_are_eq`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `clone`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `eq`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `fmt`, `from`, `from`
class AssetDto {
final String hash;
final BigInt size;
final String? mime;
final String? originalName;
const AssetDto({
required this.hash,
required this.size,
this.mime,
this.originalName,
});
@override
int get hashCode =>
hash.hashCode ^ size.hashCode ^ mime.hashCode ^ originalName.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is AssetDto &&
runtimeType == other.runtimeType &&
hash == other.hash &&
size == other.size &&
mime == other.mime &&
originalName == other.originalName;
}
/// Blocks of one page referencing the queried page.
class BacklinkGroup {
final String pageId;
final String pageTitle;
final bool isJournal;
final List<BlockDto> blocks;
const BacklinkGroup({
required this.pageId,
required this.pageTitle,
required this.isJournal,
required this.blocks,
});
@override
int get hashCode =>
pageId.hashCode ^
pageTitle.hashCode ^
isJournal.hashCode ^
blocks.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is BacklinkGroup &&
runtimeType == other.runtimeType &&
pageId == other.pageId &&
pageTitle == other.pageTitle &&
isJournal == other.isJournal &&
blocks == other.blocks;
}
/// One row of the outline, in pre-order.
class BlockDto {
final String id;
final String? parentId;
final int depth;
final String content;
final bool collapsed;
final bool hasChildren;
const BlockDto({
required this.id,
this.parentId,
required this.depth,
required this.content,
required this.collapsed,
required this.hasChildren,
});
@override
int get hashCode =>
id.hashCode ^
parentId.hashCode ^
depth.hashCode ^
content.hashCode ^
collapsed.hashCode ^
hasChildren.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is BlockDto &&
runtimeType == other.runtimeType &&
id == other.id &&
parentId == other.parentId &&
depth == other.depth &&
content == other.content &&
collapsed == other.collapsed &&
hasChildren == other.hasChildren;
}
/// `((` autocomplete hit.
class BlockHit {
final String id;
final String content;
final String pageTitle;
const BlockHit({
required this.id,
required this.content,
required this.pageTitle,
});
@override
int get hashCode => id.hashCode ^ content.hashCode ^ pageTitle.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is BlockHit &&
runtimeType == other.runtimeType &&
id == other.id &&
content == other.content &&
pageTitle == other.pageTitle;
}
/// Target of a `((block ref))`.
class BlockRefDto {
final String id;
final String content;
final String pageId;
final String pageTitle;
const BlockRefDto({
required this.id,
required this.content,
required this.pageId,
required this.pageTitle,
});
@override
int get hashCode =>
id.hashCode ^ content.hashCode ^ pageId.hashCode ^ pageTitle.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is BlockRefDto &&
runtimeType == other.runtimeType &&
id == other.id &&
content == other.content &&
pageId == other.pageId &&
pageTitle == other.pageTitle;
}
class EditDto {
final String pageId;
final int edits;
const EditDto({required this.pageId, required this.edits});
@override
int get hashCode => pageId.hashCode ^ edits.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is EditDto &&
runtimeType == other.runtimeType &&
pageId == other.pageId &&
edits == other.edits;
}
/// The whole page-level graph, edges as parallel arrays (cheap to move across the FFI).
/// Edges are directed source → target, except synapses (stored once, `source < target`).
class GraphData {
final List<GraphNode> nodes;
final Uint32List sources;
final Uint32List targets;
/// See [`edge_kind`].
final Uint8List kinds;
/// Number of references (structural edges) or synapse strength.
final Float32List weights;
/// Op-log sequence the data was built at.
final PlatformInt64 seq;
const GraphData({
required this.nodes,
required this.sources,
required this.targets,
required this.kinds,
required this.weights,
required this.seq,
});
@override
int get hashCode =>
nodes.hashCode ^
sources.hashCode ^
targets.hashCode ^
kinds.hashCode ^
weights.hashCode ^
seq.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is GraphData &&
runtimeType == other.runtimeType &&
nodes == other.nodes &&
sources == other.sources &&
targets == other.targets &&
kinds == other.kinds &&
weights == other.weights &&
seq == other.seq;
}
class GraphNode {
final String id;
final String title;
final String? journalDate;
final String? originJournal;
final PlatformInt64 createdAt;
/// Distinct neighbours over structural edges (links, tags, properties, block refs).
final int degree;
/// Distinct pages referencing this one.
final int backlinks;
/// Community (Louvain), numbered by size: 0 is the largest.
final int cluster;
/// Node index of the tag this page uses most, if any.
final int? primaryTag;
const GraphNode({
required this.id,
required this.title,
this.journalDate,
this.originJournal,
required this.createdAt,
required this.degree,
required this.backlinks,
required this.cluster,
this.primaryTag,
});
@override
int get hashCode =>
id.hashCode ^
title.hashCode ^
journalDate.hashCode ^
originJournal.hashCode ^
createdAt.hashCode ^
degree.hashCode ^
backlinks.hashCode ^
cluster.hashCode ^
primaryTag.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is GraphNode &&
runtimeType == other.runtimeType &&
id == other.id &&
title == other.title &&
journalDate == other.journalDate &&
originJournal == other.originJournal &&
createdAt == other.createdAt &&
degree == other.degree &&
backlinks == other.backlinks &&
cluster == other.cluster &&
primaryTag == other.primaryTag;
}
/// One batch of layout iterations.
class LayoutFrame {
/// `x0, y0, x1, y1, ...`
final Float32List positions;
/// Remaining "temperature"; the layout is settled when it reaches 0.
final double alpha;
const LayoutFrame({required this.positions, required this.alpha});
@override
int get hashCode => positions.hashCode ^ alpha.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is LayoutFrame &&
runtimeType == other.runtimeType &&
positions == other.positions &&
alpha == other.alpha;
}
class PageBrief {
final String id;
final String title;
final bool isJournal;
const PageBrief({
required this.id,
required this.title,
required this.isJournal,
});
@override
int get hashCode => id.hashCode ^ title.hashCode ^ isJournal.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is PageBrief &&
runtimeType == other.runtimeType &&
id == other.id &&
title == other.title &&
isJournal == other.isJournal;
}
/// Everything the page view needs in one call.
class PageData {
final PageDto page;
final List<BlockDto> blocks;
final List<String> aliases;
/// Previous/next existing journal (journal pages only).
final String? prevJournal;
final String? nextJournal;
const PageData({
required this.page,
required this.blocks,
required this.aliases,
this.prevJournal,
this.nextJournal,
});
@override
int get hashCode =>
page.hashCode ^
blocks.hashCode ^
aliases.hashCode ^
prevJournal.hashCode ^
nextJournal.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is PageData &&
runtimeType == other.runtimeType &&
page == other.page &&
blocks == other.blocks &&
aliases == other.aliases &&
prevJournal == other.prevJournal &&
nextJournal == other.nextJournal;
}
/// Page header data.
class PageDto {
final String id;
final String title;
/// Set for journal pages.
final String? journalDate;
/// Journal day the page was born in.
final String? originJournal;
final PlatformInt64 createdAt;
final PlatformInt64 updatedAt;
const PageDto({
required this.id,
required this.title,
this.journalDate,
this.originJournal,
required this.createdAt,
required this.updatedAt,
});
@override
int get hashCode =>
id.hashCode ^
title.hashCode ^
journalDate.hashCode ^
originJournal.hashCode ^
createdAt.hashCode ^
updatedAt.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is PageDto &&
runtimeType == other.runtimeType &&
id == other.id &&
title == other.title &&
journalDate == other.journalDate &&
originJournal == other.originJournal &&
createdAt == other.createdAt &&
updatedAt == other.updatedAt;
}
class Place {
final PlaceKind kind;
final String? anchor;
const Place({required this.kind, this.anchor});
@override
int get hashCode => kind.hashCode ^ anchor.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is Place &&
runtimeType == other.runtimeType &&
kind == other.kind &&
anchor == other.anchor;
}
/// Where a block goes, relative to `anchor`.
enum PlaceKind {
after,
before,
/// Last child of `anchor`, or last root block when `anchor` is `None`.
lastChildOf,
/// First child of `anchor`, or first root block when `anchor` is `None`.
firstChildOf,
}
class RelatedDto {
final PageBrief page;
final double score;
const RelatedDto({required this.page, required this.score});
@override
int get hashCode => page.hashCode ^ score.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is RelatedDto &&
runtimeType == other.runtimeType &&
page == other.page &&
score == other.score;
}
class TimelineDayDto {
final String date;
final String? journalId;
/// Pages born on this day.
final List<String> created;
/// Pages edited on this day.
final List<EditDto> edited;
const TimelineDayDto({
required this.date,
this.journalId,
required this.created,
required this.edited,
});
@override
int get hashCode =>
date.hashCode ^ journalId.hashCode ^ created.hashCode ^ edited.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is TimelineDayDto &&
runtimeType == other.runtimeType &&
date == other.date &&
journalId == other.journalId &&
created == other.created &&
edited == other.edited;
}
/// Timeline slice plus the titles of every page it mentions.
class TimelineDto {
final List<TimelineDayDto> days;
final List<PageBrief> pages;
const TimelineDto({required this.days, required this.pages});
@override
int get hashCode => days.hashCode ^ pages.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is TimelineDto &&
runtimeType == other.runtimeType &&
days == other.days &&
pages == other.pages;
}
/// Quick switcher / `[[` autocomplete hit.
class TitleHit {
final String pageId;
/// The matched title or alias.
final String title;
final bool isAlias;
const TitleHit({
required this.pageId,
required this.title,
required this.isAlias,
});
@override
int get hashCode => pageId.hashCode ^ title.hashCode ^ isAlias.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is TitleHit &&
runtimeType == other.runtimeType &&
pageId == other.pageId &&
title == other.title &&
isAlias == other.isAlias;
}