rhizome-node/src/collections/collection-relational.ts
Lentil Hoffman 73d2bf23f5
refactor: simplify relationship graph implementation
- Implement RelationshipGraphResolver extending Lossy
- Add type-safe accumulator for relationship graph state
- Update tests and documentation
2025-06-22 18:39:53 -05:00

28 lines
838 B
TypeScript

import {Collection} from "./collection-abstract";
import { ResolvedTimestampedViewOne as ResolvedViewOne } from "../views/resolvers/timestamp-resolvers";
import {TimestampResolver} from "../views/resolvers/timestamp-resolvers";
class RelationalView extends TimestampResolver {
}
export class RelationalCollection extends Collection<RelationalView> {
declare lossy?: RelationalView;
initializeView() {
if (!this.rhizomeNode) throw new Error('not connected to rhizome');
this.lossy = new RelationalView(this.rhizomeNode.lossless);
}
resolve(
id: string
): ResolvedViewOne | undefined {
if (!this.rhizomeNode) throw new Error('collection not connected to rhizome');
if (!this.lossy) throw new Error('lossy view not initialized');
const res = this.lossy.resolve([id]) || {};
return res[id];
}
}