feat(events): change notifications on GraphScopedDataset with cross-graph dedup - #96
Draft
jeswr wants to merge 4 commits into
Draft
feat(events): change notifications on GraphScopedDataset with cross-graph dedup#96jeswr wants to merge 4 commits into
jeswr wants to merge 4 commits into
Conversation
DatasetWrapper now layers @jeswr/eventful-dataset's EventfulDatasetCore over the wrapped dataset (constructor signature unchanged; write-through storage preserved) and exposes on(listener)/off(listener) so consumers can observe effective additions and deletions - whether performed directly or through mapped properties, Set mappings, or named graph views sharing the same eventful core. Adds the IDatasetChangeListener/ChangeEvent types to the public surface and ports the dataset_events test slices from rdfjs#73. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Generalizes NamedGraphDataset (which stays untouched) into a view that reads a configurable set of graphs — or every graph when the read scope is undefined — projected onto the default graph with per-triple deduplication, while directing all writes to a single configured graph. - src/GraphScopedDataset.ts: reads union the read graphs and project to the default graph; add/delete/has enforce default-graph input via ensureDefaultGraph; match mirrors NamedGraphDataset's self-wrapping pattern and rejects non-default graph arguments with TermTypeError. - DatasetWrapper.scoped(writeGraph, readGraphs, klass) beside named(). - IGraphScopedDatasetConstructor in src/type/, both exported from mod. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Combines the DatasetWrapper change-notification surface (on/off) with the GraphScopedDataset view so the scoped view can take part in eventing. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…raph dedup GraphScopedDataset overrides on/off so listeners observe the projected view rather than the raw underlying dataset: - changes are filtered to the read scope and delivered with the quad projected onto the default graph; - a triple occurring in several read graphs is reported as added only once and as deleted only when its last copy disappears from the read scope; - the view subscribes to the underlying dataset lazily: the first listener attaches a single shared callback (via DatasetWrapper.on) and the last off() detaches it. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Draft
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds change notifications to
GraphScopedDataset: listeners attached withon(listener)/off(listener)observe the projected view — filtered to the read scope, delivered in the default graph, and deduplicated across read graphs.Note
Stacked PR. This branch builds on #94 (
DatasetWrapper.on/off) and #95 (GraphScopedDataset) and includes their commits; only the last commit (feat(events): change notifications on GraphScopedDataset with cross-graph dedup) is new here. It becomes a two-file diff once those two merge.What it does
GraphScopedDatasetinheritson/offfrom #94, but the inherited semantics are wrong for a projected view: listeners would see raw source quads from every graph, with their original graph components. This PR overrideson/offso that:readGraphsare not reported (union views report every graph).DatasetWrapper.on, so it reuses feat(events): change notifications on DatasetWrapper (on/off) #94's eventful core and listener bookkeeping) and detaches it when the last listener leaves.add/delete, or wrapper-driven mutations) are observed like any other change, provided the write graph is within the read scope.No new exports and no new dependencies beyond what #94/#95 introduce: the listener contract is #94's existing
IDatasetChangeListener.Relation to #73
Supersedes the projected-view event slice of #73 (Omnibus): the
ProjectedDatasetCoreWrapperevent callback (isReadGraphfilter +existsInOtherReadGraphsuppression + default-graph re-emission) and its lazy attach/detach-on-last-listener bookkeeping, now expressed as aGraphScopedDatasetoverride on top of #94's notification surface instead of the bespoke in-repoNotifyingDatasetCore/EventEmitter. The event-dedup tests from #73'sprojected_dataset.test.tsare ported here. Not included (left to their own slices): theTriple/default-graph type restrictions,datasetFactoryplumbing, lazymatchmaterialization, and the async work.Tests
test/unit/graph_scoped_events.test.ts:readGraphs === undefined): events from any graph, dedup against copies in any other graph;onand detached on the lastoff(asserted vialistenerCounton anEventfulDatasetCoresource).Every delivered quad is asserted to be in the default graph.
npm i && npx tsc && npm test && npx typedoc && npm audit --omit=dev --audit-level=moderateall pass locally (192 tests, 0 fail; typedoc warnings unchanged frommain).