Files
Synapse/app/lib/src/rust/api/dto.dart
T
dasemuandClaude Sonnet 5.5 b800248d67 feat(core): hubs, tag pages and types, with ffi, history and import support
Hubs and templates are page kinds; tags are pages of kind tag linked by a TAGGED
edge; types are plain names on the page. Schema v5. Snapshots carry
synapse-kind/tags/types. Also adapts search, import and server tests.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-26 02:45:22 +01:00

846 lines
21 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`, `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`, `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`, `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, hub
/// membership).
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;
/// The page is a hub (`PageKind::Hub`).
final bool isHub;
/// Node index of the deepest hub containing this page (a hub: itself).
final int? homeHub;
/// Tag names of the page (see `PageDto::tags`), for grouping by tag.
final List<String> tags;
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,
required this.isHub,
this.homeHub,
required this.tags,
});
@override
int get hashCode =>
id.hashCode ^
title.hashCode ^
journalDate.hashCode ^
originJournal.hashCode ^
createdAt.hashCode ^
degree.hashCode ^
backlinks.hashCode ^
cluster.hashCode ^
primaryTag.hashCode ^
isHub.hashCode ^
homeHub.hashCode ^
tags.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 &&
isHub == other.isHub &&
homeHub == other.homeHub &&
tags == other.tags;
}
/// A hub (folder-like page) with its members.
class HubDto {
final String id;
final String title;
final String description;
/// 0 for root hubs, one more per level of nesting.
final int depth;
/// Sub-hubs first, then notes, each by title.
final List<PageBrief> members;
/// Ids of the members that are hubs themselves.
final List<String> subHubs;
const HubDto({
required this.id,
required this.title,
required this.description,
required this.depth,
required this.members,
required this.subHubs,
});
@override
int get hashCode =>
id.hashCode ^
title.hashCode ^
description.hashCode ^
depth.hashCode ^
members.hashCode ^
subHubs.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is HubDto &&
runtimeType == other.runtimeType &&
id == other.id &&
title == other.title &&
description == other.description &&
depth == other.depth &&
members == other.members &&
subHubs == other.subHubs;
}
/// Defaults for the "convert to hub" dialog.
class HubPreviewDto {
/// Last namespace segment of the title.
final String suggestedTitle;
/// First prose block as plain text (<= 280 chars).
final String suggestedDescription;
/// Candidate members: pages the outline links or tags (outline order), then pages
/// referencing the note from properties or tags.
final List<PageBrief> members;
/// Blocks that are prose rather than links (what "keep the outline" would save).
final int proseBlocks;
final int blocks;
/// `"<suggested_title> (notes)"`, for the note receiving the outline.
final String suggestedNoteTitle;
const HubPreviewDto({
required this.suggestedTitle,
required this.suggestedDescription,
required this.members,
required this.proseBlocks,
required this.blocks,
required this.suggestedNoteTitle,
});
@override
int get hashCode =>
suggestedTitle.hashCode ^
suggestedDescription.hashCode ^
members.hashCode ^
proseBlocks.hashCode ^
blocks.hashCode ^
suggestedNoteTitle.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is HubPreviewDto &&
runtimeType == other.runtimeType &&
suggestedTitle == other.suggestedTitle &&
suggestedDescription == other.suggestedDescription &&
members == other.members &&
proseBlocks == other.proseBlocks &&
blocks == other.blocks &&
suggestedNoteTitle == other.suggestedNoteTitle;
}
class HubsDto {
/// Sorted by title.
final List<HubDto> hubs;
/// Ids of the hubs that are not a member of any hub, by title.
final List<String> roots;
const HubsDto({required this.hubs, required this.roots});
@override
int get hashCode => hubs.hashCode ^ roots.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is HubsDto &&
runtimeType == other.runtimeType &&
hubs == other.hubs &&
roots == other.roots;
}
/// 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;
}
/// A page the legacy purge offers to delete.
class LegacyCandidate {
final String id;
final String title;
final String reason;
final int blocks;
final bool preselected;
const LegacyCandidate({
required this.id,
required this.title,
required this.reason,
required this.blocks,
required this.preselected,
});
@override
int get hashCode =>
id.hashCode ^
title.hashCode ^
reason.hashCode ^
blocks.hashCode ^
preselected.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is LegacyCandidate &&
runtimeType == other.runtimeType &&
id == other.id &&
title == other.title &&
reason == other.reason &&
blocks == other.blocks &&
preselected == other.preselected;
}
/// A level of a namespace (`A/B` under `A`); `id` is `None` when only deeper pages exist.
class NamespaceEntry {
final String title;
final String? id;
const NamespaceEntry({required this.title, this.id});
@override
int get hashCode => title.hashCode ^ id.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is NamespaceEntry &&
runtimeType == other.runtimeType &&
title == other.title &&
id == other.id;
}
class PageBrief {
final String id;
final String title;
final bool isJournal;
final bool isHub;
const PageBrief({
required this.id,
required this.title,
required this.isJournal,
required this.isHub,
});
@override
int get hashCode =>
id.hashCode ^ title.hashCode ^ isJournal.hashCode ^ isHub.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is PageBrief &&
runtimeType == other.runtimeType &&
id == other.id &&
title == other.title &&
isJournal == other.isJournal &&
isHub == other.isHub;
}
/// 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;
/// The page is a hub (no blocks; members list instead of an outline).
final bool isHub;
/// Hub description (empty for notes).
final String description;
/// Titles of the tag pages this page is filed under, in the order they were added.
final List<String> tags;
/// The page is a tag page (a topic that other pages are filed under).
final bool isTag;
/// Type names ("persona", "lugar"...: plain names, not pages), in the order added.
final List<String> types;
const PageDto({
required this.id,
required this.title,
this.journalDate,
this.originJournal,
required this.createdAt,
required this.updatedAt,
required this.isHub,
required this.description,
required this.tags,
required this.isTag,
required this.types,
});
@override
int get hashCode =>
id.hashCode ^
title.hashCode ^
journalDate.hashCode ^
originJournal.hashCode ^
createdAt.hashCode ^
updatedAt.hashCode ^
isHub.hashCode ^
description.hashCode ^
tags.hashCode ^
isTag.hashCode ^
types.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 &&
isHub == other.isHub &&
description == other.description &&
tags == other.tags &&
isTag == other.isTag &&
types == other.types;
}
/// Hub and namespace context of one page.
class PageStructure {
final bool isHub;
/// Hub description (empty for notes).
final String description;
/// Empty unless the page is a hub; sub-hubs first, then notes.
final List<PageBrief> members;
/// Hubs the page belongs to (its own membership list), by title.
final List<PageBrief> inHubs;
/// Ancestor namespaces from the root: `A`, `A/B` for `A/B/C` (they may not exist).
final List<NamespaceEntry> nsPath;
final List<NamespaceEntry> nsChildren;
const PageStructure({
required this.isHub,
required this.description,
required this.members,
required this.inHubs,
required this.nsPath,
required this.nsChildren,
});
@override
int get hashCode =>
isHub.hashCode ^
description.hashCode ^
members.hashCode ^
inHubs.hashCode ^
nsPath.hashCode ^
nsChildren.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is PageStructure &&
runtimeType == other.runtimeType &&
isHub == other.isHub &&
description == other.description &&
members == other.members &&
inHubs == other.inHubs &&
nsPath == other.nsPath &&
nsChildren == other.nsChildren;
}
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;
}
/// A tag or type of the vocabulary.
class TagDto {
final String name;
/// Pages using it.
final int count;
/// One of the seeded suggestions.
final bool suggested;
const TagDto({
required this.name,
required this.count,
required this.suggested,
});
@override
int get hashCode => name.hashCode ^ count.hashCode ^ suggested.hashCode;
@override
bool operator ==(Object other) =>
identical(this, other) ||
other is TagDto &&
runtimeType == other.runtimeType &&
name == other.name &&
count == other.count &&
suggested == other.suggested;
}
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;
}